From fd90c7c133b266bcf3c3ec876e5d049320d12393 Mon Sep 17 00:00:00 2001 From: Marc Skov Madsen Date: Tue, 16 Jul 2024 09:50:01 +0200 Subject: [PATCH] fix streamz reference notebook (#6980) --- examples/reference/panes/Streamz.ipynb | 30 ++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/examples/reference/panes/Streamz.ipynb b/examples/reference/panes/Streamz.ipynb index 867dacd92f..87c08c7fee 100644 --- a/examples/reference/panes/Streamz.ipynb +++ b/examples/reference/panes/Streamz.ipynb @@ -17,7 +17,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The ``Streamz`` pane renders [streamz](https://github.com/python-streamz/streamz) Stream objects emitting arbitrary objects, unlike the ``DataFrame`` pane which specifically handles streamz DataFrame and Series objects and exposes various formatting objects.\n", + "The ``Streamz`` pane renders [Streamz](https://streamz.readthedocs.io/en/latest/) Stream objects emitting arbitrary objects, unlike the ``DataFrame`` pane which specifically handles streamz DataFrame and Series objects and exposes various formatting objects.\n", + "\n", + "
\n", + "\n", + "If you are not already a user of the Streamz library, we recommend using functionality from the Param and Panel ecosystem, such as [reactive expressions](https://param.holoviz.org/user_guide/Reactive_Expressions.html), [generator functions](https://param.holoviz.org/user_guide/Generators.html) and/ or *periodic callbacks*. We find these features to be more robustly supported.\n", + "\n", + "
\n", "\n", "#### Parameters:\n", "\n", @@ -25,7 +31,7 @@ "\n", "* **``always_watch``** (boolean, default=False): Whether to watch the stream even when not displayed.\n", "* **``object``** (streamz.Stream): The streamz.Stream object being watched\n", - "* **``rate_limit``** (float, default=0.1): The minimum interval between events.\n", + "* **``rate_limit``** (float, default=0.1): The minimum interval between events in seconds.\n", "\n", "___" ] @@ -80,6 +86,22 @@ "pn.state.add_periodic_callback(emit_count, period=100, count=9);" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Lets reset the pane" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "source.emit(1)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -105,11 +127,11 @@ " return alt.Chart(pd.concat(data).reset_index()).mark_line().encode(\n", " x='index',\n", " y='y',\n", - " )\n", + " ).properties(width=\"container\")\n", "\n", "altair_stream = df.cumsum().stream.sliding_window(50).map(line_plot)\n", "\n", - "altair_pane = pn.pane.Streamz(altair_stream, height=350, always_watch=True)\n", + "altair_pane = pn.pane.Streamz(altair_stream, height=350, sizing_mode=\"stretch_width\", always_watch=True)\n", "\n", "for i in range(100):\n", " df.emit(pd.DataFrame({'y': [np.random.randn()]}, index=pd.DatetimeIndex([datetime.now()])))\n",