Charted Data.

Command Palette

Search for a command to run...

11 min readCharted Data

Interactive Charts in MDX

Learn how to embed beautiful, interactive charts directly in your blog posts using the built-in chart components.

Quick Start#

To add a chart, use the corresponding chart component with your data. Each chart accepts data in a simple CSV-like format within the component tags.


Bar Charts#

Bar charts are great for comparing values across categories. They support multiple variations.

Basic Bar Chart#

The simplest bar chart with one data series showing monthly traffic:

Monthly Unique Visitors
Total unique visitors from Jan to Jun
JanuaryJune
<BarChart>
title: Monthly Unique Visitors
description: Total unique visitors from Jan to Jun
scrollable: true
month,visitors
January,18600
February,30500
March,23700
April,73000
May,20900
June,21400
</BarChart>
  • with two data series comparing platforms
Traffic by Platform
Comparison between Desktop and Mobile visitors
Data source: Google Analytics
<BarChart>
title: Traffic by Platform
description: Comparison between Desktop and Mobile visitors
footer: Data source: Google Analytics
month,desktop,mobile
January,186,80
February,305,200
March,237,120
April,73,190
May,209,130
June,214,140
</BarChart>

Stacked Bar Chart#

Use stacked: true to show the breakdown of acquisition channels:

Quarterly Acquisition Channels
Stacked breakdown of traffic sources
<BarChart>
title: Quarterly Acquisition Channels
description: Stacked breakdown of traffic sources
stacked: true
quarter,direct,search,social,referral
Q1,400,240,120,80
Q2,300,139,221,110
Q3,200,980,229,150
Q4,278,390,200,90
</BarChart>

Horizontal Bar Chart#

Use horizontal: true for horizontal bars - perfect for viewing top landing pages:

Top Landing Pages
Most visited pages by unique sessions
<BarChart>
title: Top Landing Pages
description: Most visited pages by unique sessions
horizontal: true
height: 250
page,sessions
Home,2840
Blog,2350
Pricing,1980
Features,1650
Docs,890
</BarChart>

Multiple Series Bar Chart#

Compare key performance indicators side by side:

Website Vital Stats
Monthly comparison of pageviews vs conversions
<BarChart>
title: Website Vital Stats
description: Monthly comparison of pageviews vs conversions
scrollable: true
month,pageViews,sessions,conversions
Jan,45000,12000,850
Feb,52000,14500,920
Mar,48000,13200,780
Apr,61000,16800,1100
May,55000,15200,980
Jun,67000,18500,1250
</BarChart>

Minimal Bar Chart#

Hide grid, axes, and legend for a clean look at daily active users:

Daily Active Users (DAU)
<BarChart>
title: Daily Active Users (DAU)
hideGrid: true
hideYAxis: true
hideLegend: true
height: 200
day,users
Mon,1200
Tue,1800
Wed,1500
Thu,2100
Fri,2800
Sat,3200
Sun,1900
</BarChart>

Line Charts#

Line charts are perfect for showing trends and changes over time.

Basic Line Chart#

Smooth Trend Line#

The growth trend of returning visitors over several months:

Returning Visitors Growth
Weekly growth of loyal user base
W1W8
<LineChart>
title: Returning Visitors Growth
description: Weekly growth of loyal user base
curved: true
showDots: true
scrollable: true
week,loyalUsers
W1,4000
W2,4500
W3,5200
W4,4800
W5,5800
W6,6200
W7,7100
W8,7800
</LineChart>

Multi-Line Comparison#

Compare multiple SEO or organic traffic sources:

Traffic Source Trends
Organic vs Paid vs Social growth
<LineChart>
title: Traffic Source Trends
description: Organic vs Paid vs Social growth
scrollable: true
month,organic,paid,social
Jan,4000,2400,1800
Feb,4500,2100,2200
Mar,5200,2800,1900
Apr,4800,3100,2500
May,5800,2900,3100
Jun,6200,3500,2800
</LineChart>

Linear Line Chart (No Curve)#

Use curved: false for strict metric tracking like Server Response Time (TTFB):

Server Response Time (TTFB)
Daily average latency in milliseconds
<LineChart>
title: Server Response Time (TTFB)
description: Daily average latency in milliseconds
curved: false
showDots: true
day,latency
Mon,142
Tue,145
Wed,138
Thu,148
Fri,151
</LineChart>

Line Chart Without Dots#

A minimal look at page load performance trends:

Average Page Load Time
End-to-end performance monitoring
<LineChart>
title: Average Page Load Time
description: End-to-end performance monitoring
curved: true
showDots: false
time,loadTime
00:00,450
04:00,320
08:00,780
12:00,850
16:00,720
20:00,580
24:00,410
</LineChart>

Area Charts#

Area charts emphasize the magnitude of change over time with filled regions.

Basic Area Chart with Gradient#

Visualize data usage or content delivery bandwidth:

CDN Bandwidth Usage
Daily data egress trend in Gigabytes
MonSat
<AreaChart>
title: CDN Bandwidth Usage
description: Daily data egress trend in Gigabytes
gradient: true
day,egress
Mon,18.6
Tue,30.5
Wed,23.7
Thu,27.3
Fri,32.9
Sat,41.4
</AreaChart>

Stacked Area Chart#

Show the cumulative breakdown of session durations:

Session Duration Breakdown
User stay time per visit category
<AreaChart>
title: Session Duration Breakdown
description: User stay time per visit category
stacked: true
gradient: true
scrollable: true
week,under_1m,one_to_five,five_plus
Week 1,4000,2400,800
Week 2,3000,1398,600
Week 3,2000,980,400
Week 4,2780,3908,1200
Week 5,1890,4800,1500
Week 6,2390,3800,1100
</AreaChart>

Flat Area Chart (No Gradient)#

Use gradient: false for technical monitoring like concurrent user density:

Concurrent Site Users
Real-time user density over 6 hours
<AreaChart>
title: Concurrent Site Users
description: Real-time user density over 6 hours
gradient: false
stacked: true
time,mobile_users,desktop_users
1h,240,120
2h,310,150
3h,280,180
4h,420,210
5h,350,190
6h,290,140
</AreaChart>

Pie Charts#

Pie charts show proportional data and part-to-whole relationships.

Standard Pie Chart#

Monitor the distribution of operating systems among your audience:

Operating System Share
Audience distribution by user OS
<PieChart>
title: Operating System Share
description: Audience distribution by user OS
outerRadius: 100
os,share
iOS,275
Windows,200
Android,187
macOS,173
Other,90
</PieChart>

Donut Chart#

Add innerRadius to visualize visitor loyalty levels:

Visitor Loyalty
Ratio of New vs. Returning users
<PieChart>
title: Visitor Loyalty
description: Ratio of New vs. Returning users
innerRadius: 60
outerRadius: 100
userType,count
New Users,4500
Returning,3200
Subscribers,2800
Loyalists,1200
Enterprise,800
</PieChart>

Pie Chart with Labels#

Visualize screen resolution categories for UI optimization:

Device Screen Categories
Popular resolutions for layout testing
<PieChart>
title: Device Screen Categories
description: Popular resolutions for layout testing
innerRadius: 50
outerRadius: 90
showLabels: true
resolution,count
Full HD,5840
Mobile High,4320
4K Ultra,1240
</PieChart>

Radar Charts#

Radar charts are useful for comparing multiple variables across categories.

SEO Health Check#

Compare holistic site health metrics:

SEO Health Audit
Performance vs Accessibility vs SEO scores
PerformancePWA
<RadarChart>
title: SEO Health Audit
description: Performance vs Accessibility vs SEO scores
height: 350
metric,this_month,last_month
Performance,120,110
Accessibility,98,130
SEO,86,130
Best Practices,99,100
Security,85,90
PWA,65,85
</RadarChart>

Competitor Performance Comparison#

Benchmark your site metrics against industry averages:

Site Performance Benchmark
Ratings across competing site architectures
<RadarChart>
title: Site Performance Benchmark
description: Ratings across competing site architectures
height: 400
metric,yourSite,average,topTier
First Contentful Paint,90,75,85
Speed Index,80,90,70
Time to Interactive,95,85,80
Cumulative Layout Shift,70,95,85
First Input Delay,85,80,90
Total Blocking Time,92,88,78
</RadarChart>

Radial Charts#

Radial bar charts display data as circular progress bars, excellent for showing progress against targets.

SEO Performance Goals#

Track progress towards multi-dimensional site optimization:

SEO Performance Scores
Current progress vs 100% target
<RadialChart>
title: SEO Performance Scores
description: Current progress vs 100% target
innerRadius: 40
outerRadius: 130
height: 300
metric,score
Technical SEO,50
Content,92
Keywords,58
Backlinks,35
</RadialChart>

Infrastructure Health#

Compact monitoring of global server uptime:

Global Service Uptime
<RadialChart>
title: Global Service Uptime
innerRadius: 30
outerRadius: 90
height: 250
hideLegend: true
US East,100
Europe,50
Asia Pacific,25
</RadialChart>

Radial Progress (Single Value)#

The ultimate clean visualization for a primary key performance indicator:

Cloud Storage Usage
Percentage of total capacity used
<RadialChart>
title: Cloud Storage Usage
description: Percentage of total capacity used
innerRadius: 70
outerRadius: 110
source,usage
Used Space,75
</RadialChart>

Composed Charts (Mixed Types)#

Combine different chart types in a single visualization for complex reporting.

Acquisition Efficiency#

Marketing Spend (Bars) vs New Customers (Line):

Acquisition Efficiency
Marketing Spend ($) vs. New Customer Count
JanJun
<ComposedChart>
title: Acquisition Efficiency
description: Marketing Spend ($) vs. New Customer Count
scrollable: true
month,spend(bar),customers(line),budget(line)
Jan,1200,850,1500
Feb,1800,920,1500
Mar,1500,780,1500
Apr,2100,1100,1500
May,2800,1400,1500
Jun,2400,1250,1500
</ComposedChart>

Engagement Depth Analysis#

Active Sessions (Area) vs returning users (Line):

Engagement Depth Analysis
Total Active Sessions (area) vs. Returning User Count (line)
<ComposedChart>
title: Engagement Depth Analysis
description: Total Active Sessions (area) vs. Returning User Count (line)
scrollable: true
week,sessions(area),returning(line)
W1,620,450
W2,750,420
W3,680,480
W4,890,520
W5,810,590
W6,940,630
</ComposedChart>

Triple Reporting Metrics#

Add to Cart (Area), Checkout (Bars), and Purchase (Line) Conversion Flow:

Checkout Funnel Trends
Add to Cart (area), Checkout Started (bars), and Completed Purchase (line)
<ComposedChart>
title: Checkout Funnel Trends
description: Add to Cart (area), Checkout Started (bars), and Completed Purchase (line)
scrollable: true
channel,cart(area),checkout(bar),purchase(line)
Direct,850,620,510
Search,1200,980,840
Social,780,540,420
Referral,690,480,390
Email,920,740,650
</ComposedChart>

Configuration Reference#

The declarative syntax makes it easy to create charts. Simply provide attributes at the top and CSV data below.

Syntax Rules#

  1. Attributes: Key-value pairs (e.g., title: My Chart)
  2. Data: CSV format with headers on the first line.
  3. X-Axis: The first column is used for the X-axis labels.
  4. Series: Subsequent columns are used as data series.
  5. Types: For ComposedChart, use header(type) syntax (e.g., sales(bar)).

Property Reference#

PropTypeDefaultDescription
titlestring-Chart title displayed above
descriptionstring-Subtitle/description text
footerstring-Footer text below chart
dataarrayrequiredArray of data objects
heightnumber300Chart height in pixels
classNamestring-Additional CSS classes
scrollablebooleanfalseEnable horizontal scrolling
hideXAxisbooleanfalseHide the X axis
hideYAxisbooleanfalseHide the Y axis
hideGridbooleanfalseHide background grid
hideLegendbooleanfalseHide the legend
hideTooltipbooleanfalseHide hover tooltips
colorsstring[]theme colorsCustom color palette

Series Configuration#

For BarChart, LineChart, AreaChart, RadarChart, and ComposedChart:

series={[
{
key: "fieldName", // Required: data field key
label: "Display Name", // Required: legend label
color: "#ff0000", // Optional: custom color
type: "bar", // ComposedChart only: "bar" | "line" | "area"
stackId: "group1", // Optional: for stacking
radius: 4 // BarChart only: corner radius
}
]}

Error Handling#

Charts automatically validate data and display helpful error messages. For example, an empty data array:

Chart Error

Data array is empty

Missing data keys also trigger informative errors:

Chart Error

Data array is empty


Best Practices#

Keep data simple: Charts work best with 5-10 data points. Too many points make the chart hard to read.

Responsive design: All charts automatically resize on mobile devices. Set appropriate height values for smaller screens.

Performance: Very large datasets (100+ points) may impact page performance. Consider aggregating data before visualization.

Accessibility: Charts include proper ARIA labels and keyboard navigation support for screen readers.

Color contrast: When customizing colors, ensure sufficient contrast for colorblind users. Avoid using only red/green combinations.

Download This Boilerplate ⚡