Chart Types
data-chart supports 6 chart types, all set via the data-chart attribute.
Bar (Vertical)
The default chart type. Grouped vertical bars for comparing categories.
| Quarter | Revenue | Profit |
|---|---|---|
| Q1 | 420 | 180 |
| Q2 | 580 | 240 |
| Q3 | 510 | 210 |
| Q4 | 690 | 310 |
Multiple series (multiple <th> columns after the first) are automatically grouped side by side.
Bar (Horizontal)
Add data-chart-horizontal for horizontal bars. Best for rankings.
| Language | Users |
|---|---|
| TypeScript | 850 |
| Python | 720 |
| Go | 510 |
| Rust | 340 |
Bar (Stacked)
Add data-chart-stacked to stack series on top of each other.
| Q | Desktop | Mobile | Tablet |
|---|---|---|---|
| Q1 | 300 | 200 | 50 |
| Q2 | 280 | 250 | 60 |
| Q3 | 260 | 300 | 70 |
| Q4 | 320 | 350 | 80 |
Line
Connected data points showing trends over time.
| Month | Users | Active |
|---|---|---|
| Jan | 1200 | 900 |
| Feb | 1800 | 1400 |
| Mar | 1500 | 1100 |
| Apr | 2200 | 1800 |
| May | 2800 | 2200 |
Line charts support multiple series. Each series gets its own colored line and dots.
Area
Same as line, with a filled area beneath the line for volume emphasis.
| Week | Visitors |
|---|---|
| W1 | 3200 |
| W2 | 4100 |
| W3 | 3800 |
| W4 | 5200 |
| W5 | 4800 |
| W6 | 5900 |
The area fill uses 15% opacity of the series color.
Pie
Proportional slices showing composition. Uses the first data column only.
| Language | Share |
|---|---|
| TypeScript | 38 |
| Python | 28 |
| Go | 18 |
| Rust | 16 |
A legend with percentages is automatically generated below the pie.
Donut
Same as pie, with a hollow center displaying the total value.
| Category | Budget |
|---|---|
| Engineering | 45 |
| Marketing | 25 |
| Sales | 20 |
| Support | 10 |
Table Parsing Rules
| Input | Parsed As |
|---|---|
"123" | 123 |
"1,234" | 1234 (commas removed) |
"85%" | 85 (% removed) |
"$3.50" | 3.5 (currency symbol removed) |
"¥1,200" | 1200 |
"" (empty) | 0 |
"N/A" | 0 |
"-42" | -42 |
The first <th> column is always treated as category labels (X-axis). Subsequent columns are data series.