Skip to content

Commit

Permalink
Allow spanGaps to be specified on LineOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Feb 6, 2022
1 parent aebbb5a commit 371f006
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/charts/line.md
Expand Up @@ -135,7 +135,7 @@ The style of the line can be controlled with the following properties:
| `showLine` | If false, the line is not drawn for this dataset.
| `spanGaps` | If true, lines will be drawn between points with no or null data. If false, points with `null` data will create a break in the line. Can also be a number specifying the maximum gap length to span. The unit of the value depends on the scale used.

If the value is `undefined`, `showLine` and `spanGaps` fallback to the associated [chart configuration options](#configuration-options). The rest of the values fallback to the associated [`elements.line.*`](../configuration/elements.md#line-configuration) options.
If the value is `undefined`, the values fallback to the associated [`elements.line.*`](../configuration/elements.md#line-configuration) options.

### Interactions

Expand Down
2 changes: 1 addition & 1 deletion docs/charts/radar.md
Expand Up @@ -150,7 +150,7 @@ The style of the line can be controlled with the following properties:
| `tension` | Bezier curve tension of the line. Set to 0 to draw straight lines.
| `spanGaps` | If true, lines will be drawn between points with no or null data. If false, points with `null` data will create a break in the line.

If the value is `undefined`, `spanGaps` fallback to the associated [chart configuration options](#configuration-options). The rest of the values fallback to the associated [`elements.line.*`](../configuration/elements.md#line-configuration) options.
If the value is `undefined`, the values fallback to the associated [`elements.line.*`](../configuration/elements.md#line-configuration) options.

### Interactions

Expand Down
4 changes: 4 additions & 0 deletions types/index.esm.d.ts
Expand Up @@ -1787,6 +1787,10 @@ export interface LineOptions extends CommonElementOptions {
* Both line and radar charts support a fill option on the dataset object which can be used to create area between two datasets or a dataset and a boundary, i.e. the scale origin, start or end
*/
fill: FillTarget | ComplexFillTarget;
/**
* If true, lines will be drawn between points with no or null data. If false, points with NaN data will create a break in the line. Can also be a number specifying the maximum gap length to span. The unit of the value depends on the scale used.
*/
spanGaps: boolean | number;

segment: {
backgroundColor: Scriptable<Color|undefined, ScriptableLineSegmentContext>,
Expand Down
32 changes: 32 additions & 0 deletions types/tests/controllers/line_span_gaps.ts
@@ -0,0 +1,32 @@
import { Chart } from '../../index.esm';

const chart = new Chart('id', {
type: "line",
data: {
datasets: [
{
label: "Cats",
data: [],
}
]
},
options: {
elements: {
line: {
spanGaps: true
}
},
scales: {
x: {
type: "linear",
min: 1,
max: 10
},
y: {
type: "linear",
min: 0,
max: 50
}
}
}
});

0 comments on commit 371f006

Please sign in to comment.