Charts
Bar, line, area and donut charts — from a plain table you already have. Point at any part (or tap it, or use the arrow keys) to read the values; the legend hides and shows series; one switch turns the chart back into its table. Colors are checked for color-blind readers, in light and dark.
| Month | Online | In store |
|---|---|---|
| Jan | 4200 | 3100 |
| Feb | 4800 | 2900 |
| Mar | 5100 | 3400 |
| Apr | 5900 | 3600 |
| May | 6300 | 3300 |
| Jun | 7100 | 3900 |
<figure class="chart" data-moey-chart="bar" data-moey-format="currency:USD">
<figcaption>Revenue by month<small>Online and in store, first half of 2026</small></figcaption>
<table>
<thead>
<tr><th>Month</th><th>Online</th><th>In store</th></tr>
</thead>
<tbody>
<tr><td>Jan</td><td>4200</td><td>3100</td></tr>
<tr><td>Feb</td><td>4800</td><td>2900</td></tr>
<tr><td>Mar</td><td>5100</td><td>3400</td></tr>
<tr><td>Apr</td><td>5900</td><td>3600</td></tr>
<tr><td>May</td><td>6300</td><td>3300</td></tr>
<tr><td>Jun</td><td>7100</td><td>3900</td></tr>
</tbody>
</table>
</figure>
The first column is the labels; every other column is a series. Numbers may carry symbols and separators ($4,200) — or put the exact value in data-value and write the cell any way you like. The table stays in the page for screen readers, and for everyone behind the Table switch.
Line
For change over time. Hovering shows every series at that point, so nobody has to aim at a 2px line.
| Month | Search | Direct | Social |
|---|---|---|---|
| Jan | 820 | 410 | 120 |
| Feb | 910 | 460 | 150 |
| Mar | 880 | 520 | 170 |
| Apr | 1040 | 560 | 210 |
| May | 1210 | 610 | 260 |
| Jun | 1180 | 700 | 300 |
| Jul | 1320 | 690 | 330 |
| Aug | 1460 | 760 | 390 |
| Sep | 1390 | 820 | 420 |
| Oct | 1580 | 860 | 480 |
| Nov | 1720 | 910 | 510 |
| Dec | 1850 | 990 | 560 |
<figure class="chart" data-moey-chart="line" data-moey-format="compact">
<figcaption>Visitors per month</figcaption>
<table>
<thead>
<tr><th>Month</th><th>Search</th><th>Direct</th><th>Social</th></tr>
</thead>
<tbody>
<tr><td>Jan</td><td>820</td><td>410</td><td>120</td></tr>
<tr><td>Feb</td><td>910</td><td>460</td><td>150</td></tr>
…
</tbody>
</table>
</figure>
Area
A line with a soft fill — for one total. Add data-moey-stacked for parts that add up.
| Day | Sign-ups |
|---|---|
| Nov 10 | 32 |
| Nov 11 | 41 |
| Nov 12 | 38 |
| Nov 13 | 55 |
| Nov 14 | 61 |
| Nov 15 | 58 |
| Nov 16 | 72 |
| Nov 17 | 80 |
| Nov 18 | 77 |
| Nov 19 | 91 |
| Nov 20 | 104 |
| Nov 21 | 118 |
| Nov 22 | 112 |
| Nov 23 | 126 |
<figure class="chart" data-moey-chart="area">
<figcaption>Sign-ups</figcaption>
<table>
<thead>
<tr><th>Day</th><th>Sign-ups</th></tr>
</thead>
<tbody>
<tr><td>Nov 10</td><td>32</td></tr>
<tr><td>Nov 11</td><td>41</td></tr>
…
</tbody>
</table>
</figure>
Stacked bars
Parts of a whole, per category. The tooltip adds the total.
| Day | Solved | Waiting | Escalated |
|---|---|---|---|
| Mon | 18 | 9 | 4 |
| Tue | 22 | 7 | 6 |
| Wed | 15 | 12 | 3 |
| Thu | 26 | 8 | 5 |
| Fri | 20 | 10 | 7 |
<figure class="chart" data-moey-chart="bar" data-moey-stacked>
<figcaption>Support tickets this week</figcaption>
<table>
<thead>
<tr><th>Day</th><th>Solved</th><th>Waiting</th><th>Escalated</th></tr>
</thead>
<tbody>
<tr><td>Mon</td><td>18</td><td>9</td><td>4</td></tr>
<tr><td>Tue</td><td>22</td><td>7</td><td>6</td></tr>
…
</tbody>
</table>
</figure>
Horizontal bars
For rankings and long names. data-moey-labels prints each value at the tip of its bar.
| Product | Units |
|---|---|
| Linen shirt | 1284 |
| Canvas tote | 1102 |
| Wool beanie | 860 |
| Leather wallet | 642 |
| Cotton socks (3 pairs) | 517 |
<figure class="chart" data-moey-chart="bar" data-moey-horizontal data-moey-labels>
<figcaption>Best sellers</figcaption>
<table>
<thead>
<tr><th>Product</th><th>Units</th></tr>
</thead>
<tbody>
<tr><td>Linen shirt</td><td>1284</td></tr>
<tr><td>Canvas tote</td><td>1102</td></tr>
…
</tbody>
</table>
</figure>
Donut
Shares of one total — best with a few parts. The middle shows the total, or the part you point at. Give a part its own color with <tr data-color="…">.
| Source | Visits |
|---|---|
| Search | 4820 |
| Direct | 2310 |
| Social | 1460 |
| 980 | |
| Referral | 410 |
<figure class="chart" data-moey-chart="donut" data-moey-center="Visits">
<figcaption>Where visitors came from</figcaption>
<table>
<thead>
<tr><th>Source</th><th>Visits</th></tr>
</thead>
<tbody>
<tr><td>Search</td><td>4820</td></tr>
<tr><td>Direct</td><td>2310</td></tr>
…
</tbody>
</table>
</figure>
Sparklines
A tiny trend for stat tiles: data-moey-spark with the numbers. It takes the text color — or a theme-* color.
<span class="chart-spark" data-moey-spark="31,34,33,38,41,40,45,48"></span>
<span class="chart-spark theme-red" data-moey-spark="9,12,8,14,11,17,19,23"></span>
In a card
Charts fit any container and redraw when it changes size — on a phone, in a grid, in a sidebar.
| Month | Search | Direct | Social |
|---|---|---|---|
| Jan | 820 | 410 | 120 |
| Feb | 910 | 460 | 150 |
| Mar | 880 | 520 | 170 |
| Apr | 1040 | 560 | 210 |
| May | 1210 | 610 | 260 |
| Jun | 1180 | 700 | 300 |
| Jul | 1320 | 690 | 330 |
| Aug | 1460 | 760 | 390 |
| Sep | 1390 | 820 | 420 |
| Oct | 1580 | 860 | 480 |
| Nov | 1720 | 910 | 510 |
| Dec | 1850 | 990 | 560 |
| Source | Visits |
|---|---|
| Search | 4820 |
| Direct | 2310 |
| Social | 1460 |
| 980 | |
| Referral | 410 |
<div class="card">
<div class="card-body">
<figure class="chart" data-moey-chart="line">…</figure>
</div>
</div>
From JavaScript
Give the data to Moey.chart() — it writes the table for you — and call update() when it changes. The colors stay with their series.
<figure class="chart" id="orders">
<figcaption>Live orders</figcaption>
</figure>
<script>
const chart = Moey.chart('#orders', {
type: 'bar', // bar · line · area · donut
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [
{ name: 'Paid', data: [42, 51, 38, 60, 57] },
{ name: 'Refunded', data: [3, 5, 2, 4, 6], color: 'red' },
],
format: 'compact', // or 'currency:EUR', 'percent'
});
chart.update({ series: [ … ] }); // redraws, keeps colors
</script>
Colors
Series take these eight colors in this order. The order is what keeps neighbors apart for color-blind readers — every pair next to each other differs in both hue and lightness — so a ninth series should become "Other" (data-color="gray") rather than a new color. Dark mode uses its own checked steps. Pick one by name with data-color on the column's <th> when a color means something (refunds in red).
Accessible by default
- The data is a real table: screen readers read it, and the Table switch shows it to everyone.
- Tab to a chart, then use ← → (↑ ↓), Home, End to read each point — the values are announced.
- Names are never color-only: a legend for two or more series, labels in the tooltip, and the table.
- Tap targets cover the whole column, not the thin mark; a sideways drag on a phone reads along the chart while up/down still scrolls the page.
- Animations play once, when the chart scrolls into view, and never with reduced motion.
Reference
On the <figure class="chart"> | What it does |
|---|---|
data-moey-chart="bar|line|area|donut" | The kind of chart, drawn from the table inside |
data-moey-stacked | Bars or areas stack up (parts of a total) |
data-moey-horizontal | Bars run sideways (rankings, long names) |
data-moey-labels | Values at the bar tips |
data-moey-format="currency:EUR|percent|compact" | How numbers show (axis, tooltip, table); axes shorten big numbers (12K) by themselves |
data-moey-baseline="auto" | Lines: fit the data instead of starting at 0 |
data-moey-center="Visits" | Donut: the word under the total |
<th data-color="red"> · <tr data-color> · <td data-value> | A series' color · a donut part's color · the exact number of a cell |
--mo-chart-height · --mo-chart-1 … 8 · .chart-swatch-1 … 8 | The plot height (16rem; donut 13rem) · the palette · the palette as swatches |
Moey.chart(el, { type, labels, series, format }) | Draw from data → { update(data), data, el } |
Event moey:toggle | A series was hidden or shown from the legend (detail: { index, shown }) |
<span class="chart-spark" data-moey-spark="1,4,2"> | A sparkline |