Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix streamz reference notebook #6980

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading