Line
A line through the values, or several lines.
Line chart
Each row of the table is a point. The number is shown above each point.
millimetres
| Jan | 84 |
|---|---|
| Feb | 71 |
| Mar | 76 |
| Apr | 58 |
| May | 61 |
| Jun | 47 |
| Jul | 39 |
| Aug | 52 |
<figure 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>
Smooth
If the figure has data-chart-shape="smooth", the line is a curve through every point. It never goes higher or lower than the points on either side of it, so the curve shows no peak or dip that is not in the data, and a flat stretch stays flat.
millimetres
| Jan | 84 |
|---|---|
| Feb | 71 |
| Mar | 76 |
| Apr | 58 |
| May | 61 |
| Jun | 47 |
| Jul | 39 |
| Aug | 52 |
<figure 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>
If you want to make every line and area smooth, set the shape option to "smooth". Then data-chart-shape="straight" makes one chart straight again.
Grow
If the figure has data-chart-animate="grow", the line grows from zero instead of from left to right. The points move with it, and the numbers appear when it is done.
millimetres
| Jan | 84 |
|---|---|
| Feb | 71 |
| Mar | 76 |
| Apr | 58 |
| May | 61 |
| Jun | 47 |
| Jul | 39 |
| Aug | 52 |
<figure 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>
If you want to make every line and area grow, set the animate option to "grow". A chart with triggered steps (like from Reveal.js fragments) still builds from left to right. See Animation.
Below zero
A line can cross zero. A number below zero is shown under its point, and a grey line marks zero.
thousands of euros
| Jan | 12.6 |
|---|---|
| Feb | 28.7 |
| Mar | -11.7 |
| Apr | -36.3 |
| May | 19.8 |
| Jun | -4.1 |
<figure data-chart="line" data-chart-shape="smooth" data-chart-animate="grow">
<figcaption><b>Monthly result</b><br><span>thousands of euros</span></figcaption>
<table>
<tbody>
<tr><th>Jan</th><td>12.6</td></tr>
<tr><th>Feb</th><td>28.7</td></tr>
<tr><th>Mar</th><td>-11.7</td></tr>
<tr><th>Apr</th><td>-36.3</td></tr>
<tr><th>May</th><td>19.8</td></tr>
<tr><th>Jun</th><td>-4.1</td></tr>
</tbody>
</table>
</figure>
Several lines
Each value column is a line. The column header is the name of the line, shown at the end of the line. If the lines end close together, and their names and values crowd each other there, show the names in a legend instead: see Legends.
| Year | North | South |
|---|---|---|
| 2016 | 41 | 30 |
| 2019 | 58 | 39 |
| 2022 | 77 | 52 |
| 2025 | 105 | 61 |
<figure data-chart="line">
<figcaption><b>Apples per tree</b></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>
The numbers depend on the number of lines:
- One line: the number is above each point.
- Two lines: the number of the higher point is above it, the number of the lower point below it.
- Three lines or more: if there is room, the number is above its point. If not, it is below it. If there is no room there either, the chart has to omit it. If you hover over the chart above a name (or tap it on a touch device), a tooltip shows all numbers at that place. If one line is highlighted, only that line shows its numbers.
Points
With several lines, each line has its own point. There are six points, always in the same order. After six lines, the points start again with the next line style. So there are 24 different lines, and the 25th line looks like the first. The legend shows the same points.
| Line | Filled circle | Open circle | Filled square | Open square | Filled diamond | Open diamond |
|---|---|---|---|---|---|---|
| Solid | 1 | 2 | 3 | 4 | 5 | 6 |
| Dashed | 7 | 8 | 9 | 10 | 11 | 12 |
| Dotted | 13 | 14 | 15 | 16 | 17 | 18 |
| Dash-dot | 19 | 20 | 21 | 22 | 23 | 24 |
| Year | North | South | East | West |
|---|---|---|---|---|
| 2016 | 41 | 30 | 22 | 12 |
| 2019 | 58 | 39 | 35 | 20 |
| 2022 | 77 | 52 | 41 | 33 |
| 2025 | 105 | 61 | 70 | 45 |
<figure data-chart="line" data-chart-legend>
<figcaption><b>Apples per tree</b></figcaption>
<table>
<thead>
<tr><th>Year</th><th>North</th><th>South</th><th>East</th><th>West</th></tr>
</thead>
<tbody>
<tr><th>2016</th><td>41</td><td>30</td><td>22</td><td>12</td></tr>
<tr><th>2019</th><td>58</td><td>39</td><td>35</td><td>20</td></tr>
<tr><th>2022</th><td>77</td><td>52</td><td>41</td><td>33</td></tr>
<tr><th>2025</th><td>105</td><td>61</td><td>70</td><td>45</td></tr>
</tbody>
</table>
</figure>
If you want another point on a line, add data-marker to its column header: circle, square or diamond. If you want an open point, add open, such as data-marker="diamond open".
| Year | North | South |
|---|---|---|
| 2016 | 41 | 30 |
| 2019 | 58 | 39 |
| 2022 | 77 | 52 |
| 2025 | 105 | 61 |
<figure data-chart="line" data-chart-legend>
<table>
<thead>
<tr><th>Year</th><th data-marker="diamond">North</th><th data-marker="diamond open">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>
An open point is cut out of the line, so the background shows through it.
Dashed and dotted lines
If the column header of a line has data-line="dashed", data-line="dotted" or data-line="dash-dot", the line is dashed, dotted or has dashes and dots. The legend shows the same line.
| Year | North | South | East | Central | West |
|---|---|---|---|---|---|
| 2016 | 41 | 30 | 22 | 62 | 12 |
| 2019 | 58 | 39 | 35 | 81 | 20 |
| 2022 | 77 | 52 | 41 | 108 | 33 |
| 2025 | 105 | 61 | 70 | 132 | 45 |
<figure data-chart="line" data-chart-legend>
<figcaption><b>Apples per tree</b></figcaption>
<table>
<thead>
<tr><th>Year</th><th>North</th><th data-line="dashed">South</th><th data-line="dotted">East</th><th data-line="dash-dot">Central</th><th>West</th></tr>
</thead>
<tbody>
<tr><th>2016</th><td>41</td><td>30</td><td>22</td><td>62</td><td>12</td></tr>
<tr><th>2019</th><td>58</td><td>39</td><td>35</td><td>81</td><td>20</td></tr>
<tr><th>2022</th><td>77</td><td>52</td><td>41</td><td>108</td><td>33</td></tr>
<tr><th>2025</th><td>105</td><td>61</td><td>70</td><td>132</td><td>45</td></tr>
</tbody>
</table>
</figure>
If you want another pattern or another line width, see Lines and points.
If you want to give each line its own colour, use a palette.
Your own order
If you want another look for every line chart, also later ones, set the lines option. Each next line gets the next item, and after the last item the order starts again. An item can have marker, open and line. The legend and the tooltip show the same look.
init({
lines: [
{ marker: "square" },
{ marker: "diamond", open: true, line: "dashed" },
{ marker: "circle", line: "dotted" },
],
});
data-marker and data-line on a column header still set the look of that one line. On a column chart with a line over it, only the lines count.
If you want this for one chart or one part of a page, add data-chart-lines to the figure or to an element around it, with the same list as JSON.
Some lines do not need to be told apart, such as the lines of a forecast. If you want all lines to look the same, use a list with one item. With marker: "none", the lines have no points. On one line, data-marker="none" on its column header does the same.
| Year | Low | Lower | Middle | Higher | High |
|---|---|---|---|---|---|
| 2025 | 30 | 30 | 30 | 30 | 30 |
| 2026 | 27 | 31 | 33 | 35 | 37 |
| 2027 | 29 | 29 | 31 | 40 | 35 |
| 2028 | 26 | 33 | 38 | 37 | 44 |
| 2029 | 28 | 36 | 42 | 46 | 52 |
| 2030 | 25 | 34 | 40 | 51 | 49 |
| 2031 | 23 | 38 | 47 | 49 | 60 |
| 2032 | 26 | 35 | 44 | 58 | 67 |
| 2033 | 22 | 39 | 51 | 63 | 74 |
| 2034 | 24 | 41 | 55 | 66 | 86 |
<figure data-chart="line" data-chart-lines='[{"marker":"none"}]' data-chart-values="last">
<figcaption><b>Possible harvests per tree</b></figcaption>
<table>
<thead>
<tr><th>Year</th><th>Low</th><th>Lower</th><th>Middle</th><th>Higher</th><th>High</th></tr>
</thead>
<tbody>
<tr><th>2025</th><td>30</td><td>30</td><td>30</td><td>30</td><td>30</td></tr>
<!-- …one row per year, to 2034 -->
</tbody>
</table>
</figure>
Your list replaces the 24 looks. If it has three items, the fourth line looks like the first, and only its colour tells them apart. So if your charts can have many lines, the list needs as many items as there are lines.
Highlight a line
If the header of a line has data-kind="focus", that line keeps its colour and shows its numbers. The other lines are shown fainter.
| Year | North | South | East |
|---|---|---|---|
| 2016 | 41 | 30 | 22 |
| 2019 | 58 | 39 | 35 |
| 2022 | 77 | 52 | 41 |
| 2025 | 105 | 61 | 70 |
<figure data-chart="line">
<table>
<thead>
<tr><th>Year</th><th data-kind="focus">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>
Steps
If the figure has data-chart-shape="step", each value is a flat line across the width of its row, and the line goes straight up or down to the next row. A step line has no points. A number is shown only where the value changes, in the middle of the rows that have that value.
euros
| Jan | 2.40 |
|---|---|
| Feb | 2.40 |
| Mar | 2.60 |
| Apr | 2.60 |
| May | 2.60 |
| Jun | 2.90 |
| Jul | 2.90 |
| Aug | 2.70 |
<figure data-chart="line" data-chart-shape="step">
<figcaption><b>Price of a bag of apples</b><br><span>euros</span></figcaption>
<table>
<tbody>
<tr><th>Jan</th><td>2.40</td></tr>
<tr><th>Feb</th><td>2.40</td></tr>
<tr><th>Mar</th><td>2.60</td></tr>
<tr><th>Apr</th><td>2.60</td></tr>
<tr><th>May</th><td>2.60</td></tr>
<tr><th>Jun</th><td>2.90</td></tr>
<tr><th>Jul</th><td>2.90</td></tr>
<tr><th>Aug</th><td>2.70</td></tr>
</tbody>
</table>
</figure>
Stacked lines
If the figure has data-chart-stack, each line starts on top of the one before it. For stacked lines, an area chart is usually easier to read.
Missing values
If a cell has no number, such as n/a, the line has a gap there.
| Jan | 88 |
|---|---|
| Feb | 74 |
| Mar | n/a |
| Apr | 49 |
| May | 55 |
<figure data-chart="line">
<table>
<tbody>
<tr><th>Jan</th><td>88</td></tr>
<tr><th>Feb</th><td>74</td></tr>
<tr><th>Mar</th><td>n/a</td></tr>
<tr><th>Apr</th><td>49</td></tr>
<tr><th>May</th><td>55</td></tr>
</tbody>
</table>
</figure>
Many rows
With many rows, a line shows fewer numbers, and the names under the chart get smaller or fewer. A row can have a short name for under the chart in data-short. See Many rows.
Years and quarters
If rows next to each other have the same short name, such as the year of each month, the chart shows that name once, from the first of those rows on, with its tick there. So a chart of months can show its years, or its quarters, under the chart. The tooltip, the crosshair and a screen reader still read the full name of each row.
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 |
<figure data-chart="line">
<table>
<tbody>
<tr><th data-short="Q1 ’23">January 2023</th><td>24.0</td></tr>
<tr><th data-short="Q1 ’23">February 2023</th><td>24.6</td></tr>
<tr><th data-short="Q1 ’23">March 2023</th><td>24.3</td></tr>
<tr><th data-short="Q2 ’23">April 2023</th><td>21.4</td></tr>
<!-- …one row per month, 36 in all -->
</tbody>
</table>
</figure>
If the names of the groups still do not fit, only every second, third or more group is shown.
Which values are shown
A value for every row is too much on a line with many rows. With data-chart-values, or the values option for all charts, you choose which values a line or an area chart shows:
| Value | Shows |
|---|---|
auto |
All values if they fit, and else the first, the last, the highest, the lowest and the outliers. The default. |
all |
All values. If they would touch, every second, third or more. |
none |
No values. With data-chart-axis, the values can be read along the axis. |
first last highest lowest outliers |
Only these, any of them, in any order. outliers are the values more than 25% from the trend, as in a summary. |
auto last |
All values if they fit, and else only the ones after auto. |
A row with data-value="show" always shows its value, such as the month a new press came into use. A point is shown where a value is. Each value goes above, below or beside its point, where it is clear of the lines, the names and the other values; a value at a dip tries below first. If there is no such place, it may cross a line, which then stops under the value, but it never covers another value, a name or a point. If two values would still touch, the chart has to omit one of them, with its point. Which one stays goes in this order: a row with data-value="show", then the last value, the first, the highest, the lowest and the outliers.
If the lines have names at their ends and data-chart-values has a set with last, the last number of each line goes between the end of the line and its name. With auto, that happens when the values do not all fit. If lines end close together, their numbers move apart with their names.
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 |
<figure data-chart="line" data-chart-values="auto last">
<table>
<tbody>
<tr><th data-short="Jan ’23">January 2023</th><td>24.0</td></tr>
<tr data-value="show"><th data-short="Mar ’24">March 2024</th><td>28.1</td></tr>
<!-- …one row per month, 36 in all -->
</tbody>
</table>
</figure>
A value that is not shown is in the tooltip of its row, and in the table for screen readers. In print, data-chart-table="auto" prints the table, or the summary if the table is long. See Summary.
Axis and gridlines
By default there is no value axis: the numbers on the points show the values. If you want numbers along the axis, on the left, add data-chart-axis. If you want a light line at each of those numbers, add data-chart-grid. You can add one of them, or both. If you want to add them to every chart, set the axis and grid options to true.
millimetres
| Jan | 84 |
|---|---|
| Feb | 71 |
| Mar | 76 |
| Apr | 58 |
| May | 61 |
| Jun | 47 |
| Jul | 39 |
| Aug | 52 |
<figure 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>
<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>
If a chart has an axis or gridlines, its scale ends on a number of the axis. If you want to set the scale yourself, add data-chart-scale, such as data-chart-scale="0 100". If you want to change how the axis and gridlines look, see Axes and gridlines.
Next
If you want to show the names in a row under the chart, see Legends.