Tablechart

for Reveal.js: Donuts

Donut chart

Each row is a slice. The slices start at the top and go clockwise, in the order of the table.

Where the crop went
thousands of apples
Picked 68.7
Juiced 38.2
Eaten fresh 18.1
Sold whole 12.4
<figure class="tablechart" data-chart="donut">
  <figcaption>
    <b>Where the crop went</b><br>
    <span>thousands of apples</span>
  </figcaption>
  <table>
    <tbody>
      <tr data-kind="total"><th>Picked</th><td>68.7</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>
    </tbody>
  </table>
</figure>

The number in the middle

If a row has data-kind="total", its value is shown in the middle. If there is no total row, the middle shows the sum of the slices.

Where the crop went
thousands of apples
Picked 74.5
Juiced 38.2
Eaten fresh 18.1
Sold whole 12.4
Composted 5.8

Colours

By default, all slices use the text colour, each one a bit lighter. To set your own colours, set --tablechart-color-1, -2 and on.

Given a palette
thousands of apples
Picked 68.7
Juiced 38.2
Eaten fresh 18.1
Sold whole 12.4
.donutpalette {
    --tablechart-color-1: #b4552d;
    --tablechart-color-2: #d69a52;
    --tablechart-color-3: #7fa87f;
}

Rounded slices

If a chart has --tablechart-corner-radius, the corners of its slices are rounded. A thin slice gets a smaller radius.

Where the crop went
thousands of apples
Picked 68.7
Juiced 38.2
Eaten fresh 18.1
Sold whole 12.4
<figure class="tablechart" data-chart="donut" style="--tablechart-corner-radius: 6px;">
  <figcaption>
    <b>Where the crop went</b><br>
    <span>thousands of apples</span>
  </figcaption>
  <table>
    <tbody>
      <tr data-kind="total"><th>Picked</th><td>68.7</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>
    </tbody>
  </table>
</figure>

Step by step

Add data-fragment to the figure to show one slice per step.

Where the crop went
thousands of apples
Picked 68.7
Juiced 38.2
Eaten fresh 18.1
Sold whole 12.4
<figure class="tablechart" data-chart="donut" data-fragment>
  <figcaption>
    <b>Where the crop went</b><br>
    <span>thousands of apples</span>
  </figcaption>
  <table>
    <tbody>
      <tr data-kind="total"><th>Picked</th><td>68.7</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>
    </tbody>
  </table>
</figure>