Forum Discussion
sorting legend based on two criteria
Not possible in the standard visual. May not even be possible in Deneb unless dm-p has an idea.
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.
- lbendlin2 years agoSuper 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?
- dm-p2 years agoSuper User
Whatever the layer, if they share the same encoding channel, Vega will likely resolve them to the same scale (and sort). Your best bet would be to use a window transform to generate a numeric order based on grouping and sorting of multiple fields in the dataset and then sort on that.