Forum Discussion

mojganmeibodi19's avatar
mojganmeibodi19
Regular Visitor
2 years ago

sorting legend based on two criteria

I have a simple dataset that contains each supplier's sale in each year. I made a bar chart with years in the x axis and suppliers' sale on the y axis and used supplier company as legend.


I want to sort the legend (suppliers) in each bar (year) based on the total sales of that supplier in that specific year.
I can sort them by all-time total sales of suppliers, but I dont know how to do this sorting in each year.

6 Replies

  • josef78's avatar
    josef78
    Icon for Memorable Member rankMemorable Member

    Try Ribbon chart, and set transparency on connectors....

  • Not possible in the standard visual.  May not even be possible in Deneb unless dm-p has an idea.

    • dm-p's avatar
      dm-p
      Icon for Super User rankSuper User

      Vega and Vega-Lite don't have sorting capabilities for more than one field using standard language constructs, but you can use transforms and window functions to create fields that dictate a sort order that you can then sort by.

      • lbendlin's avatar
        lbendlin
        Icon for Super User rankSuper User

        Could you layer the individual columns as separate marks with their own sort order? Or would you have to know the number of columns/marks beforehand?