Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow spanGaps to be specified on LineOptions #10133

Merged
merged 1 commit into from Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
kurkle marked this conversation as resolved.
Show resolved Hide resolved

### 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
}
}
}
});