All diagram types Open editor

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

How to use it

  1. Open the example in the editor, or paste your own Mermaid code.
  2. Edit the code on the left. The preview updates as you type, and errors point to the line.
  3. Export SVG or PNG, copy a Markdown block for GitHub or Notion, or copy a share link.

More diagram types