Chart.js
Chart.js is a simple yet flexible JavaScript charting library that produces clean, responsive charts with smooth animations. Moraya’s Chart.js plugin lets you embed charts in your Markdown by writing a standard Chart.js configuration object inside a fenced code block.
Syntax
Use the chartjs or chart language tag on a fenced code block. The content is a JSON object with type, data, and optional options fields, matching the Chart.js configuration schema.
```chartjs
{
"type": "bar",
"data": {
"labels": ["A", "B", "C"],
"datasets": [{ "label": "Values", "data": [10, 20, 30] }]
}
}
```
Both chartjs and chart language tags are supported and produce identical results.
Examples
Bar Chart
A vertical bar chart showing monthly user signups.
```chartjs
{
"type": "bar",
"data": {
"labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
"datasets": [
{
"label": "New Signups",
"data": [1240, 1580, 1920, 1750, 2100, 2380],
"backgroundColor": [
"rgba(54, 162, 235, 0.7)",
"rgba(54, 162, 235, 0.7)",
"rgba(54, 162, 235, 0.7)",
"rgba(54, 162, 235, 0.7)",
"rgba(54, 162, 235, 0.7)",
"rgba(54, 162, 235, 0.7)"
],
"borderColor": "rgba(54, 162, 235, 1)",
"borderWidth": 1
}
]
},
"options": {
"plugins": {
"title": { "display": true, "text": "Monthly User Signups" }
},
"scales": {
"y": { "beginAtZero": true }
}
}
}
```
Horizontal Bar Chart
A horizontal bar chart comparing programming language popularity.
```chart
{
"type": "bar",
"data": {
"labels": ["Python", "JavaScript", "TypeScript", "Java", "Go", "Rust"],
"datasets": [
{
"label": "Developer Survey (%)",
"data": [48, 42, 35, 30, 18, 12],
"backgroundColor": [
"#3776ab",
"#f7df1e",
"#3178c6",
"#ed8b00",
"#00add8",
"#ce422b"
]
}
]
},
"options": {
"indexAxis": "y",
"plugins": {
"title": { "display": true, "text": "Most Used Languages (2025)" },
"legend": { "display": false }
},
"scales": {
"x": { "beginAtZero": true, "max": 60 }
}
}
}
```
Line Chart
A line chart tracking server response times over 24 hours.
```chartjs
{
"type": "line",
"data": {
"labels": ["00:00", "03:00", "06:00", "09:00", "12:00", "15:00", "18:00", "21:00"],
"datasets": [
{
"label": "Response Time (ms)",
"data": [45, 38, 42, 120, 185, 165, 140, 72],
"borderColor": "rgb(75, 192, 192)",
"backgroundColor": "rgba(75, 192, 192, 0.1)",
"fill": true,
"tension": 0.3
}
]
},
"options": {
"plugins": {
"title": { "display": true, "text": "API Response Time (24h)" }
},
"scales": {
"y": { "beginAtZero": true, "title": { "display": true, "text": "ms" } }
}
}
}
```
Pie Chart
A pie chart showing project time allocation.
```chartjs
{
"type": "pie",
"data": {
"labels": ["Development", "Testing", "Design", "Meetings", "Documentation"],
"datasets": [
{
"data": [40, 20, 15, 15, 10],
"backgroundColor": [
"#36a2eb",
"#ff6384",
"#ffce56",
"#4bc0c0",
"#9966ff"
]
}
]
},
"options": {
"plugins": {
"title": { "display": true, "text": "Sprint Time Allocation" },
"legend": { "position": "right" }
}
}
}
```
Doughnut Chart
A doughnut chart showing cloud infrastructure cost breakdown.
```chartjs
{
"type": "doughnut",
"data": {
"labels": ["Compute", "Storage", "Database", "Network", "Other"],
"datasets": [
{
"data": [3200, 1800, 2400, 950, 650],
"backgroundColor": [
"#ff6384",
"#36a2eb",
"#ffce56",
"#4bc0c0",
"#c9cbcf"
],
"borderWidth": 2
}
]
},
"options": {
"plugins": {
"title": { "display": true, "text": "Monthly Cloud Costs ($)" },
"legend": { "position": "bottom" }
},
"cutout": "55%"
}
}
```
Radar Chart
A radar chart comparing two frontend frameworks across several criteria.
```chartjs
{
"type": "radar",
"data": {
"labels": ["Performance", "Ecosystem", "Learning Curve", "Bundle Size", "TypeScript", "Community"],
"datasets": [
{
"label": "Svelte",
"data": [95, 65, 90, 95, 85, 70],
"borderColor": "#ff3e00",
"backgroundColor": "rgba(255, 62, 0, 0.15)"
},
{
"label": "React",
"data": [75, 98, 60, 55, 80, 98],
"borderColor": "#61dafb",
"backgroundColor": "rgba(97, 218, 251, 0.15)"
}
]
},
"options": {
"plugins": {
"title": { "display": true, "text": "Framework Comparison" }
},
"scales": {
"r": { "beginAtZero": true, "max": 100 }
}
}
}
```
Polar Area Chart
A polar area chart showing content type distribution across a blog.
```chartjs
{
"type": "polarArea",
"data": {
"labels": ["Tutorials", "Case Studies", "News", "Opinion", "Reviews"],
"datasets": [
{
"data": [35, 22, 18, 14, 11],
"backgroundColor": [
"rgba(255, 99, 132, 0.6)",
"rgba(54, 162, 235, 0.6)",
"rgba(255, 206, 86, 0.6)",
"rgba(75, 192, 192, 0.6)",
"rgba(153, 102, 255, 0.6)"
]
}
]
},
"options": {
"plugins": {
"title": { "display": true, "text": "Blog Posts by Category" },
"legend": { "position": "right" }
}
}
}
```
Bubble Chart
A bubble chart showing product comparison by price, rating, and market share.
```chartjs
{
"type": "bubble",
"data": {
"datasets": [
{
"label": "Product A",
"data": [{ "x": 29, "y": 4.5, "r": 18 }],
"backgroundColor": "rgba(255, 99, 132, 0.6)"
},
{
"label": "Product B",
"data": [{ "x": 49, "y": 4.2, "r": 25 }],
"backgroundColor": "rgba(54, 162, 235, 0.6)"
},
{
"label": "Product C",
"data": [{ "x": 79, "y": 4.8, "r": 12 }],
"backgroundColor": "rgba(255, 206, 86, 0.6)"
},
{
"label": "Product D",
"data": [{ "x": 39, "y": 3.9, "r": 30 }],
"backgroundColor": "rgba(75, 192, 192, 0.6)"
},
{
"label": "Product E",
"data": [{ "x": 99, "y": 4.6, "r": 8 }],
"backgroundColor": "rgba(153, 102, 255, 0.6)"
}
]
},
"options": {
"plugins": {
"title": { "display": true, "text": "Products: Price vs Rating (bubble = market share)" }
},
"scales": {
"x": { "title": { "display": true, "text": "Price ($)" } },
"y": { "title": { "display": true, "text": "Rating" }, "min": 3, "max": 5 }
}
}
}
```
Multi-Dataset Line Chart
A multi-line chart comparing revenue trends across three regions.
```chartjs
{
"type": "line",
"data": {
"labels": ["Q1 '24", "Q2 '24", "Q3 '24", "Q4 '24", "Q1 '25", "Q2 '25"],
"datasets": [
{
"label": "North America",
"data": [420, 460, 510, 480, 530, 580],
"borderColor": "#36a2eb",
"tension": 0.2
},
{
"label": "Europe",
"data": [310, 340, 355, 370, 395, 420],
"borderColor": "#ff6384",
"tension": 0.2
},
{
"label": "Asia Pacific",
"data": [180, 220, 275, 320, 380, 450],
"borderColor": "#ffce56",
"tension": 0.2
}
]
},
"options": {
"plugins": {
"title": { "display": true, "text": "Regional Revenue ($k)" }
},
"scales": {
"y": { "beginAtZero": false, "title": { "display": true, "text": "$k" } }
}
}
}
```