Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Dynamically change sorting in stacked bar chart

Hello there,

I am wondering what the best approach is for dynamically changing the order of bars in a stacked bar chart. Right now what I do is before passing any of the traces, I create a “dummy” trace with all the names of my bars as Y, and the X values all as NaN. This dummy trace is ordered in such a way that the bars are sorted with the longest total bar at the top, and then descending from there.
Here’s a visual:

As you can see, the bars are all ordered by total length of the stacked bar, which is great!
But I have a very big category “unregistered”, the black bar.
It is very likely that a user will want to hide specifically that category, and I know this can be done by clicking on it in the legend, but then the chart will look like this:

Now the ordering is all messed up. What I want is for the remaining bars to “reorder” themselves, so I once again go from largest to smallest.

Is there anyway this is possible?