Numbers
Decimals, text around a number, missing values and the language of the page.
Text around a number
Tablechart reads the first number in each cell. Text before or after the number is shown with it, such as a currency sign, a percent sign or a footnote mark.
| Market | €2.40 |
|---|---|
| Farm shop | €2.90* |
| Supermarket | €3.10 |
<figure data-chart="column">
<figcaption><b>Price of a bag of apples</b></figcaption>
<table>
<tbody>
<tr><th>Market</th><td>€2.40</td></tr>
<tr><th>Farm shop</th><td>€2.90*</td></tr>
<tr><th>Supermarket</th><td>€3.10</td></tr>
</tbody>
</table>
</figure>
Decimals
All numbers on a chart have the same number of decimals: the most that any cell has. If you want to show one decimal, write one in at least one cell, such as 3.0.
| Mon | 2.5 |
|---|---|
| Tue | 3.0 |
| Wed | 4 |
| Thu | 1.5 |
<figure data-chart="column">
<figcaption><b>Rainfall in a day</b></figcaption>
<table>
<tbody>
<tr><th>Mon</th><td>2.5</td></tr>
<tr><th>Tue</th><td>3.0</td></tr>
<tr><th>Wed</th><td>4</td></tr>
<tr><th>Thu</th><td>1.5</td></tr>
</tbody>
</table>
</figure>
In the middle of a donut, the total keeps its own decimals.
Thousands
Numbers in the table have no thousands separator, such as 12500. Tablechart adds the separator of the language of the page. A comma or a point in a number is read as the decimal separator, so 12,500 is read as 12.5.
| North | 12500 |
|---|---|
| South | 9800 |
| East | 7250 |
<figure data-chart="bar">
<figcaption><b>Apples picked</b></figcaption>
<table>
<tbody>
<tr><th>North</th><td>12500</td></tr>
<tr><th>South</th><td>9800</td></tr>
<tr><th>East</th><td>7250</td></tr>
</tbody>
</table>
</figure>
Number formatting per language
How numbers are written follows the lang attribute of the html element: the decimal separator and the thousands separator. If the lang attribute changes, the numbers change with it, and the chart is redrawn. This is only the formatting of the numbers, not a translation. The title and the names stay as they are. If you want to translate them too, see Translation.
The buttons change the language of this page. The numbers on the columns change from 10,250.5 in English to 10.250,5 in Dutch, 10'250.5 in Swiss German and 10 250,5 in French.
| 2023 | 10250.5 |
|---|---|
| 2024 | 11800.0 |
| 2025 | 12500.5 |
<figure data-chart="column">
<figcaption><b>Apples picked</b></figcaption>
<table>
<tbody>
<tr><th>2023</th><td>10250.5</td></tr>
<tr><th>2024</th><td>11800.0</td></tr>
<tr><th>2025</th><td>12500.5</td></tr>
</tbody>
</table>
</figure>
If you want to use one language for all charts, whatever the page says, set the locale option.
init({ locale: "nl" });
Missing values
If a cell has no number, such as n/a, the row has no bar. The text of the cell is shown where the bar would be. In a line chart, the line has a gap.
| 2022 | 86 |
|---|---|
| 2023 | n/a |
| 2024 | 94 |
| 2025 | 101 |
<figure data-chart="column">
<figcaption><b>Apples picked</b></figcaption>
<table>
<tbody>
<tr><th>2022</th><td>86</td></tr>
<tr><th>2023</th><td>n/a</td></tr>
<tr><th>2024</th><td>94</td></tr>
<tr><th>2025</th><td>101</td></tr>
</tbody>
</table>
</figure>
Numbers that do not fit
If there is no room for a number, the chart has to omit it. This can happen in a stacked or grouped chart, a step chart or a line chart with lines close together. The number is still in the table, and the tooltip shows it.
A column or bar chart with many rows shows the numbers of its largest values, each only where it is clear of the other columns and numbers. A line or area chart shows the first, the last, the highest, the lowest and the values far from the trend. See Which values are shown.
If you hover over a column, bar or point (or tap it on a touch device), a tooltip shows all numbers at that place. See Tooltips.