Using Bokeh server (v.11), I currently have an app workflow that looks like this:
-
Plot all data points in a set (about 80 points total)
-
Filter that original data set with a Python callback along the lines of
plot_source.data = ColumnDataSource(new_source).data
, wherenew_source
is a Pandas data frame. This narrows the plot to about 4 points total. -
Select a point on the (filtered) plot.
-
Get a unique identifier for the selected point, along the lines of
unique_id = plot_source.data['unique_identifier'][plot_source.selected['1d']['indices'][0]]
-
Remove the filter, effectively reversing step 2.
-
Change plot_source.selected to reflect the new index the previously-extracted unique identifier:
plot_source.selected['1d']['indices'] = [plot_source.data['unique_identifier'].index(unique_id)]
All of this works fine on the python side - in my app (too complicated and dependent on internal resources to share here), I selected a point from the filtered set so that, say, plot_source.selected['1d']['indices'] == [3]
, and the workflow above determines that in the unfiltered set, that same unique identifier is places in the source so plot_source.selected['1d']['indices'] == [72]
. However, in the browser, that change doesn’t seem to take effect: while the python side shows the selected index is 72, the browser thinks it is still 3, which means un-filtering the data effectively changes which point is selected.
I see from examples on the site that, when doing a JavaScript callback, it’s necessary to call source.trigger('change')
for the changes to take effect. Is there something comparable that I need to do when running a Python callback?
I wanted to check quickly here, to see if this was simply a matter of my ignorance, before working up a toy example to illustrate the issue. Thank you in advance for any help you can offer.