-
-
Notifications
You must be signed in to change notification settings - Fork 552
Closed
Labels
type: discussionRequiring community discussionRequiring community discussion
Milestone
Description
I was just trying out pn.bind
and I can see that it does not support setting watch=True
. This limits the use cases. Then it's just easier to stick with @pn.depends
as it supports all use cases.
In the below example the slider does not work.
import numpy as np
import panel as pn
import pandas as pd
import plotly.graph_objects as go
pn.extension('plotly')
data = {}
for i in range(10):
xo = 5 * np.random.rand()
xf = 5 + 5 * np.random.rand()
x = np.linspace(xo, xf, int(50 + 50*np.random.rand()))
e = np.random.rand()
y = x**(1+e) * np.cos(x) + 4*(np.random.rand(len(x)) - 0.5)
data[i] = {
'x': x.tolist(),
'y': y.tolist()
}
nlines = pn.widgets.IntSlider(name='Number of lines', value=2, start=1, end=9)
timeseries = pn.pane.Plotly()
def get_plot(nlines):
print("get_plot", nlines)
fig = go.Figure()
for i in range(nlines):
fig.add_trace(
go.Scatter(x=data[i]['x'], y=data[i]['y'], mode='lines', name=f'line-{i}'))
timeseries.object = fig
get_plot(nlines.value)
pn.bind(get_plot, nlines=nlines, watch=True)
pn.Row(nlines, timeseries).servable()
Metadata
Metadata
Assignees
Labels
type: discussionRequiring community discussionRequiring community discussion