Re-position bar segments for stacked bar plot


I am working on a web application that produces horizontal stacked bar charts. I set the plot.legend.click_policy to hide, so that I can click the legend and see some categories of data toggle between hidden and visible. However, when I hide the data from one category, it just leaves blank space in the middle of the stacked bars. The behavior I am looking for is that it would re-position (or pack) all of the bars toward the vertical axis. Here is an example of what I am looking to do with bokeh:

If it makes a difference, the server-side of my app is using bokeh.embed.json_item to export the JSON data for the plot, and the client-side is using bokehjs to embed the JSON object.

I am using version 1.4.0. I just saw that 2.0.0 was released so I gave it a try, but it appears to have the same behavior as 1.4.0.

Thanks for any help or letting me know if this is even possible!

Currently the stack expression does not take glyph visibility into account. This is certainly a reasonable thing to consider have happen, but it would require new development. An appropriate first step would be for you to open a GitHub feature request issue describing what you want and providing a minimal script that you would like to have work with the new feature.

Thanks for the reply and letting me know. I have submitted a feature request for this. Here is the link in case anyone else wants to follow it: