I’m trying to make a graph where the axes can be changed through drop downs, just like what’s shown in the crossfilter example in the gallery, except not using the Bokeh server.
I’ve created something and I can’t figure out what I’m doing wrong. I’ve set the x value to be the value of a select widget, but when the value in the select widget is changed the graph doesn’t update, and I don’t understand why.
There’s a .js_on_change for the widget, and the graph correctly interprets the initial value set. Perhaps it’s something to do with the select widget referring to strings, not the values in the source (if so it’d be great to know how to change this).
Here’s my code simplified down which demonstrates the issue:
from bokeh.plotting import figure, show
from bokeh.models import CDSView, ColumnDataSource, CustomJS
from bokeh.models.widgets import Select
from bokeh.layouts import column, layout
data = dict(Apples=[97, 34, 23, 6, 26, 97, 21, 92, 73, 10, 92, 14, 77, 4, 25, 48, 26, 39, 93],
Bananas=[39, 28, 61, 43, 10, 95, 40, 73, 96, 85, 49, 14, 28, 90, 47, 59, 89, 64, 86],
Not_Cancelled=[87, 63, 56, 38, 57, 63, 73, 56, 30, 23, 66, 47, 76, 15, 80, 78, 69, 87, 28],
OnTime_Arrivals=[21, 65, 86, 39, 32, 62, 46, 51, 17, 79, 64, 43, 54, 50, 47, 63, 54, 84, 79])
source = ColumnDataSource(data=data)
Axesselect = Select(title=“Option:”, value=“Bananas”, options=[“Apples”, “Bananas”, “Not_Cancelled”, “OnTime_Arrivals”])
Axesselect.js_on_change(‘value’, CustomJS(args=dict(source=source), code=“”“source.change.emit()”“”))
view = CDSView(source=source)
p = figure()
p.circle(Axesselect.value,‘Not_Cancelled’, source=source, view=view, size=20)
controls = [Axesselect]
inputs = column(*controls, width = 300)
l = layout([[inputs, p]], sizing_mode=“stretch_both”)
show(l)
Could someone please point out what super basic thing I’m probably overlooking and doing wrong?
And thank you so much for all the help! Great to see such a supportive community for Bokeh. I’m having a great time building such cool stuff!