Skip to content

feat: add xyChart.stacked to stack bar series - #18

Open
snario wants to merge 2 commits into
wevm:mainfrom
snario:feat/xychart-stacked
Open

snario wants to merge 2 commits into
wevm:mainfrom
snario:feat/xychart-stacked

Conversation

@snario

@snario snario commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Multiple bar series in an XY chart render side by side. Parts of a whole, such as orders by channel, read better as one bar per category whose segments add up to the total.

This adds a stacked option under xyChart. With stacked: true, all bar series of a chart draw as one bar per category:

  • Direction: positive values stack above the baseline, and negative values stack below it.
  • Segments: a 1 px line of the background separates each segment from the one under it.
  • Range: without a y-axis range, the value axis fits the stack totals.
  • Labels: with showDataLabel, each stack shows its total, or both totals when it goes both ways.
  • Lines: line series draw over the stacks, unchanged.

The option is configuration only, so the parser and diagram model stay identical to Mermaid 12.1.0, which ignores the key. mermaid-js/mermaid#7509 proposes a brace syntax for stacking, but it is not merged, so this PR adds no syntax.

---
config:
  xyChart:
    stacked: true
    showDataLabel: true
---
xychart
  x-axis [Q1, Q2, Q3, Q4]
  bar "Online" [12, 15, 18, 22]
  bar "Store" [8, 7, 9, 10]
  bar "Partner" [3, 4, 6, 7]
Loading

The XY chart page documents the option, and a changeset marks it as a minor release.

Validation: cargo clippy, cargo test --workspace, pnpm check, pnpm check:types, vp test --project node (805 tests) and pnpm check:size pass. Every existing XY chart vector renders byte-identical SVG. The browser screenshot suite was not run.

@snario
snario force-pushed the feat/xychart-stacked branch from 36357d5 to 280c99b Compare November 9, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant