]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Allow spanGaps to be specified on LineOptions (#10133)
authorEvert Timberg <evert.timberg@gmail.com>
Sun, 6 Feb 2022 20:11:02 +0000 (15:11 -0500)
committerGitHub <noreply@github.com>
Sun, 6 Feb 2022 20:11:02 +0000 (15:11 -0500)
docs/charts/line.md
docs/charts/radar.md
types/index.esm.d.ts
types/tests/controllers/line_span_gaps.ts [new file with mode: 0644]

index 22a7a349d741bfb3cfbf5b0fad824e2f79e10db4..f4331f9706972ab9dd3f4d8481ac7703e4d359f0 100644 (file)
@@ -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
 
index 5508b2abf6b1aa6c71bad3935805d0bbf649b7a9..5a5890ca7ada60a0e337939fec8d113f51873dc9 100644 (file)
@@ -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
 
index 14a26d596677cf88b78f245d8c514e2d28afacb0..21e6b839e00a220fd03e7b5a2686f6326aacb2ed 100644 (file)
@@ -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>,
diff --git a/types/tests/controllers/line_span_gaps.ts b/types/tests/controllers/line_span_gaps.ts
new file mode 100644 (file)
index 0000000..040c9a9
--- /dev/null
@@ -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
+      }
+    }
+  }
+});