How To Update A Source In A Javascript Callback Of Bokeh In Python?
I am adapting this answer for my case, where I want an interactive, standalone graph where the slider selects which column of the data to plot in a bar chart. (Standalone is crucia
Solution 1:
The issue is in the CustomJS code as you suspected. There are two things that need to be fixed.
Bokeh has deprecated
get()andset()methods and replaced them bygetv()orsetv(). However, the preferred way of accessing or modifying model properties is through usual JavaScript attributes, e.g.,source_visible.data.Bokeh has deprecated
trigger('change')and replaced it bychange.emit().
The fixed CustomJS code:
slider.callback = CustomJS(
args=dict(source_visible=source_visible,
source_available=source_available), code="""
var selected_function = cb_obj.value.toString();
// Get the data from the data sources
var data_visible = source_visible.data;
var data_available = source_available.data;
// Change bar height to the selected value
data_visible.top = data_available[selected_function];
// Update the plot
source_visible.change.emit();
""")
JavaScript errors and warnings are seen in the browser's console. Here are instructions for opening the console in different browsers.
Post a Comment for "How To Update A Source In A Javascript Callback Of Bokeh In Python?"