I am working on making a multiselect tool where the user selects a range, and that range is fed to a pd sql query. Can anyone point me to an example to help or maybe have a look at the code below (its only a snippet of what I am trying to achieve.
the user selects a range, and that range is fed to a pd sql query.
Can you elaborate on what you want here? My guess is essentially you want the multiselect to allow the user to filter a dataset by multiple bin ranges?
Are you going the python–>bokeh server route or standalone–>CustomJS? Two drastically different options to implement depending on this…
Image shows what I have today. User selects a range. That range is fed to the sql_query:
db = _get_conn()
df1 = pd.read_sql_query(sql, db, params=[65, 75])
I have added it manually here [65, 75]. The second multichoice changes based on the range the user inputs. I researched some more and I assume I need to use the on_change(‘value’, function). Where function is the database change request?
Take the value selected by the user in the multiselect
Use that to run the pandas query, and
Then to use that query result to update the appropriate ColumnDataSource (aka the CDS that’s driving your graphs/whatever you have in bokeh.
And yes, apply that function to multiselect.on_change(‘value’,function). If you build up a dummy example here I can probably help further if you need it, but I think you’re on the right track.