Skip to content

feat: add xyChart.rightAxis for a second value axis - #19

Merged
jxom merged 3 commits into
wevm:mainfrom
snario:feat/xychart-right-axis
Nov 10, 2026
Merged

jxom merged 3 commits into
wevm:mainfrom
snario:feat/xychart-right-axis

Conversation

@snario

@snario snario commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Builds on #18 and includes its commit. The new commit is the last one.

Some charts put two quantities with different units or magnitudes on one chart, such as revenue and margin. On one value axis, the smaller series flattens near zero.

This adds a rightAxis option under xyChart. Series named in rightAxis.series are measured against a second value axis:

  • Placement: the axis is drawn on the right of the plot, or along the top when the chart runs horizontal.
  • Range: min and max set the range. Without them, the axis fits its series, and bars stand on zero.
  • Title: title sets the axis title. showTitle, showLabel, showTick, and showAxisLine work as on the other axes.
  • Stacking: with stacked: true, bars of each axis form their own stack, and the two stacks stand side by side.

The option is configuration only, so the parser and diagram model stay identical to Mermaid 12.1.0, which ignores the key.

---
config:
  xyChart:
    rightAxis:
      series: [Margin]
      title: "Margin (%)"
      min: 0
      max: 50
---
xychart
  x-axis [Q1, Q2, Q3, Q4]
  y-axis "Revenue ($M)"
  bar "Revenue" [120, 180, 240, 310]
  line "Margin" [12, 18, 22, 29]
Loading

Validation: cargo clippy, cargo test --workspace, pnpm check, pnpm check:types, vp test --project node (806 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-right-axis branch from a0bd07a to f107ee7 Compare November 9, 2026 23:18
@jxom
jxom merged commit 4e9b527 into wevm:main Nov 10, 2026
2 checks passed
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.

2 participants