merIDK / Diagram types / Bar and line chart
Mermaid bar and line chart: example and syntax
The XY chart draws bar charts, line charts or both on one set of axes, straight from text. It suits metrics in a README or a report.
Open this example in the editor
Example code
xychart-beta
title "Monthly revenue"
x-axis [Jan, Feb, Mar, Apr, May, Jun]
y-axis "USD (k)" 0 --> 60
bar [22, 28, 35, 31, 44, 52]
line [20, 26, 33, 34, 42, 50]
Result
xychart-beta
title "Monthly revenue"
x-axis [Jan, Feb, Mar, Apr, May, Jun]
y-axis "USD (k)" 0 --> 60
bar [22, 28, 35, 31, 44, 52]
line [20, 26, 33, 34, 42, 50]Syntax quick reference
- Categories:
x-axis [Jan, Feb, Mar]. - Range:
y-axis "Label" 0 --> 100. - Series:
bar [..]andline [..]; you can use several of each. - Use
xychart-beta horizontalfor horizontal bars.
How to use it
- Open the example in the editor, or paste your own Mermaid code.
- Edit the code on the left. The preview updates as you type, and errors point to the line.
- Export SVG or PNG, copy a Markdown block for GitHub or Notion, or copy a share link.