Stack bar chart selection of Hbar segment in javascript callback

Is there a way to select a segment of the stacked bar and get the index of the bar and the segment name in a javascript callback?

I’m using standalone HTML file and hence python callbacks are not possible (I want to run in offline mode and bokeh server is an overkill so dont want to use that)

What does “segment name” refer to? Questions are always improved and focused if you provide a Minimal Reproducible Example, even if it is only the start of what you want.

I tried to illustrate what I’m trying to do here:

Before going further it’s probably worth mentioning that with vbar_stack it is not possible to select only a single bar in a stack. All the bars in a given stack are selected. That is because vbar_stack puts all the rows in the same ColumnDataSource and selecting one bar sets a selection index that applies to all the other bars in that column (so they will also be selected). [1] Do you need selection on individual bars in a stack? If so, the first thing to change is to use individual vbar calls for each row, each with a different data source (so that selections are not shared).

  1. ref for details: Expose options to suppress linked selection/inspection when data sources are shared · Issue #7644 · bokeh/bokeh · GitHub ↩︎

1 Like

I understand, Thanks for the response.
I’m now trying to find the segment by using cb_obj.x and cb_obj.y, requires a bit of calculation but I think I can make it work.