Hello,
Using the server, I try to add new lines to a figure when pressing one of the two buttons (top button: one new line at a time, below: three new lines at a time).
I have a hard time to make it work properly: the top button works from time to time (never the 2nd time), and seems to depend on the time I am waiting between two clicks. When the interval is too short, it bugs quickly, nothing happens anymore.
The button below is behaving even worse, never get the three new lines.
Moreover, the printed columndatasource seems to loose columns. With larger arrays, lines start flickering.
What is the proper way to use bokeh for dynamic addition of new lines ?
Is there some timeout to respect between operations linking the server and the client ?
from bokeh.plotting import figure
from bokeh.io import curdoc,output_file, show
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import Button
from bokeh.layouts import column
def b_cb():
global i
i+=1
s = c.add([el+i for el in y])
p.line(x=‘x’,y=s, source=c)
print(c.column_names)
def b2_cb():
global i
i+=3
for j in range(3):
s = c.add([el+i+j for el in y])
p.line(x=‘x’,y=s, source=c)
print(c.column_names)
b=Button()
b.on_click(b_cb)
b2=Button()
b2.on_click(b2_cb)
x=[-10,10,20];y=[-2,2,5]
i=0
c=ColumnDataSource(dict(x=x,y=y))
p = figure(plot_width=400, plot_height=400)
curdoc().add_root(column(b,b2,p))