When I create a stacked bar chart (and, honestly, that is just about the only chart type I create), I want the ability to sort the series values automatically.
Today, I can navigate into the Series tab and manually reorder. But this becomes very annoying when there are a lot of values or when the series is constantly moving.
it would be great to be able to automatically sort the bars by the values of series in ascending or descending order. It could pick the first or last column as the bar from which to sort, and the remaining columns would follow that sort order. So in this case if I picked “Sort by rightmost column descending”, I would see the largest series at the bottom (681, green), followed by the next largest (682, purple), and so on.
You can use the Series tab of the Visualization Editor to control the order in which traces are stacked. You can also control it by adding an ORDER BY statement to your query. The stack follows the order in which your group names first appear in your query result.
In the following examples, notice that the same measures remain the same color but they stack in different orders.
I think what is being asked here is to sort the bars based on the value not based on the group.
The idea being that when you look at the stacked bar chart (or area chart) your larger values appear at the top and your smaller values appear at the bottom (or reverse of this).
For scenario X, red is always smaller than green which is always smaller than blue. For scenario Y, each color takes a turn being largest.
Projection A and Projection B both automatically stack colors from largest to smallest like you described. Projection C uses the same data as B but the stack order is manual/frozen: green, blue, red.
Automatic sorting makes sense in scenario X. But it’s unnecessary because the same outcome is possible with an ORDER BY statement.
In scenario Y, automatic sorting is harder to read than manual. Plotly doesn’t support it. Neither does Redash. Anecdotally, I don’t know a tool that does support it which is why I had to draw these illustrations by hand.
I read OP’s question as how to arrange the stack order without using the Series tab. The alternative is not desirable as far as I can tell.
Projection C is exactly what I would want.
In the consulting firm I used to work in, we worked with stacked bar charts extensively, and this question was “settled” with the answer being Projection C.
Most users are focused on the last column (most recent, if time is on the Y column), so, that should be the one to drive the sort order, and all columns to the left of it should follow behind.
Hi @jesse , I am not sure whether this’ been asked before or not. But I’m stuck on how to make a clustered stacked bar chart on Redash. The chart that I mean looks like in the below image (also in the image is the format of data on how to make clustered stacked bar chart on google sheets and ms. excel)