Tablechart

for Reveal.js: Line charts

Line chart

Each row is a point. The line builds from left to right.

Rainfall at the orchard
millimetres
Jan 84
Feb 71
Mar 76
Apr 58
May 61
Jun 47
Jul 39
Aug 52
<figure class="tablechart" data-chart="line">
  <figcaption>
    <b>Rainfall at the orchard</b><br><span>millimetres</span>
  </figcaption>
  <table>
    <tbody>
      <tr><th>Jan</th><td>84</td></tr>
      <tr><th>Feb</th><td>71</td></tr>
      <tr><th>Mar</th><td>76</td></tr>
      <tr><th>Apr</th><td>58</td></tr>
      <tr><th>May</th><td>61</td></tr>
      <tr><th>Jun</th><td>47</td></tr>
      <tr><th>Jul</th><td>39</td></tr>
      <tr><th>Aug</th><td>52</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.

Rainfall at the orchard
millimetres
Jan 84
Feb 71
Mar 76
Apr 58
May 61
Jun 47
Jul 39
Aug 52
<figure class="tablechart" data-chart="line" data-chart-axis data-chart-grid>
  <figcaption>
    <b>Rainfall at the orchard</b><br><span>millimetres</span>
  </figcaption>
  <table>
    <tbody>
      <tr><th>Jan</th><td>84</td></tr>
      <tr><th>Feb</th><td>71</td></tr>
      <tr><th>Mar</th><td>76</td></tr>
      …
    </tbody>
  </table>
</figure>

Smooth

Add data-chart-shape="smooth" to the figure. The line is a curve through every point, and never goes higher or lower than the points on either side of it.

Rainfall at the orchard
millimetres
Jan 84
Feb 71
Mar 76
Apr 58
May 61
Jun 47
Jul 39
Aug 52
<figure class="tablechart" data-chart="line" data-chart-shape="smooth">
  <figcaption>
    <b>Rainfall at the orchard</b><br><span>millimetres</span>
  </figcaption>
  <table>
    <tbody>
      <tr><th>Jan</th><td>84</td></tr>
      <tr><th>Feb</th><td>71</td></tr>
      <tr><th>Mar</th><td>76</td></tr>
      <tr><th>Apr</th><td>58</td></tr>
      <tr><th>May</th><td>61</td></tr>
      <tr><th>Jun</th><td>47</td></tr>
      <tr><th>Jul</th><td>39</td></tr>
      <tr><th>Aug</th><td>52</td></tr>
    </tbody>
  </table>
</figure>

Grow up

Add data-chart-animate="grow" to the figure. The line grows up from zero instead of from left to right. A chart with data-fragment still builds from left to right, because each step adds a point.

Rainfall at the orchard
millimetres
Jan 84
Feb 71
Mar 76
Apr 58
May 61
Jun 47
Jul 39
Aug 52
<figure class="tablechart" data-chart="line" data-chart-shape="smooth" data-chart-animate="grow">
  <figcaption>
    <b>Rainfall at the orchard</b><br><span>millimetres</span>
  </figcaption>
  <table>
    <tbody>
      <tr><th>Jan</th><td>84</td></tr>
      <tr><th>Feb</th><td>71</td></tr>
      <tr><th>Mar</th><td>76</td></tr>
      <tr><th>Apr</th><td>58</td></tr>
      <tr><th>May</th><td>61</td></tr>
      <tr><th>Jun</th><td>47</td></tr>
      <tr><th>Jul</th><td>39</td></tr>
      <tr><th>Aug</th><td>52</td></tr>
    </tbody>
  </table>
</figure>

Annotations

Annotations work the same as in the other chart types.

Apples per tree
each
2021 74
2022 80
2023 91
2024 102
2025 116
A year+12%

Several lines

Each value column is a line. The column header is shown as the name at the end of the line.

Apples per tree
each
Year North South
2016 41 30
2019 58 39
2022 77 52
2025 105 61
<figure class="tablechart" data-chart="line" data-chart-prefix="lineseries">
  <figcaption>
    <b>Apples per tree</b><br><span>each</span>
  </figcaption>
  <table>
    <thead>
      <tr><th>Year</th><th>North</th><th>South</th></tr>
    </thead>
    <tbody>
      <tr><th>2016</th><td>41</td><td>30</td></tr>
      <tr><th>2019</th><td>58</td><td>39</td></tr>
      <tr><th>2022</th><td>77</td><td>52</td></tr>
      <tr><th>2025</th><td>105</td><td>61</td></tr>
    </tbody>
  </table>
</figure>

Legend

Add data-chart-legend to the figure to show the names in a legend under the chart, instead of at the end of the lines.

Apples per tree
each
Year North South
2016 41 30
2019 58 39
2022 77 52
2025 105 61
<figure class="tablechart" data-chart="line" data-chart-prefix="linelegend" data-chart-legend>
  <figcaption>
    <b>Apples per tree</b><br><span>each</span>
  </figcaption>
  <table>
    <thead>
      <tr><th>Year</th><th>North</th><th>South</th></tr>
    </thead>
    <tbody>
      <tr><th>2016</th><td>41</td><td>30</td></tr>
      …
      <tr><th>2025</th><td>105</td><td>61</td></tr>
    </tbody>
  </table>
</figure>

Step by step

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

Visitors to the orchard
thousands
2021 12
2022 18
2023 15
2024 24
2025 29
<figure class="tablechart" data-chart="line" data-chart-shape="smooth" data-fragment>
  <figcaption>
    <b>Visitors to the orchard</b><br><span>thousands</span>
  </figcaption>
  <table>
    <tbody>
      <tr><th>2021</th><td>12</td></tr>
      <tr><th>2022</th><td>18</td></tr>
      <tr><th>2023</th><td>15</td></tr>
      <tr><th>2024</th><td>24</td></tr>
      <tr><th>2025</th><td>29</td></tr>
    </tbody>
  </table>
</figure>

Several lines, step by step

With data-fragment on the figure, each step adds a point to every line.

Apples per tree
each
North South
2016 41 30
2019 58 39
2022 77 52
2025 105 61
<figure class="tablechart" data-chart="line" data-fragment>
  <figcaption>
    <b>Apples per tree</b><br><span>each</span>
  </figcaption>
  <table>
    <thead>
      <tr><th></th><th>North</th><th>South</th></tr>
    </thead>
    <tbody>
      <tr><th>2016</th><td>41</td><td>30</td></tr>
      <tr><th>2019</th><td>58</td><td>39</td></tr>
      …
    </tbody>
  </table>
</figure>

Line by line

Add data-fragment to a column header to show that whole line on a step.

Apples per tree
each
North South
2016 41 30
2019 58 39
2022 77 52
2025 105 61
<figure class="tablechart" data-chart="line">
  <figcaption>
    <b>Apples per tree</b><br><span>each</span>
  </figcaption>
  <table>
    <thead>
      <tr>
        <th></th>
        <th data-fragment>North</th>
        <th data-fragment>South</th>
      </tr>
    </thead>
    <tbody>
      <tr><th>2016</th><td>41</td><td>30</td></tr>
      <tr><th>2019</th><td>58</td><td>39</td></tr>
      …
    </tbody>
  </table>
</figure>

Point by point, line by line

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

Apples per tree
each
North South
2016 41 30
2019 58 39
2022 77 52
2025 105 61
<figure class="tablechart" data-chart="line">
  <figcaption>
    <b>Apples per tree</b><br><span>each</span>
  </figcaption>
  <table>
    <thead>
      <tr><th></th><th>North</th><th>South</th></tr>
    </thead>
    <tbody>
      <tr>
        <th>2016</th>
        <td data-fragment>41</td>
        <td data-fragment>30</td>
      </tr>
      <tr>
        <th>2019</th>
        <td data-fragment>58</td>
        <td data-fragment>39</td>
      </tr>
      …
    </tbody>
  </table>
</figure>