Skip to the content
Konstruktor UI

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.

<kui-chart> needs kui.js; the markup works without it as described below

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.

Income per month, 2025 and 2026
Month20252026
Jan1820021400
Feb1760022900
Mar2010024800
Apr1940023600
May2180026100
Jun2250027900
Jul1990025200
Aug1680021700
Sep2310029400
Oct2460031200
Nov2530032800
Dec2790035100
HTML
<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

Median response time of the API
DayResponse time
Mon182
Tue176
Wed204
Thu241
Fri198
Sat151
Sun147
HTML
<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.

Invoices sent per quarter, by office
QuarterNovi SadBeogradNiš
Q1 2026412538196
Q2 2026455571224
Q3 2026438602251
Q4 2026496644279
HTML
<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.

Hours of the team per week, by kind of work
WeekClient workInternalTraining
W4496226
W45104188
W4688304
W471121612
W48101246
HTML
<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.

Costs in November 2026
KindAmount
Salaries1840000
Rent360000
Software145000
Travel92000
Other61000
HTML
<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.

Open invoices 1.84M RSD
Open invoices, last 8 weeks, in thousands of RSD
WeekOpen
W411420
W421510
W431480
W441620
W451590
W461710
W471780
W481840
Days to payment 23days
Median days to payment, last 8 weeks
WeekDays
W4134
W4231
W4332
W4429
W4527
W4626
W4724
W4823
Rechnungsempfängerzufriedenheit 94%
Satisfaction of invoice recipients, last 8 weeks, in percent
WeekSatisfied
W4191
W4292
W4390
W4493
W4592
W4694
W4793
W4894
HTML
<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.
HTML
<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.

Share of invoices paid on time, by client size
Client size20252026
Up to 10 people7178
11 to 507683
51 to 2508288
Over 2506469
The same kind of table without the element, as a page without the script shows it
Client size20252026
Up to 10 people71 %78 %
Over 25064 %69 %
HTML
<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.

Monthly result after costs, 2026
MonthResult
Jan4200
Feb-1800
Mar2600
Apr5100
May-600
Jun3900
Jul4400
Aug-2300
Sep6100
Oct5800
Nov7200
Dec3300
HTML
<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-expanded and aria-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.