Skip to content

Commit

Permalink
fix streamz reference notebook (#6980)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSkovMadsen authored and philippjfr committed Jul 16, 2024
1 parent 567fb1b commit fd90c7c
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions examples/reference/panes/Streamz.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@
"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",
"<div class=\"alert alert-warning\">\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",
"</div>\n",
"\n",
"#### Parameters:\n",
"\n",
"For details on other options for customizing the component see the [layout](../../how_to/layout/index.md) and [styling](../../how_to/styling/index.md) how-to guides.\n",
"\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",
"___"
]
Expand Down Expand Up @@ -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": {},
Expand All @@ -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",
Expand Down

0 comments on commit fd90c7c

Please sign in to comment.