Charts
Charts
<kui-chart> draws a small chart as inline SVG from the table inside it. The table is the data and the accessible version at once: screen readers read it, a button shows it on screen, and without a script it is all there is. Five types: line, bar, stacked, donut and sparkline.
Examples
Line
For a value over time. Each value column of the table is one line; the first column names the points. With one series the line gets a light area under it. Hover the plot to read the values of a month.
| Month | 2025 | 2026 |
|---|---|---|
| Jan | 18200 | 21400 |
| Feb | 17600 | 22900 |
| Mar | 20100 | 24800 |
| Apr | 19400 | 23600 |
| May | 21800 | 26100 |
| Jun | 22500 | 27900 |
| Jul | 19900 | 25200 |
| Aug | 16800 | 21700 |
| Sep | 23100 | 29400 |
| Oct | 24600 | 31200 |
| Nov | 25300 | 32800 |
| Dec | 27900 | 35100 |
<kui-chart type="line" currency="EUR">
<table class="kui-table">
<caption>Income per month, 2025 and 2026</caption>
<thead><tr><th scope="col">Month</th><th scope="col">2025</th><th scope="col">2026</th></tr></thead>
<tbody>
<tr><th scope="row">Jan</th><td>18200</td><td>21400</td></tr>
<tr><th scope="row">Feb</th><td>17600</td><td>22900</td></tr>
<tr><th scope="row">Mar</th><td>20100</td><td>24800</td></tr>
<tr><th scope="row">Apr</th><td>19400</td><td>23600</td></tr>
<tr><th scope="row">May</th><td>21800</td><td>26100</td></tr>
<tr><th scope="row">Jun</th><td>22500</td><td>27900</td></tr>
<tr><th scope="row">Jul</th><td>19900</td><td>25200</td></tr>
<tr><th scope="row">Aug</th><td>16800</td><td>21700</td></tr>
<tr><th scope="row">Sep</th><td>23100</td><td>29400</td></tr>
<tr><th scope="row">Oct</th><td>24600</td><td>31200</td></tr>
<tr><th scope="row">Nov</th><td>25300</td><td>32800</td></tr>
<tr><th scope="row">Dec</th><td>27900</td><td>35100</td></tr>
</tbody>
</table>
</kui-chart>
Line with one series
| Day | Response time |
|---|---|
| Mon | 182 |
| Tue | 176 |
| Wed | 204 |
| Thu | 241 |
| Fri | 198 |
| Sat | 151 |
| Sun | 147 |
<kui-chart type="line" unit="ms" height="180">
<table class="kui-table">
<caption>Median response time of the API</caption>
<thead><tr><th scope="col">Day</th><th scope="col">Response time</th></tr></thead>
<tbody>
<tr><th scope="row">Mon</th><td>182</td></tr>
<tr><th scope="row">Tue</th><td>176</td></tr>
<tr><th scope="row">Wed</th><td>204</td></tr>
<tr><th scope="row">Thu</th><td>241</td></tr>
<tr><th scope="row">Fri</th><td>198</td></tr>
<tr><th scope="row">Sat</th><td>151</td></tr>
<tr><th scope="row">Sun</th><td>147</td></tr>
</tbody>
</table>
</kui-chart>
Bar
Columns grouped by row: one group per quarter, one column per series in the fixed colour order. For comparing amounts between a few categories.
| Quarter | Novi Sad | Beograd | Niš |
|---|---|---|---|
| Q1 2026 | 412 | 538 | 196 |
| Q2 2026 | 455 | 571 | 224 |
| Q3 2026 | 438 | 602 | 251 |
| Q4 2026 | 496 | 644 | 279 |
<kui-chart type="bar" unit="invoices">
<table class="kui-table">
<caption>Invoices sent per quarter, by office</caption>
<thead><tr><th scope="col">Quarter</th><th scope="col">Novi Sad</th><th scope="col">Beograd</th><th scope="col">Niš</th></tr></thead>
<tbody>
<tr><th scope="row">Q1 2026</th><td>412</td><td>538</td><td>196</td></tr>
<tr><th scope="row">Q2 2026</th><td>455</td><td>571</td><td>224</td></tr>
<tr><th scope="row">Q3 2026</th><td>438</td><td>602</td><td>251</td></tr>
<tr><th scope="row">Q4 2026</th><td>496</td><td>644</td><td>279</td></tr>
</tbody>
</table>
</kui-chart>
Stacked bar
Columns whose parts add up to a whole: here the hours of a team per week, split by kind of work. Use it when the total matters as much as the parts.
| Week | Client work | Internal | Training |
|---|---|---|---|
| W44 | 96 | 22 | 6 |
| W45 | 104 | 18 | 8 |
| W46 | 88 | 30 | 4 |
| W47 | 112 | 16 | 12 |
| W48 | 101 | 24 | 6 |
<kui-chart type="stacked" unit="h">
<table class="kui-table">
<caption>Hours of the team per week, by kind of work</caption>
<thead><tr><th scope="col">Week</th><th scope="col">Client work</th><th scope="col">Internal</th><th scope="col">Training</th></tr></thead>
<tbody>
<tr><th scope="row">W44</th><td>96</td><td>22</td><td>6</td></tr>
<tr><th scope="row">W45</th><td>104</td><td>18</td><td>8</td></tr>
<tr><th scope="row">W46</th><td>88</td><td>30</td><td>4</td></tr>
<tr><th scope="row">W47</th><td>112</td><td>16</td><td>12</td></tr>
<tr><th scope="row">W48</th><td>101</td><td>24</td><td>6</td></tr>
</tbody>
</table>
</kui-chart>
Donut
The share of each row in a total, from the first value column. Keep it to five parts or fewer. Hover a part to see its value in the centre.
| Kind | Amount |
|---|---|
| Salaries | 1840000 |
| Rent | 360000 |
| Software | 145000 |
| Travel | 92000 |
| Other | 61000 |
<kui-chart type="donut" currency="RSD">
<table class="kui-table">
<caption>Costs in November 2026</caption>
<thead><tr><th scope="col">Kind</th><th scope="col">Amount</th></tr></thead>
<tbody>
<tr><th scope="row">Salaries</th><td>1840000</td></tr>
<tr><th scope="row">Rent</th><td>360000</td></tr>
<tr><th scope="row">Software</th><td>145000</td></tr>
<tr><th scope="row">Travel</th><td>92000</td></tr>
<tr><th scope="row">Other</th><td>61000</td></tr>
</tbody>
</table>
</kui-chart>
Sparkline in a stat tile
A small line with no axes, legend or table button, for the trend next to a number. It is drawn in the muted text colour with the last point in the accent. The table stays as hidden text for screen readers.
| Week | Open |
|---|---|
| W41 | 1420 |
| W42 | 1510 |
| W43 | 1480 |
| W44 | 1620 |
| W45 | 1590 |
| W46 | 1710 |
| W47 | 1780 |
| W48 | 1840 |
| Week | Days |
|---|---|
| W41 | 34 |
| W42 | 31 |
| W43 | 32 |
| W44 | 29 |
| W45 | 27 |
| W46 | 26 |
| W47 | 24 |
| W48 | 23 |
| Week | Satisfied |
|---|---|
| W41 | 91 |
| W42 | 92 |
| W43 | 90 |
| W44 | 93 |
| W45 | 92 |
| W46 | 94 |
| W47 | 93 |
| W48 | 94 |
<div class="kui-stats">
<div class="kui-stat">
<span class="kui-stat__label">Open invoices</span>
<span class="kui-stat__value">1.84<small>M RSD</small></span>
<kui-chart type="sparkline" class="kui-stat__spark">
<table class="kui-table">
<caption>Open invoices, last 8 weeks, in thousands of RSD</caption>
<thead><tr><th scope="col">Week</th><th scope="col">Open</th></tr></thead>
<tbody>
<tr><th scope="row">W41</th><td>1420</td></tr>
<tr><th scope="row">W42</th><td>1510</td></tr>
<tr><th scope="row">W43</th><td>1480</td></tr>
<tr><th scope="row">W44</th><td>1620</td></tr>
<tr><th scope="row">W45</th><td>1590</td></tr>
<tr><th scope="row">W46</th><td>1710</td></tr>
<tr><th scope="row">W47</th><td>1780</td></tr>
<tr><th scope="row">W48</th><td>1840</td></tr>
</tbody>
</table>
</kui-chart>
</div>
<div class="kui-stat">
<span class="kui-stat__label">Days to payment</span>
<span class="kui-stat__value">23<small>days</small></span>
<kui-chart type="sparkline" class="kui-stat__spark">
<table class="kui-table">
<caption>Median days to payment, last 8 weeks</caption>
<thead><tr><th scope="col">Week</th><th scope="col">Days</th></tr></thead>
<tbody>
<tr><th scope="row">W41</th><td>34</td></tr>
<tr><th scope="row">W42</th><td>31</td></tr>
<tr><th scope="row">W43</th><td>32</td></tr>
<tr><th scope="row">W44</th><td>29</td></tr>
<tr><th scope="row">W45</th><td>27</td></tr>
<tr><th scope="row">W46</th><td>26</td></tr>
<tr><th scope="row">W47</th><td>24</td></tr>
<tr><th scope="row">W48</th><td>23</td></tr>
</tbody>
</table>
</kui-chart>
</div>
<div class="kui-stat">
<span class="kui-stat__label">Rechnungsempfängerzufriedenheit</span>
<span class="kui-stat__value">94<small>%</small></span>
<kui-chart type="sparkline" class="kui-stat__spark">
<table class="kui-table">
<caption>Satisfaction of invoice recipients, last 8 weeks, in percent</caption>
<thead><tr><th scope="col">Week</th><th scope="col">Satisfied</th></tr></thead>
<tbody>
<tr><th scope="row">W41</th><td>91</td></tr>
<tr><th scope="row">W42</th><td>92</td></tr>
<tr><th scope="row">W43</th><td>90</td></tr>
<tr><th scope="row">W44</th><td>93</td></tr>
<tr><th scope="row">W45</th><td>92</td></tr>
<tr><th scope="row">W46</th><td>94</td></tr>
<tr><th scope="row">W47</th><td>93</td></tr>
<tr><th scope="row">W48</th><td>94</td></tr>
</tbody>
</table>
</kui-chart>
</div>
</div>
The colour rules
Series take the chart tokens --kui-chart-1 to --kui-chart-8 in this fixed order, in every theme. The first series is always blue and the second always orange, so a person who has learned one chart can read the next.
- 1. Blue
- 2. Orange
- 3. Green
- 4. Ochre
- 5. Pink
- 6. Leaf green
- 7. Violet
- 8. Red
- The order is fixed. Series 1 is
--kui-chart-1, series 2 is--kui-chart-2, and so on. Do not pick colours by meaning or taste. - Colours are never cycled. A chart with more than eight series is the wrong chart: group the small ones into “Other”, or show a table.
- A legend is drawn when there are two or more series (for a donut, two or more rows). A single series is named by the chart’s title, so it needs no legend.
- Text is never in a series colour. Titles, axis labels, values and the legend’s words use the text tokens; only the marks and the legend’s keys carry the series colours.
- The same series keeps the same colour across the charts of one screen. Keep the column order of the tables the same.
- Dark mode has its own eight values with the same order and hues, tuned for the dark surface. The theme check measures them against both backgrounds.
<ul class="kui-chart__legend" aria-label="The eight series colours in their order">
<li><span class="kui-chart__key kui-chart__s1"></span><span>1. Blue</span></li>
<li><span class="kui-chart__key kui-chart__s2"></span><span>2. Orange</span></li>
<li><span class="kui-chart__key kui-chart__s3"></span><span>3. Green</span></li>
<li><span class="kui-chart__key kui-chart__s4"></span><span>4. Ochre</span></li>
<li><span class="kui-chart__key kui-chart__s5"></span><span>5. Pink</span></li>
<li><span class="kui-chart__key kui-chart__s6"></span><span>6. Leaf green</span></li>
<li><span class="kui-chart__key kui-chart__s7"></span><span>7. Violet</span></li>
<li><span class="kui-chart__key kui-chart__s8"></span><span>8. Red</span></li>
</ul>
<ul class="docs-list">
<li>The order is fixed. Series 1 is <code class="kui-code">--kui-chart-1</code>, series 2 is <code class="kui-code">--kui-chart-2</code>, and so on. Do not pick colours by meaning or taste.</li>
<li>Colours are never cycled. A chart with more than eight series is the wrong chart: group the small ones into “Other”, or show a table.</li>
<li>A legend is drawn when there are two or more series (for a donut, two or more rows). A single series is named by the chart’s title, so it needs no legend.</li>
<li>Text is never in a series colour. Titles, axis labels, values and the legend’s words use the text tokens; only the marks and the legend’s keys carry the series colours.</li>
<li>The same series keeps the same colour across the charts of one screen. Keep the column order of the tables the same.</li>
<li>Dark mode has its own eight values with the same order and hues, tuned for the dark surface. The theme check measures them against both backgrounds.</li>
</ul>
The table is the fallback
The table button under every chart (except a sparkline) shows the table in place of nothing: the chart stays, and the table appears under it. Press it here. Without the script the table is shown as it is, styled by .kui-table.
| Client size | 2025 | 2026 |
|---|---|---|
| Up to 10 people | 71 | 78 |
| 11 to 50 | 76 | 83 |
| 51 to 250 | 82 | 88 |
| Over 250 | 64 | 69 |
| Client size | 2025 | 2026 |
|---|---|---|
| Up to 10 people | 71 % | 78 % |
| Over 250 | 64 % | 69 % |
<kui-chart type="bar" percent>
<table class="kui-table">
<caption>Share of invoices paid on time, by client size</caption>
<thead><tr><th scope="col">Client size</th><th scope="col">2025</th><th scope="col">2026</th></tr></thead>
<tbody>
<tr><th scope="row">Up to 10 people</th><td>71</td><td>78</td></tr>
<tr><th scope="row">11 to 50</th><td>76</td><td>83</td></tr>
<tr><th scope="row">51 to 250</th><td>82</td><td>88</td></tr>
<tr><th scope="row">Over 250</th><td>64</td><td>69</td></tr>
</tbody>
</table>
</kui-chart>
<table class="kui-table">
<caption>The same kind of table without the element, as a page without the script shows it</caption>
<thead><tr><th scope="col">Client size</th><th scope="col">2025</th><th scope="col">2026</th></tr></thead>
<tbody>
<tr><th scope="row">Up to 10 people</th><td>71 %</td><td>78 %</td></tr>
<tr><th scope="row">Over 250</th><td>64 %</td><td>69 %</td></tr>
</tbody>
</table>
States
Every state
A chart with no rows draws only its frame; say so in words next to it. A value cell that is not a number counts as 0, so fill every cell. Negative values in a bar chart go below the base line. Long labels on the horizontal axis are thinned so they never overlap.
| Month | Result |
|---|---|
| Jan | 4200 |
| Feb | -1800 |
| Mar | 2600 |
| Apr | 5100 |
| May | -600 |
| Jun | 3900 |
| Jul | 4400 |
| Aug | -2300 |
| Sep | 6100 |
| Oct | 5800 |
| Nov | 7200 |
| Dec | 3300 |
<kui-chart type="bar" currency="EUR" height="200">
<table class="kui-table">
<caption>Monthly result after costs, 2026</caption>
<thead><tr><th scope="col">Month</th><th scope="col">Result</th></tr></thead>
<tbody>
<tr><th scope="row">Jan</th><td>4200</td></tr>
<tr><th scope="row">Feb</th><td>-1800</td></tr>
<tr><th scope="row">Mar</th><td>2600</td></tr>
<tr><th scope="row">Apr</th><td>5100</td></tr>
<tr><th scope="row">May</th><td>-600</td></tr>
<tr><th scope="row">Jun</th><td>3900</td></tr>
<tr><th scope="row">Jul</th><td>4400</td></tr>
<tr><th scope="row">Aug</th><td>-2300</td></tr>
<tr><th scope="row">Sep</th><td>6100</td></tr>
<tr><th scope="row">Oct</th><td>5800</td></tr>
<tr><th scope="row">Nov</th><td>7200</td></tr>
<tr><th scope="row">Dec</th><td>3300</td></tr>
</tbody>
</table>
</kui-chart>
Classes and attributes
<kui-chart type>- line (the default), bar, stacked, donut or sparkline.
table inside- The data: a caption (the chart’s title), a head row (the first cell names the labels, the others name the series), one body row per point with a th and the values.
td data-value- The number to draw when the cell’s text is formatted (“1,2 M”).
unit="…"- Written after each value in the tooltip, such as ms or h.
currency="EUR"- Values are money in that ISO currency, formatted in the page’s language.
percent- Values are shares of 100 and are written with %.
height- The plot’s height in pixels. Defaults: 220 for line and bar, 200 for donut, 36 for sparkline.
.kui-chart__s1 … __s8- The series classes, if you draw a legend or a key of your own.
.kui-chart__legend, .kui-chart__key- The legend list and its colour key.
Keyboard
- Tab
- Reaches the button that shows or hides the table.
- Enter or Space
- Shows or hides the table.
Accessibility
- The drawing is aria-hidden; the table is the accessible version. Its caption is the chart’s name, read first.
- The table button has
aria-expandedandaria-controls; its words are the keyed showTable and showChart. - Values in the tooltip are formatted in the page’s language: 21.400 € in German, 21 400 € in Serbian.
- Series are told apart by colour and by the legend’s words; the tooltip names each series with its value. Do not rely on colour alone for a key finding: say it in the text around the chart.
- In forced-colours mode the marks use the system text colour; the table remains the exact reading.
Do and do not
Do
- Write the finding in a sentence above the chart: “Income grew 27 % against 2025”.
- Use a line for time, bars for comparing categories, a donut for parts of one total.
- Start the value axis at zero for bars; the chart does this for you.
Do not
- Do not use more than eight series, or more than five parts in a donut.
- Do not colour text, labels or numbers in a series colour.
- Do not remove the table; it is how many people read the chart.