Advertisement
❮ Previous: Mermaid Pie Charts Next: Mermaid Requirement Diagrams ❯

Mermaid XY Charts

Mermaid XY Charts (xychart-beta) are used to create clean, text-based line and bar charts. They are ideal for tracking metrics, financial performance, and technical data over time.

Example

xychart-beta
    title "Chart Title"
    x-axis [A, B, C, D]
    y-axis "Value" 0 --> 100
    bar [20, 40, 60, 80]

Structural Configuration & Core Settings

An XY chart initializes with the xychart-beta keyword. You must explicitly configure both the horizontal (X-axis) and vertical (Y-axis) parameters before inputting data series.

Example

xychart-beta
    title "Monthly Sales"
    x-axis [Jan, Feb, Mar, Apr, May]
    y-axis "Sales" 0 --> 100
    bar [30, 45, 60, 50, 75]

Rendering Data Series (Bar vs. Line)

You can choose to render your data series as solid blocks or as points connected by line intervals. You can also stack multiple charts in the same viewport.

Bar Chart

xychart-beta
    title "Monthly Sales"
    x-axis ["Jan", "Feb", "Mar"]
    y-axis "Sales" 0 --> 100
    bar [30, 50, 75]

Line Chart

xychart-beta
    title "Monthly Users"
    x-axis ["Jan", "Feb", "Mar"]
    y-axis "Users" 0 --> 100
    line [30, 45, 70]

Important Layout Constraints


More Examples

Bar + Line

xychart-beta
    title "Sales Performance"
    x-axis [Q1, Q2, Q3, Q4]
    y-axis "Revenue" 0 --> 100
    bar [40, 60, 55, 80]
    line [35, 55, 65, 75]

Numeric X-Axis

xychart-beta
    title "Temperature"
    x-axis "Day" 1 --> 7
    y-axis "Temperature (°C)" 0 --> 40
    line [25, 27, 29, 31, 30, 28, 26]
❮ Previous: Mermaid Pie Charts Next: Mermaid Requirement Diagrams ❯
Advertisement