Lines, gaps and segments
Missing values
A null in the data of a line or an area is a missing value. gaps says how to draw it:
gaps | Draws |
|---|---|
break (default) | the line stops, and starts again after the gap; an isolated point keeps its dot |
join | the points on each side of the gap are linked |
zero | the missing value at 0, and 0 stays inside the axis |
series: [
{ name: 'Sensor A', data: [12, null, 15, 16, null, 14], gaps: 'join' },
{ name: 'Sensor B', data: [8, 9, null, null, 11, 10] }, // break
{ name: 'Sales', kind: 'area', data: [4, 6, null, 5], gaps: 'zero' },
]With gaps: 'zero', the value stays missing for the tooltip, the keyboard and the table: only the drawing shows 0. Bands (kind: 'band') follow gaps too, on both of their lines.
Segments
segments draws part of a line another way, by index in the series: from the point at from to the one at to (the last one when to is left out).
{
name: 'Sales',
data: [62, 70, 74, 81, 77, 86, 90, 84, 92, 95, 99, 104],
segments: [{ from: 8, dashed: true, label: 'forecast' }],
}| Field | Does |
|---|---|
from, to | first and last index of the stretch |
dashed | dashes; the dots of the stretch are left out, as on a dashed line |
color | colour of the line, of its dots and of the area under it |
opacity | opacity of the line, and of the area under it |
label | said after the name of the series in the tooltip and to screen readers: Sales (forecast), Dec: 104 |
The line is drawn once for the whole series and once for each segment, each copy kept to its stretch: the curve is the same on both sides of a change, with curve: 'linear', 'smooth' or 'step', and so is the area under it.
Segments follow the zoom and thin: they are counted in the indexes of the whole series. They should not overlap; when they do, the last one listed wins for the dots and the tooltip.
The SVG and PNG exports keep them.