XY Chart
What is an XY Chart?
Mermaid's An XY chart is a versatile data visualization tool used to represent data with two variables on x-axis and y-axis. It currently supports two main chart types:
Bar Chart: Displays data as rectangular bars.
Line Chart: Connects data points with a line.
The framework is flexible and expandable, allowing for the addition of new chart types in the future.
Creating Your First XY Chart
Steps:
Open the Code IDE and click Apps and Agents.
Select Mermaid. Paradime will automatically start a new Mermaid project.
In the terminal that appears, use the arrow keys to select XY Chart.
A new
xyChart.mmd
file will be created in your editor with this starter template:
Click the eye icon (👁️) in the top right corner of your Mermaid file to preview the chart.
Modify the
.mmd
file as needed; the preview updates automatically.
Syntax Guide
Title
The chart title is added using the title
keyword:
X-Axis
The x-axis can represent categories or a numerical range:
Categorical:
[cat1, cat2, ...]
Numerical:
"title" min --> max
Y-Axis
The y-axis represents numerical values only:
"title" min --> max
Chart Types
Bar Chart: Use
bar [data values]
.Line Chart: Use
line [data values]
.
Example:
Advanced Features
Orientation
Change the chart orientation to horizontal:
Configuration Options
Customize your chart using parameters like width, height, or axis labels:
Theming
Adjust chart colors and styles using themeVariables
:
Practical Example: Monthly Sales Revenue
Best Practices
Use descriptive titles for clarity.
Ensure axis ranges accommodate your data.
Choose appropriate chart types for data representation.
Use themes to make charts visually appealing.
Additional Resources
For more syntax options and advanced features, visit the official Mermaid documentation.
Last updated