Vega-Lite API Stack Sorting Struggle
This visualization demonstrates a stacking order issue with the Vega-Lite API. It displays suicide rates by age group across years as stacked bar marks, where the color legend is correctly sorted by a custom age order, but the bar layering does not match that same sorted sequence. Using D3’s CSV loader for data ingestion, the code applies a viridis color scheme and attempts to set both color and order encodings with the same sort specification, revealing a mismatch in how Vega-Lite interprets these properties.
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.