I have a Bokeh plot with 3 sliders. I am able to change the sliders value and modify my plot. The problem is with the “value” of sliders. Two of the slider’s values are dependent on each other and by changing one the other one does not change or update. And there is no way to pass the source to slider to update its value. To clarify better, assume we have a line going from (x = 0, y = 10) to (x = 10, y = 10) and the second line going from (x = 10, y = 10) to (x = 20, y = 5), and the third line goes from (x = 20, y = 5) to (x = 30, y = 5). My second slider change the length of second piece, and the third slider change the length of third piece. changing slider values will change the lines in such away I would like but does not change the value of the other slider correctly. Find below a section of my code for sliders. Thanks a lot for your valuable product.
sourceupper = ColumnDataSource(data=dict(x=xsource, y=ysourceupper))
p.line(‘x’, ‘y’, source = sourceupper, line_color = “navy”, line_width = 4)
callback1 = CustomJS(args=dict(source=sourceupper), code="""
var data = source.get(‘data’);
var f = cb_obj.get(‘value’);
x = data[‘x’];
y = data[‘y’];
y[0] = f *10;
y[1] = f *10;
source.trigger(‘change’);
“”")
callback2 = CustomJS(args=dict(source=sourceupper), code="""
var data = source.get(‘data’);
var f = cb_obj.get(‘value’);
x = data[‘x’];
y = data[‘y’];
x[1] = f
source.trigger(‘change’);
“”")
callback3 = CustomJS(args=dict(source=sourceupper), code="""
var data = source.get(‘data’);
var f = cb_obj.get(‘value’);
x = data[‘x’];
y = data[‘y’];
x[2] = parseInt(f) + 10
console.log(x[2])
source.trigger(‘change’);
“”")
p.background_fill= “#cccccc”
p.grid.grid_line_color=“white”
slider1 = Slider(start=0, end = 100, value = ysourceupper[1] / bthrs, step = 0.5, title = “Magnitude”, callback = callback1)
slider2 = Slider(start=0, end = tend * 60, value = xsource[1] , step = 0.5, title = “Hold Time (secs)”, callback = callback2)
slider3 = Slider(start=0, end = tend * 60, value = xsource[2] - sol[0], step = 1, title = “Decay Time (secs)”, callback = callback3)