Fewer names and numbers

A chart with many rows has little room for each number and name. Tablechart then shows fewer of them, on every chart type. The table keeps all of them, so a screen reader reads every value. If you hover over a row of the chart (or tap it on a touch device), a tooltip shows all its numbers.

Names under the chart

  • If the names under the chart do not fit, they get smaller, down to 70%. If they still do not fit, only every second, third or more is shown, evenly spaced, at full size. A name at an end moves in, so it stays inside the chart.
  • Each name has a tick above it, at the place of its row, so you can see which point it belongs to, also when it moved in. They have the colour and width of the gridlines, a little stronger. --tablechart-tick-color, --tablechart-tick-opacity and --tablechart-tick-width change them. data-chart-ticks="false", or the ticks option, turns the ticks off.

A short name under the chart needs less room. A row can have its full name in the table, which a screen reader and the tooltip read, and a short name for under the chart in data-short.

Apple juice sold
thousands of litres per month
January 2023 24.0
February 2023 24.6
March 2023 24.3
April 2023 21.4
May 2023 20.6
June 2023 18.3
July 2023 18.9
August 2023 20.6
September 2023 21.2
October 2023 24.3
November 2023 25.5
December 2023 28.1
January 2024 29.8
February 2024 28.4
March 2024 28.1
April 2024 25.3
May 2024 24.4
June 2024 24.1
July 2024 22.7
August 2024 24.4
September 2024 25.0
October 2024 28.2
November 2024 31.3
December 2024 31.9
January 2025 33.6
February 2025 32.2
March 2025 31.9
April 2025 31.1
May 2025 28.2
June 2025 27.9
July 2025 26.5
August 2025 28.2
September 2025 30.8
October 2025 31.9
November 2025 35.1
December 2025 35.7
HTML
<figure data-chart="line">
	<table>
		<tbody>
			<tr><th data-short="Jan ’23">January 2023</th><td>24.0</td></tr>
			<tr><th data-short="Feb ’23">February 2023</th><td>24.6</td></tr>
			<!-- …one row per month, 36 in all -->
		</tbody>
	</table>
</figure>

A row with a translation key, such as juice-row11, gets the key juice-row11-short for its short name under the chart. A translation script then needs a short name for that key too.

Numbers on a line or an area

If the values of a line would touch, only a few are shown: the first, the last, the highest, the lowest and the values far from the trend. See Which values are shown.

A point is shown where a value is. If all values are shown and the points would touch each other, the line has no points.

Numbers on columns and bars

With many columns, only the numbers of the largest values are shown, each where it is clear of the other columns and numbers.

Visitors to the farm shop
January 2024 35
February 2024 40
March 2024 51
April 2024 65
May 2024 79
June 2024 89
July 2024 94
August 2024 92
September 2024 85
October 2024 74
November 2024 63
December 2024 55
January 2025 53
February 2025 58
March 2025 69
April 2025 83
May 2025 97
June 2025 107
July 2025 112
August 2025 110
September 2025 103
October 2025 92
November 2025 81
December 2025 73
HTML
<tr><th data-short="Jan ’24">January 2024</th><td>35</td></tr>

On grouped columns, the numbers all get smaller together, down to half their size. If they still do not fit, the chart has to omit all of them.

On stacked columns, a number inside a part of a column is shown only if it fits there. The totals above the columns follow the same rule as single columns: the largest totals that are clear of the others are shown.

Apples sold
thousands per month
Month Farm shop Market
January 2024 21 20
February 2024 24 41
March 2024 31 29
April 2024 39 50
May 2024 47 38
June 2024 53 26
July 2024 56 47
August 2024 55 35
September 2024 51 23
October 2024 44 44
November 2024 38 32
December 2024 33 20
January 2025 32 41
February 2025 35 29
March 2025 41 50
April 2025 50 38
May 2025 58 26
June 2025 64 47
July 2025 67 35
August 2025 66 23
September 2025 62 44
October 2025 55 32
November 2025 49 20
December 2025 44 41
HTML
<figure data-chart="column" data-chart-stack>
	<figcaption><b>Apples sold</b><br><span>thousands per month</span></figcaption>
	<table>
		<thead>
			<tr><th>Month</th><th>Farm shop</th><th>Market</th></tr>
		</thead>
		<tbody>
			<tr><th data-short="Jan ’24">January 2024</th><td>21</td><td>20</td></tr>
			<tr><th data-short="Feb ’24">February 2024</th><td>24</td><td>41</td></tr>
			<tr><th data-short="Mar ’24">March 2024</th><td>31</td><td>29</td></tr>
			<tr><th data-short="Apr ’24">April 2024</th><td>39</td><td>50</td></tr>
			<tr><th data-short="May ’24">May 2024</th><td>47</td><td>38</td></tr>
			…
			<tr><th data-short="Nov ’25">November 2025</th><td>49</td><td>20</td></tr>
			<tr><th data-short="Dec ’25">December 2025</th><td>44</td><td>41</td></tr>
		</tbody>
	</table>
</figure>

Bar charts

A bar chart gets taller with each row, so every bar keeps the same thickness, and every name and number fits. A long name wraps onto more lines. If you want short names next to the bars, use data-short, as above. See Long names.

A bar chart on narrow screens

A column chart with many rows can be shown as a bar chart when it is narrow. If the figure has --tablechart-type: bar in a container query or a media query, the chart is built again as a bar chart when the query applies, and as a column chart when it does not.

CSS
.type-box {
	container-type: inline-size;
}
@container (max-width: 500px) {
	.type-box > [data-chart] {
		--tablechart-type: bar;
	}
}

The buttons change the width of the example.

Visitors per month
Jan 41
Feb 38
Mar 52
Apr 61
May 74
Jun 88
Jul 93
Aug 90
Sep 77
Oct 63
Nov 49
Dec 45
HTML
<div class="type-box">
	<figure data-chart="column">
		<figcaption><b>Visitors per month</b></figcaption>
		<table>
			<tbody>
				<tr><th>Jan</th><td>41</td></tr>
				<tr><th>Feb</th><td>38</td></tr>
				<tr><th>Mar</th><td>52</td></tr>
				<tr><th>Apr</th><td>61</td></tr>
				<tr><th>May</th><td>74</td></tr>
				<tr><th>Jun</th><td>88</td></tr>
				<tr><th>Jul</th><td>93</td></tr>
				<tr><th>Aug</th><td>90</td></tr>
				<tr><th>Sep</th><td>77</td></tr>
				<tr><th>Oct</th><td>63</td></tr>
				<tr><th>Nov</th><td>49</td></tr>
				<tr><th>Dec</th><td>45</td></tr>
			</tbody>
		</table>
	</figure>
</div>

--tablechart-type works for column and bar charts. It can also turn a bar chart into a column chart, with --tablechart-type: column.

Pies and donuts with many slices

Each slice is 15% lighter than the one before, down to 20% of the colour. From about the sixth slice on, the slices have the same colour. Then a warning in the console shows that those slices have too little contrast with the background. If you want a colour for each slice, set a palette.

A number that does not fit in its slice is next to it, with a short line. If those numbers would touch, only the numbers of the largest slices are shown. The legend lists every slice.

Trees in the orchard
per variety
Elstar 320
Jonagold 192
Braeburn 137
Gala 107
Boskoop 87
Cox 74
Granny Smith 64
Fuji 56
Pinova 51
Santana 46
Topaz 42
Kanzi 38
Rubens 36
Wellant 33
Junami 31
Red Prince 29
HTML
<figure data-chart="donut">
	<figcaption><b>Trees in the orchard</b><br><span>per variety</span></figcaption>
	<table>
		<tbody>
			<tr><th>Elstar</th><td>320</td></tr>
			<tr><th>Jonagold</th><td>192</td></tr>
			<tr><th>Braeburn</th><td>137</td></tr>
			<tr><th>Gala</th><td>107</td></tr>
			<tr><th>Boskoop</th><td>87</td></tr>
			…
			<tr><th>Junami</th><td>31</td></tr>
			<tr><th>Red Prince</th><td>29</td></tr>
		</tbody>
	</table>
</figure>

If you want the small slices to be clear, add them up in one row, such as "Other". Or, if each value matters, a bar chart shows every name next to its number.

Many lines

With several lines, the name of each line is at its end. If lines end close together, their names move apart, so each one has room. If the names and numbers still crowd each other, the names can go in a legend: see Legends.

Summary

For a long table, a summary can say in a few sentences what a listener needs, such as the highest value and the trend. See Summary.