-
-
Notifications
You must be signed in to change notification settings - Fork 516
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
Adds the watch argument to pn.bind #2000
Conversation
Manual Test Is below I've tried the test without 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() |
Codecov Report
@@ Coverage Diff @@
## master #2000 +/- ##
==========================================
- Coverage 84.66% 84.51% -0.16%
==========================================
Files 163 175 +12
Lines 19729 20415 +686
==========================================
+ Hits 16704 17253 +549
- Misses 3025 3162 +137
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
Thanks. Great to get it in. Now I will start to learn to use it. I think that for many users explicitly declaring widgets and binding them to a function is easier to understand than parameterized classes, Param and annotations. Let me know if there is anything I should do. |
Whether the function will be automatically evaluated when one | ||
of the parameter dependencies change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether the function will be automatically evaluated when one | |
of the parameter dependencies change. | |
Whether to evaluate the function automatically whenever one of the | |
bound parameters changes. |
Whether the function will be automatically evaluated when one | ||
of the parameter dependencies change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether the function will be automatically evaluated when one | |
of the parameter dependencies change. | |
Whether to evaluate the function automatically whenever one of the | |
bound parameters changes. |
Fixes #1999