How to set custom sort order for stacked barchart #2441
Answered
by
mbostock
quillcraft
asked this question in
Q&A
-
|
Manual tells me that I can set custom sort order for stacked bars, but I have an error: TypeError: f?.startsWith is not a function How to fix it: https://observablehq.com/@mizinov/qa-stacked-bars-with-sorting |
Beta Was this translation helpful? Give feedback.
Answered by
mbostock
Jun 24, 2026
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
quillcraft
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

If you have an explicit order, you set the domain of the y-scale.
The sort option is for when you need to derive the domain from data. If you’ve already derived the domain yourself, you just set it directly.
If you wanted to derive the order inline, in this case you could use the data as the input channel to the sort option like so: