Is it possible to use ColumnDataSource with interactive (sliced) legends

I have an app using Bokeh server and Flask server. Yet, my question relates to the basic Legend functionality.

On the one hand, I wish to use CoulmnDataSource to plot my data- easy, fast etc. Easy also to handle selection and plot data updates. Assume one of the columns in the CDS is holding the label (category) of the row.
Yet, when it comes to supporting a legend, the drawing functions (such as .circle) allow me either to add a fixed legend_label value, or else to use the legend_group. The latter, the legend_group feature is cool but it would not then support a Hide/Show/Mute per category- i.e. the whole legend (one group) get to hide/show at once- while the desired functionality is to have the Hide/Show support on a category-base level.

I know that I can move the data to pandas DataFrame and then draw each subset of the data separately (using its own legend_label) but then I’d loose the whole other benefits of the CDS.

Does anyone know if what I looking for is achiveable somehow? If not, I’d recon this could be really a very useful add on to the CDS support on Bokeh (to allow to slice it for the drawing and to automatically create the legend entries, similar in a way to the support for the color feature).

Many thanks in adance

Please see this recent discussion, which more or less also applies as-is to legend_group.

Thank you Bryan.
I looked at the other thread. While setting the alpha (toggling it between 0 and 1) could produce similar effect on the plot, I am not sure it would not have side effects. For example, I think that the selection would still return also data points with alpha=0.
I am totally clear with the complexity of the implementation of the support for the ON/OFF and yet, Bokeh could indeed internally support such a feature by emulating the alpha 0/1 effect in its display and selection operations.
Apparently, there is indeed a need for such a feature - i.e. to support independent legend selectable entries even when one glyph is used- and for example, when the ColumnDataSource is used for the plot. To require the user to split the drawing to multiple glyphs (for example using seperate drawing for each DataFrame) just preents the usage of the ColumnDataSource because of this missing feature- which seems pity.

Glad to see I am not alone into this…

Unfortunately, it’s a very big change to some fundamental low-level parts of BokehJS, I can’t speculate at all when/if it might happen.

OK. Got it, Thanks alot

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.