Vega-Lite API Stack Sorting Struggle
This visualization shows suicide rates aggregated by year and age group, with bars stacked by age. The color legend uses a custom sort order, but the stacking order of the bars fails to match that order, highlighting a mismatch in the Vega-Lite API. The code uses `vl.aggregate` to sum suicides, `vl.markBar`, and encodes color and order with `fieldO('age')` and a custom `sort` array. Data comes from a CSV loaded via `d3.csv`, and the visualization is rendered using the Vega-Lite API with D3 v5.
AI-generated descriptionThis visualization demonstrates frustrations with the vega-lite-api in trying to get the sort order of stacking to match the sort order of the color scale. Notice that the ordering of the color legend is correct (a custom sort order), but the order of the layering does not match it.