Tablechart

for Reveal.js: Column charts

Column chart

Apples picked
thousands
Spring 58
Summer 72
Autumn 70
Winter 91
<figure class="tablechart" data-chart="column">
  <figcaption>
    <b>Apples picked</b><br><span>thousands</span>
  </figcaption>
  <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>

Axis and gridlines

Add data-chart-axis for the numbers along the value axis, and data-chart-grid for a line at each of them. The scale then ends on a number of the axis.

Apples picked
thousands
Spring 58
Summer 72
Autumn 70
Winter 91
<figure class="tablechart" data-chart="column" data-chart-axis data-chart-grid>
  <figcaption>
    <b>Apples picked</b><br><span>thousands</span>
  </figcaption>
  <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>

More rows

Add more rows to the table. The columns get narrower to fit.

Apples per tree
each
2021 74
2022 80
2023 91
2024 102
2025 116

Decimals

Numbers are shown with the decimals you write, so 1.0 stays 1.0. The decimal separator follows the language of the document.

Seeds per fruit
each
Apples 8.2
Oranges 10.0
Lemons 6.5
<tr><th>Apples</th><td>8.2</td></tr>
<tr><th>Oranges</th><td>10.0</td></tr>
<tr><th>Lemons</th><td>6.5</td></tr>

Grouped columns

If the table has more than one value column, each row is a group. The column headers are the names in the legend.

Apples sold by variety
thousands
2022 2026
Elstar 118 131
Jonagold 140 135
Braeburn 109 121
<figure class="tablechart" data-chart="column">
  <figcaption>
    <b>Apples sold by variety</b><br><span>thousands</span>
  </figcaption>
  <table>
    <thead><tr><th></th><th>2022</th><th>2026</th></tr></thead>
    <tbody>
      <tr><th>Elstar</th><td>118</td><td>131</td></tr>
      <tr><th>Jonagold</th><td>140</td><td>135</td></tr>
      <tr><th>Braeburn</th><td>109</td><td>121</td></tr>
    </tbody>
  </table>
</figure>

Stacked columns

Add data-chart-stack to the figure. The values of a row are on top of each other, with the total above.

Apples sold
thousands
Farm shop Market
2023 64 38
2024 71 45
2025 69 57

Rounded ends

If a chart has --tablechart-corner-radius, the end of each column that shows the value is rounded. The end at the baseline stays square.

Apples picked
thousands
Spring 58
Summer 72
Autumn 70
Winter 91
<figure class="tablechart" data-chart="column" style="--tablechart-corner-radius: 6px;">
  <figcaption>
    <b>Apples picked</b><br><span>thousands</span>
  </figcaption>
  <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>

Rounded ends in a stack

In a stack, only the outer end of the stack is rounded.

Apples sold
thousands
Farm shop Market
2023 64 38
2024 71 45
2025 69 57
<figure class="tablechart" data-chart="column" data-chart-stack style="--tablechart-corner-radius: 6px;">
  <figcaption>
    <b>Apples sold</b><br><span>thousands</span>
  </figcaption>
  <table>
    <thead>
      <tr><th></th><th>Farm shop</th><th>Market</th></tr>
    </thead>
    <tbody>
      <tr><th>2023</th><td>64</td><td>38</td></tr>
      <tr><th>2024</th><td>71</td><td>45</td></tr>
      …
    </tbody>
  </table>
</figure>

Step by step

Add data-fragment to a row to show it on a step. Rows with the same data-fragment-index appear together.

Picked by grove
thousands
Apples, north 58
Oranges, north 72
Apples, south 70
Oranges, south 91
<tr data-fragment data-fragment-index="1">
  <th>Apples, north</th>
  <td>58</td>
</tr>
<tr data-fragment data-fragment-index="1">
  <th>Oranges, north</th>
  <td>72</td>
</tr>
<tr data-fragment data-fragment-index="2">
  <th>Apples, south</th>
  <td>70</td>
</tr>
<tr data-fragment data-fragment-index="2">
  <th>Oranges, south</th>
  <td>91</td>
</tr>

Grouped, step by step

With data-fragment on the figure, each step adds one group.

Apples sold by variety
thousands
2022 2026
Elstar 118 131
Jonagold 140 135
Braeburn 109 121
<figure class="tablechart" data-chart="column" data-fragment>
  <figcaption>
    <b>Apples sold by variety</b><br><span>thousands</span>
  </figcaption>
  <table>
    <thead><tr><th></th><th>2022</th><th>2026</th></tr></thead>
    <tbody>
      <tr><th>Elstar</th><td>118</td><td>131</td></tr>
      <tr><th>Jonagold</th><td>140</td><td>135</td></tr>
      …
    </tbody>
  </table>
</figure>

Grouped, series by series

Add data-fragment to a column header to show that series in every group on a step.

Apples sold by variety
thousands
2022 2026
Elstar 118 131
Jonagold 140 135
Braeburn 109 121
<figure class="tablechart" data-chart="column">
  <figcaption>
    <b>Apples sold by variety</b><br><span>thousands</span>
  </figcaption>
  <table>
    <thead>
      <tr>
        <th></th>
        <th data-fragment>2022</th>
        <th data-fragment>2026</th>
      </tr>
    </thead>
    <tbody>
      <tr><th>Elstar</th><td>118</td><td>131</td></tr>
      <tr><th>Jonagold</th><td>140</td><td>135</td></tr>
      …
    </tbody>
  </table>
</figure>

Grouped, one by one

Add data-fragment to every cell. The steps go down each column of the table: one series column by column, then the next.

Apples sold by variety
thousands
2022 2026
Elstar 118 131
Jonagold 140 135
Braeburn 109 121
<figure class="tablechart" data-chart="column">
  <figcaption>
    <b>Apples sold by variety</b><br><span>thousands</span>
  </figcaption>
  <table>
    <thead><tr><th></th><th>2022</th><th>2026</th></tr></thead>
    <tbody>
      <tr>
        <th>Elstar</th>
        <td data-fragment>118</td>
        <td data-fragment>131</td>
      </tr>
      <tr>
        <th>Jonagold</th>
        <td data-fragment>140</td>
        <td data-fragment>135</td>
      </tr>
      …
    </tbody>
  </table>
</figure>

Stacked, step by step

With data-fragment on the figure, each step adds one stack.

Apples sold
thousands
Farm shop Market
2023 64 38
2024 71 45
2025 69 57
<figure class="tablechart" data-chart="column" data-chart-stack data-fragment>
  <figcaption>
    <b>Apples sold</b><br><span>thousands</span>
  </figcaption>
  <table>
    <thead>
      <tr><th></th><th>Farm shop</th><th>Market</th></tr>
    </thead>
    <tbody>
      <tr><th>2023</th><td>64</td><td>38</td></tr>
      <tr><th>2024</th><td>71</td><td>45</td></tr>
      …
    </tbody>
  </table>
</figure>

Stacked, layer by layer

Add data-fragment to a column header to show that layer on every stack on a step.

Apples sold
thousands
Farm shop Market
2023 64 38
2024 71 45
2025 69 57
<figure class="tablechart" data-chart="column" data-chart-stack>
  <figcaption>
    <b>Apples sold</b><br><span>thousands</span>
  </figcaption>
  <table>
    <thead>
      <tr>
        <th></th>
        <th data-fragment>Farm shop</th>
        <th data-fragment>Market</th>
      </tr>
    </thead>
    <tbody>
      <tr><th>2023</th><td>64</td><td>38</td></tr>
      <tr><th>2024</th><td>71</td><td>45</td></tr>
      …
    </tbody>
  </table>
</figure>

Stacked, piece by piece

Add data-fragment to every cell. The steps go down each column of the table: the bottom layer piece by piece, then the next layer on top.

Apples sold
thousands
Farm shop Market
2023 64 38
2024 71 45
2025 69 57
<figure class="tablechart" data-chart="column" data-chart-stack>
  <figcaption>
    <b>Apples sold</b><br><span>thousands</span>
  </figcaption>
  <table>
    <thead>
      <tr><th></th><th>Farm shop</th><th>Market</th></tr>
    </thead>
    <tbody>
      <tr>
        <th>2023</th>
        <td data-fragment>64</td>
        <td data-fragment>38</td>
      </tr>
      <tr>
        <th>2024</th>
        <td data-fragment>71</td>
        <td data-fragment>45</td>
      </tr>
      …
    </tbody>
  </table>
</figure>

Break the scale

If one value is much larger than the others, add an axis-break annotation. Above the break, bar heights are not to scale, so every bar shows its number.

Apples picked by orchard
thousands
North 12.4
South 9.8
East 14.1
The old grove 168.5
West 11.2
<div class="chart-annotations">
  <span data-annotation="axis-break" data-at="20"></span>
</div>

Several charts on a slide

A chart fills the width of its container. To place several charts, use your own grid.

Apple juice
thousands of litres
Last season 251.5
This season 279.6
Orange juice
thousands of litres
Last season 92.2
This season 76.1
Lemon juice
thousands of litres
Last season 248.2
This season 261.6