]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix filling between datasets of different lengths
authorSimon Brunel <simonbrunel@users.noreply.github.com>
Sat, 10 Jun 2017 11:52:37 +0000 (13:52 +0200)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sat, 10 Jun 2017 13:44:15 +0000 (09:44 -0400)
src/plugins/plugin.filler.js
test/fixtures/plugin.filler/fill-line-dataset-span.json
test/fixtures/plugin.filler/fill-line-dataset-spline-span.json
test/fixtures/plugin.filler/fill-line-dataset-spline.json
test/fixtures/plugin.filler/fill-line-dataset.json

index c0219a051117146e4f60ea0a1e2d8757bb9d5682..9354e4ed58d8c32b1c681ad4b8c6d00beccead1f 100644 (file)
@@ -19,9 +19,10 @@ module.exports = function(Chart) {
                        var meta = chart.getDatasetMeta(index);
                        var visible = meta && chart.isDatasetVisible(index);
                        var points = (visible && meta.dataset._children) || [];
+                       var length = points.length || 0;
 
-                       return !points.length? null : function(point, i) {
-                               return points[i]._view || null;
+                       return !length? null : function(point, i) {
+                               return (i < length && points[i]._view) || null;
                        };
                },
 
index 7cd4e7c920bc472fcb3619e58e7f92a03754d583..34b4ddc7f5947174af605d9df8d110d467c6f751 100644 (file)
@@ -13,7 +13,7 @@
                 "fill": "+1"
             }, {
                 "backgroundColor": "rgba(0, 0, 255, 0.25)",
-                "data": [0, 2, 0, -2, 0, 2, 0, null, null],
+                "data": [0, 2, 0, -2, 0, 2, 0],
                 "fill": 3
             }, {
                 "backgroundColor": "rgba(255, 0, 255, 0.25)",
index 6f89e62c4bfc4a7ee450be08a80b7801cc3ce31b..a37ce02a90203a1f739829bf03a3f85263efb688 100644 (file)
@@ -13,7 +13,7 @@
                 "fill": "+1"
             }, {
                 "backgroundColor": "rgba(0, 0, 255, 0.25)",
-                "data": [0, 2, 0, -2, 0, 2, 0, null, null],
+                "data": [0, 2, 0, -2, 0, 2, 0],
                 "fill": 3
             }, {
                 "backgroundColor": "rgba(255, 0, 255, 0.25)",
index 55054f1f5b65d8d2275e65f909c5c7c4224a4541..329e7123c097df9b0397aba3cf5f9fb17d7d43b3 100644 (file)
@@ -13,7 +13,7 @@
                 "fill": "+1"
             }, {
                 "backgroundColor": "rgba(0, 0, 255, 0.25)",
-                "data": [0, 2, 0, -2, 0, 2, 0, null, null],
+                "data": [0, 2, 0, -2, 0, 2, 0],
                 "fill": 3
             }, {
                 "backgroundColor": "rgba(255, 0, 255, 0.25)",
index d82bd7440b44e0904a3305b982f6c8ff85c7d3e4..4224b78bcfc7fd30ba126cfd11b90e289c7d99cd 100644 (file)
@@ -13,7 +13,7 @@
                 "fill": "+1"
             }, {
                 "backgroundColor": "rgba(0, 0, 255, 0.25)",
-                "data": [0, 2, 0, -2, 0, 2, 0, null, null],
+                "data": [0, 2, 0, -2, 0, 2, 0],
                 "fill": 3
             }, {
                 "backgroundColor": "rgba(255, 0, 255, 0.25)",