The text colour

A chart has the text colour of the element it is in. The bars, the lines, the names and the numbers next to the bars all get that colour. Without a palette, each next line or slice is a lighter shade of it. If the page has another text colour in dark mode, the chart gets that colour too. See Light and dark.

In this example, no colour is set, so the chart has the text colour of this page:

Spring 58
Summer 72
Autumn 70
Winter 91
HTML
<figure data-chart="column">
	<table>
		<tbody>
			<tr><th>Spring</th><td>58</td></tr>
			<tr><th>Summer</th><td>72</td></tr>
			<tr><th>Autumn</th><td>70</td></tr>
			<tr><th>Winter</th><td>91</td></tr>
		</tbody>
	</table>
</figure>

If you want another colour for the chart only, set --tablechart-color on the figure. If you want the bars in another colour than the text, see One colour.

One colour

--tablechart-bar-color sets the colour of all bars, and of a single line.

CSS
.orange {
	--tablechart-bar-color: #e4572e;
}
Spring 58
Summer 72
Autumn 70
Winter 91
HTML
<figure class="orange" data-chart="column">
	<table>
		<tbody>
			<tr><th>Spring</th><td>58</td></tr>
			<tr><th>Summer</th><td>72</td></tr>
			<tr><th>Autumn</th><td>70</td></tr>
			<tr><th>Winter</th><td>91</td></tr>
		</tbody>
	</table>
</figure>

Colours with low contrast

If a column or bar has a colour with less than 3:1 contrast with the background, it gets an edge that has enough (WCAG 1.4.11). The edge is in the colour of the bar, moved towards the text colour as far as needed. It is inside the bar, so the bar keeps its size. Where the bar is on the baseline, the baseline is its edge. Then the baseline gets a contrast of 4.5:1, so it is darker than the edges. --tablechart-bar-edge-width sets the width of the edge (1px by default). If you want no edge, set --tablechart-bar-edge: none.

CSS
.pale {
	--tablechart-bar-color: light-dark(#f3d77a, #4a4a8a);
}
Spring 58
Summer 72
Autumn -30
Winter 91
HTML
<figure class="pale" data-chart="column">
	<table>
		<tbody>
			<tr><th>Spring</th><td>58</td></tr>
			<tr><th>Summer</th><td>72</td></tr>
			<tr><th>Autumn</th><td>-30</td></tr>
			<tr><th>Winter</th><td>91</td></tr>
		</tbody>
	</table>
</figure>
Spring 58
Summer 72
Autumn 70
Winter 91
HTML
<figure class="pale" data-chart="bar" style="--tablechart-bar-radius: 6px">
	<table>
		<tbody>
			<tr><th>Spring</th><td>58</td></tr>
			<tr><th>Summer</th><td>72</td></tr>
			<tr><th>Autumn</th><td>70</td></tr>
			<tr><th>Winter</th><td>91</td></tr>
		</tbody>
	</table>
</figure>

A palette works the same way: each series gets an edge only if its own colour has too little contrast. In the chart below, the first two colours get an edge and the third does not. Between the parts of a stack is a gap in the background colour. The parts have no edge along it, and the edges at the sides go on across it. The squares in the legend and in the tooltip get the same edge.

CSS
.pastel {
	--tablechart-color-1: light-dark(#a8d8ea, #2e4a6b);
	--tablechart-color-2: light-dark(#f6c6a8, #6b3a2e);
	--tablechart-color-3: light-dark(#5a7d9a, #9fc3e0);
}
Season Apples Pears Plums
Spring 20 14 9
Summer 31 22 15
Autumn 42 28 12
Winter 18 11 6
HTML
<figure class="pastel" data-chart="column" data-chart-stack>
	<table>
		<thead>
			<tr><th>Season</th><th>Apples</th><th>Pears</th><th>Plums</th></tr>
		</thead>
		<tbody>
			<tr><th>Spring</th><td>20</td><td>14</td><td>9</td></tr>
			<tr><th>Summer</th><td>31</td><td>22</td><td>15</td></tr>
			<tr><th>Autumn</th><td>42</td><td>28</td><td>12</td></tr>
			<tr><th>Winter</th><td>18</td><td>11</td><td>6</td></tr>
		</tbody>
	</table>
</figure>

A slice of a donut or pie gets the same edge, all round its shape: along the outside and the inside of the ring, along the gaps, and round the corners if the slices are rounded. A pie has no inside, so it has no edge there. The dots in the legend get the edge too.

Fruit Share
Apples 45
Pears 30
Plums 25
HTML
<figure class="pastel" data-chart="donut">
	<table>
		<thead>
			<tr><th>Fruit</th><th>Share</th></tr>
		</thead>
		<tbody>
			<tr><th>Apples</th><td>45</td></tr>
			<tr><th>Pears</th><td>30</td></tr>
			<tr><th>Plums</th><td>25</td></tr>
		</tbody>
	</table>
</figure>
Fruit Share
Apples 45
Pears 30
Plums 25
HTML
<figure class="pastel" data-chart="donut" style="--tablechart-slice-radius: 8px">
	<table>
		<thead>
			<tr><th>Fruit</th><th>Share</th></tr>
		</thead>
		<tbody>
			<tr><th>Apples</th><td>45</td></tr>
			<tr><th>Pears</th><td>30</td></tr>
			<tr><th>Plums</th><td>25</td></tr>
		</tbody>
	</table>
</figure>

In a combo chart, the columns get the edge. A line has no edge, so in the chart below it has a dark colour of its own.

CSS
.pale-combo {
	--tablechart-color-1: light-dark(#f3d77a, #4a4a8a);
	--tablechart-color-2: light-dark(#7a4f00, #e8d48a);
}
Season Sold Target
Spring 58 50
Summer 72 80
Autumn 30 45
Winter 91 85
HTML
<figure class="pale-combo" data-chart="column">
	<table>
		<thead>
			<tr><th>Season</th><th>Sold</th><th data-chart="line">Target</th></tr>
		</thead>
		<tbody>
			<tr><th>Spring</th><td>58</td><td>50</td></tr>
			<tr><th>Summer</th><td>72</td><td>80</td></tr>
			<tr><th>Autumn</th><td>30</td><td>45</td></tr>
			<tr><th>Winter</th><td>91</td><td>85</td></tr>
		</tbody>
	</table>
</figure>

Waterfall colours

These set the colours of rising steps, falling steps and totals. The number inside a bar gets a colour with enough contrast with the bar. See Numbers inside bars or columns.

CSS
.warm {
	--tablechart-up-color: light-dark(#3f7a3f, #44803f);
	--tablechart-down-color: #8a5a1c;
	--tablechart-total-color: #6b6256;
}
Picked 74.5
Windfalls 28.2
Bruised -16.1
Peelings -13.3
Pressed 73.3
HTML
<figure class="warm" data-chart="waterfall">
	<table>
		<tbody>
			<tr data-kind="total"><th>Picked</th><td>74.5</td></tr>
			<tr><th>Windfalls</th><td>28.2</td></tr>
			<tr><th>Bruised</th><td>-16.1</td></tr>
			<tr><th>Peelings</th><td>-13.3</td></tr>
			<tr data-kind="total"><th>Pressed</th><td>73.3</td></tr>
		</tbody>
	</table>
</figure>

A palette

Donut slices use --tablechart-color-1, --tablechart-color-2 and on, in order. If a colour is not set, that slice uses the default.

CSS
.fruity {
	--tablechart-color-1: #b4552d;
	--tablechart-color-2: #b47a2f;
	--tablechart-color-3: #678f67;
	--tablechart-color-4: #8f8576;
}
Picked 74.5
Juiced 38.2
Eaten fresh 18.1
Sold whole 12.4
Composted 5.8
HTML
<figure class="fruity" data-chart="donut">
	<table>
		<tbody>
			<tr data-kind="total"><th>Picked</th><td>74.5</td></tr>
			<tr><th>Juiced</th><td>38.2</td></tr>
			<tr><th>Eaten fresh</th><td>18.1</td></tr>
			<tr><th>Sold whole</th><td>12.4</td></tr>
			<tr><th>Composted</th><td>5.8</td></tr>
		</tbody>
	</table>
</figure>

If a line chart has several lines, the lines use the palette too.

Year North South East
2016 41 30 22
2019 58 39 35
2022 77 52 41
2025 105 61 70
HTML
<figure class="fruity" data-chart="line">
	<table>
		<thead>
			<tr><th>Year</th><th>North</th><th>South</th><th>East</th></tr>
		</thead>
		<tbody>
			<tr><th>2016</th><td>41</td><td>30</td><td>22</td></tr>
			<tr><th>2019</th><td>58</td><td>39</td><td>35</td></tr>
			<tr><th>2022</th><td>77</td><td>52</td><td>41</td></tr>
			<tr><th>2025</th><td>105</td><td>61</td><td>70</td></tr>
		</tbody>
	</table>
</figure>

Without a palette

Without a palette, each slice or line is a bit lighter than the one before it. These variables set how much.

Variable Sets
--tablechart-slice-color The colour of the first slice. The text colour by default.
--tablechart-slice-fade How much lighter each slice is: 15% by default.
--tablechart-slice-min The lightest a slice gets: 20% of its colour by default.
--tablechart-series-color The colour of the first line. The bar colour by default.
--tablechart-series-fade How much lighter each line is: 30% by default. With more than three lines, the steps are smaller, so the last line is not lighter than --tablechart-series-min.
--tablechart-series-min The lightest a line gets: 40% of its colour by default.
--tablechart-series-muted-share The strength of a line next to a highlighted line: 45% by default.
--tablechart-series-own-color The colour of one line, set on [data-series="2"] and so on.

A range of colours

If you set an end colour, the lines, the parts of a stack or the slices go from the first colour to the end colour, in even steps, instead of getting lighter. With two lines they are the first and the end colour; with three there is also the colour exactly in between, and so on.

If both colours have a contrast of at least 3:1 with the background, and both are darker than the background, or both lighter, every colour in between has that too. If both have at least 4.5:1, the numbers inside the parts can stay in the background colour.

CSS
.dark-range {
	--tablechart-bar-color: light-dark(#0b5d66, #236d76);
	--tablechart-series-color-end: light-dark(#1f3a8a, #4060b4);
}
Apples sold
thousands
Year Farm shop Market Online
2023 64 38 22
2024 71 45 30
2025 69 57 26
2026 80 62 41
HTML
<figure class="dark-range" data-chart="column" data-chart-stack>
	<figcaption><b>Apples sold</b><br><span>thousands</span></figcaption>
	<table>
		<thead>
			<tr><th>Year</th><th>Farm shop</th><th>Market</th><th>Online</th></tr>
		</thead>
		<tbody>
			<tr><th>2023</th><td>64</td><td>38</td><td>22</td></tr>
			<tr><th>2024</th><td>71</td><td>45</td><td>30</td></tr>
			<tr><th>2025</th><td>69</td><td>57</td><td>26</td></tr>
			<tr><th>2026</th><td>80</td><td>62</td><td>41</td></tr>
		</tbody>
	</table>
</figure>
Variable Sets
--tablechart-series-color-end The colour of the last line or part. The first is --tablechart-series-color, or the bar colour. --tablechart-series-color-start is another name for the first colour, to go with the end colour.
--tablechart-slice-color-end The colour of the last slice. The first is --tablechart-slice-color. --tablechart-slice-color-start is another name for it, to go with the end colour.