Charts
Charts drawn from a plain HTML table. Put a <table> in a figure.chart with data-momo-chart: momo.js draws it, adds a legend, a tooltip for the pointer and the keyboard, and a Table button. Without JavaScript the table shows, so every value is always readable.
Column
Amounts per period or per group. A single series needs no legend (the title names it) and shows its values on the caps when there is room.
| Month | Signups |
|---|---|
| Jan | 420 |
| Feb | 515 |
| Mar | 610 |
| Apr | 580 |
| May | 735 |
| Jun | 890 |
<figure class="chart" data-momo-chart="column">
<figcaption><span class="chart-title">New signups</span><span class="chart-sub">Per month, 2026</span></figcaption>
<table>
<thead><tr><th>Month</th><th>Signups</th></tr></thead>
<tbody>
<tr><th>Jan</th><td>420</td></tr><tr><th>Feb</th><td>515</td></tr><tr><th>Mar</th><td>610</td></tr>
<tr><th>Apr</th><td>580</td></tr><tr><th>May</th><td>735</td></tr><tr><th>Jun</th><td>890</td></tr>
</tbody>
</table>
</figure>Grouped columns
Each extra column in the table is a series. Colors come in a fixed order and stay with their series: hide one in the legend and the others keep their color.
| Quarter | Starter | Team | Business |
|---|---|---|---|
| Q1 | 42 | 88 | 120 |
| Q2 | 48 | 97 | 131 |
| Q3 | 51 | 110 | 149 |
| Q4 | 57 | 126 | 171 |
<figure class="chart" data-momo-chart="column" data-prefix="$" data-height="220">
<figcaption><span class="chart-title">Revenue by plan</span><span class="chart-sub">Thousands, per quarter</span></figcaption>
<table>
<thead><tr><th>Quarter</th><th>Starter</th><th>Team</th><th>Business</th></tr></thead>
<tbody>
<tr><th>Q1</th><td>42</td><td>88</td><td>120</td></tr>
<tr><th>Q2</th><td>48</td><td>97</td><td>131</td></tr>
<tr><th>Q3</th><td>51</td><td>110</td><td>149</td></tr>
<tr><th>Q4</th><td>57</td><td>126</td><td>171</td></tr>
</tbody>
</table>
</figure>Line
Change over time. Each line ends with its value (when the ends are far enough apart), and the pointer gets a crosshair with every series in one tooltip. data-zero="false" lets the axis start near the data instead of at 0.
| Week | Web | iOS | Android |
|---|---|---|---|
| W1 | 100 | 100 | 100 |
| W2 | 72 | 78 | 69 |
| W3 | 61 | 70 | 57 |
| W4 | 55 | 66 | 49 |
| W5 | 52 | 63 | 44 |
| W6 | 50 | 61 | 40 |
| W7 | 49 | 60 | 38 |
| W8 | 48 | 59 | 36 |
<figure class="chart" data-momo-chart="line" data-suffix="%">
<figcaption><span class="chart-title">Weekly retention</span><span class="chart-sub">Share of users still active</span></figcaption>
<table>
<thead><tr><th>Week</th><th>Web</th><th>iOS</th><th>Android</th></tr></thead>
<tbody>
<tr><th>W1</th><td>100</td><td>100</td><td>100</td></tr>
<tr><th>W2</th><td>72</td><td>78</td><td>69</td></tr>
<tr><th>W3</th><td>61</td><td>70</td><td>57</td></tr>
<tr><th>W4</th><td>55</td><td>66</td><td>49</td></tr>
<tr><th>W5</th><td>52</td><td>63</td><td>44</td></tr>
<tr><th>W6</th><td>50</td><td>61</td><td>40</td></tr>
<tr><th>W7</th><td>49</td><td>60</td><td>38</td></tr>
<tr><th>W8</th><td>48</td><td>59</td><td>36</td></tr>
</tbody>
</table>
</figure>Area
A line with a soft wash under it, for one series where the amount matters.
| Day | Users |
|---|---|
| Nov 16 | 12400 |
| Nov 17 | 12950 |
| Nov 18 | 13100 |
| Nov 19 | 12800 |
| Nov 20 | 13600 |
| Nov 21 | 11200 |
| Nov 22 | 10900 |
| Nov 23 | 13900 |
| Nov 24 | 14300 |
| Nov 25 | 14800 |
| Nov 26 | 14650 |
| Nov 27 | 15200 |
| Nov 28 | 12100 |
| Nov 29 | 11800 |
<figure class="chart" data-momo-chart="area" data-height="180">
<figcaption><span class="chart-title">Active users</span><span class="chart-sub">Daily, last 14 days</span></figcaption>
<table>
<thead><tr><th>Day</th><th>Users</th></tr></thead>
<tbody>
<tr><th>Nov 16</th><td>12400</td></tr><tr><th>Nov 17</th><td>12950</td></tr><tr><th>Nov 18</th><td>13100</td></tr>
<tr><th>Nov 19</th><td>12800</td></tr><tr><th>Nov 20</th><td>13600</td></tr><tr><th>Nov 21</th><td>11200</td></tr>
<tr><th>Nov 22</th><td>10900</td></tr><tr><th>Nov 23</th><td>13900</td></tr><tr><th>Nov 24</th><td>14300</td></tr>
<tr><th>Nov 25</th><td>14800</td></tr><tr><th>Nov 26</th><td>14650</td></tr><tr><th>Nov 27</th><td>15200</td></tr>
<tr><th>Nov 28</th><td>12100</td></tr><tr><th>Nov 29</th><td>11800</td></tr>
</tbody>
</table>
</figure>Stacked
Parts of a total over time. Segments are split by a thin gap (no borders), and the tooltip adds the total.
| Week | Chat | Phone | Other | |
|---|---|---|---|---|
| W44 | 120 | 86 | 40 | 12 |
| W45 | 132 | 94 | 38 | 15 |
| W46 | 118 | 110 | 35 | 10 |
| W47 | 101 | 128 | 31 | 14 |
| W48 | 96 | 141 | 29 | 11 |
<figure class="chart" data-momo-chart="stacked" data-height="220">
<figcaption><span class="chart-title">Tickets by channel</span><span class="chart-sub">Per week</span></figcaption>
<table>
<thead><tr><th>Week</th><th>Email</th><th>Chat</th><th>Phone</th><th data-other>Other</th></tr></thead>
<tbody>
<tr><th>W44</th><td>120</td><td>86</td><td>40</td><td>12</td></tr>
<tr><th>W45</th><td>132</td><td>94</td><td>38</td><td>15</td></tr>
<tr><th>W46</th><td>118</td><td>110</td><td>35</td><td>10</td></tr>
<tr><th>W47</th><td>101</td><td>128</td><td>31</td><td>14</td></tr>
<tr><th>W48</th><td>96</td><td>141</td><td>29</td><td>11</td></tr>
</tbody>
</table>
</figure>data-other on a heading makes that series gray: use it to fold small series into "Other" instead of adding more colors. There are eight series colors; a ninth series should become "Other" or a second chart.
Bar (ranked list)
Horizontal bars for comparing named things: pages, products, people. Long names get cut with the full name on hover; values sit at the bar ends. Sort the table rows biggest first.
| Page | Visits |
|---|---|
| /pricing | 8420 |
| /docs/getting-started | 6105 |
| /blog/neobrutalism-in-product-design | 4380 |
| /changelog | 2950 |
| /careers | 1210 |
<figure class="chart" data-momo-chart="bar">
<figcaption><span class="chart-title">Top pages</span><span class="chart-sub">Visits this week</span></figcaption>
<table>
<thead><tr><th>Page</th><th>Visits</th></tr></thead>
<tbody>
<tr><th>/pricing</th><td>8420</td></tr>
<tr><th>/docs/getting-started</th><td>6105</td></tr>
<tr><th>/blog/neobrutalism-in-product-design</th><td>4380</td></tr>
<tr><th>/changelog</th><td>2950</td></tr>
<tr><th>/careers</th><td>1210</td></tr>
</tbody>
</table>
</figure>Sparkline
A tiny trend for stat cards and table rows: <span class="sparkline" data-values="…">. It is drawn in gray with the latest point in the accent. Add data-area for a wash, and .sparkline-block to fill the width.
Conversion 4.4%
<div class="stat">
<span class="stat-label">Monthly revenue</span>
<span class="stat-value">$48.2K</span>
<span class="stat-meta"><span class="stat-change is-up"><i class="mi mi-trending-up" aria-hidden="true"></i> 12%</span> vs last month</span>
<span class="sparkline sparkline-block" data-values="31,34,33,37,36,40,39,42,41,44,46,48" data-area aria-label="Revenue trend, last 12 months: 31K to 48K"></span>
</div>
<p>Conversion <span class="sparkline" data-values="3.1,3.4,3.2,3.8,4.1,3.9,4.4" aria-label="Conversion, last 7 days: 3.1% to 4.4%"></span> <b>4.4%</b></p>Reading the values
- Pointer: move over a chart. Lines get a crosshair; columns and bars light up their group.
- Keyboard: tab to the chart, then use the arrow keys, Home and End. The tooltip is read out.
- Table: the Table button swaps the drawing for the data table (and back).
- Legend: with two or more series, click a name to hide or show it. The last one cannot be hidden.
Options
| Attribute | Does |
|---|---|
data-momo-chart | column, bar, stacked, line or area |
data-prefix / data-suffix | Text around every value: $, %, h |
data-decimals | Decimal places (default: none for whole numbers, 1 otherwise). Axes past 10,000 switch to 10K style. |
data-height | Plot height in pixels (default 240). The axis labels are added below it, never cut. |
data-zero="false" | Lines and areas: start the axis near the data |
data-labels | none hides value labels; all shows column caps even past 12 columns |
td data-value | The number to draw when the cell shows formatted text ($1.2M) |
th data-other | That series is the gray "Other" |
JavaScript
Load new data with Momo.chart.update: it rewrites the table too, so the table view always matches. A series keeps its color when it comes back. While data loads, Momo.chart.loading(fig) fades the old chart instead of flashing.
const fig = document.querySelector('#revenue');
Momo.chart.loading(fig);
const data = await fetch('/api/revenue').then((r) => r.json());
Momo.chart.update(fig, {
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
series: [{ name: 'Starter', values: [42, 48, 51, 57] }, { name: 'Team', values: [88, 97, 110, 126] }],
});
Good to know
- Never put two different units on one chart with two axes: make two charts.
- One big number is a stat card, not a chart with one bar.
- Series colors are checked for color blindness and contrast in light and dark mode:
--chart-1to--chart-8(violet, yellow, pink, orange, cyan, lime, blue, red) and--chart-other. - Text in charts always uses the text colors, never the series color.