Search code examples
apache-superset

How to customize the order of bars in a Superset Chart


In Apache Superset I want to create a Bar Chart - just like the 'Vaccine Candidates per Phase' from the 'COVID Vaccine Dashboard'.

Goal: We want to customize the order of the bars without adding '0', '1' to the labels to then order it alphabetically, as it was done in this graph.

Vaccine Candidates per Phase

Here it seems the order of the bars is according to the 'count' variable.

How can we customize the order of the bars? How can we specify in which order they should appear (without relying on alphabetical ordering)?


Solution

  • I would love to be wrong, but I believe this is a missing feature currently (as of Superset 2.0.0). I've been unable to get that sorting working with the Bar Chart v2 Chart Type.

    Here's a GitHub issue for this same problem and a reply from a top Superset contributor saying that actually, it would be a feature request, not a bug report. Here's a feature request for implementing this behavior on the Bar Chart v2 chart type if you want to upvote or comment.

    I'm newer to Superset but from what I can tell, sorting order control worked on the older bar chart types. For instance, it looks like this was closed as implemented on the Time Series Bar Chart type. But it's not yet implemented for the newest EChart-powered Bar Chart v2.

    For what it's worth, I've also been unable to control the order of stacked bars on a Mixed Chart - I suspect it's the same root cause.