Example
xychart-beta
title "Monthly Active Users"
x-axis [Jan, Feb, Mar, Apr, May, Jun]
y-axis "Users" 0 --> 5000
bar [120, 380, 820, 1540, 2900, 4600]
line [120, 380, 820, 1540, 2900, 4600] Syntax
Categorical x-axis
xychart-beta
title "Signups per month"
x-axis [Jan, Feb, Mar, Apr]
y-axis "Signups" 0 --> 400
bar [120, 180, 260, 350]
line [120, 180, 260, 350] Quote the title and the y-axis label. The y range is optional; Mermaid fits to the data when omitted.
Try this snippet →Numeric x-axis and orientation
xychart-beta horizontal
title "Latency by percentile"
x-axis "Percentile" 50 --> 99
y-axis "ms" 0 --> 800
line [120, 180, 260, 410, 790] horizontal after the keyword flips the axes. A numeric x-axis is written as min --> max.
Common mistakes
These are the parse errors that come up most, including in code written by ChatGPT and Claude. Paste any failing diagram into the editor and it marks the offending line.
-
Series length does not match the number of x categories.
Fix: Give every series exactly one value per category. Missing values are not interpolated.
-
Unquoted title with spaces.
Fix:
title "Signups per month". Single words parse unquoted; anything with spaces needs quotes. -
Writing
xychartwithout-beta.Fix: In Mermaid 11 the keyword is still
xychart-beta.
Real-world examples
Complete, copy-ready xy charts for common situations. Each one opens in the editor with a click.
Browse all examples →FAQ
Can I add a legend?
Not yet. Describe the series in the title or caption, or use distinct colours via theme variables.
How many series can I plot?
There is no fixed limit, but readability drops after three or four. Split into several charts if you need more.