Simplest MRE:
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.io import curdoc # maybe i need this?
src = ColumnDataSource(data={'x':[1,2,3],'y':[1,2,3]})
f=figure()
r1 = f.scatter(x='x',y='y',source=src)
r2 = f.line(x='x',y='y',source=src)
Here I have 2 renderers being driven by the same CDS. I’m wondering if there’s a way to retrieve these renderers from the CDS on the python side. In my far more involved use case, the CDS (actually multiple CDS’s) are being held in a class instance, but I’m trying to keep the renderers “free” from my class and instead be up to the user. However if I want to add a filter… I need to instantiate a CDSView and add that view to all renderers that are being driven by each CDS.
So my hope is something like:
# where self already has a "source_dict" that contains a bunch of CDS models
def addFilter(self,filter_specs):
fi = filter_specs #...make the filter based on args provided
view = CDSView(filters=[fi])
for src in source_dict.values():
rends = ???? #... magically find all the renderers currently instantiated by user that are being driven by src
for r in rends:
rends.view=view
Thanks…