From 60aca7b6be62fc2f5613e3d396fa5e538767fc25 Mon Sep 17 00:00:00 2001 From: Simon Brunel Date: Sat, 10 Jun 2017 13:52:37 +0200 Subject: [PATCH] Fix filling between datasets of different lengths --- src/plugins/plugin.filler.js | 5 +++-- test/fixtures/plugin.filler/fill-line-dataset-span.json | 2 +- .../plugin.filler/fill-line-dataset-spline-span.json | 2 +- test/fixtures/plugin.filler/fill-line-dataset-spline.json | 2 +- test/fixtures/plugin.filler/fill-line-dataset.json | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugins/plugin.filler.js b/src/plugins/plugin.filler.js index c0219a05111..9354e4ed58d 100644 --- a/src/plugins/plugin.filler.js +++ b/src/plugins/plugin.filler.js @@ -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; }; }, diff --git a/test/fixtures/plugin.filler/fill-line-dataset-span.json b/test/fixtures/plugin.filler/fill-line-dataset-span.json index 7cd4e7c920b..34b4ddc7f59 100644 --- a/test/fixtures/plugin.filler/fill-line-dataset-span.json +++ b/test/fixtures/plugin.filler/fill-line-dataset-span.json @@ -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)", diff --git a/test/fixtures/plugin.filler/fill-line-dataset-spline-span.json b/test/fixtures/plugin.filler/fill-line-dataset-spline-span.json index 6f89e62c4bf..a37ce02a902 100644 --- a/test/fixtures/plugin.filler/fill-line-dataset-spline-span.json +++ b/test/fixtures/plugin.filler/fill-line-dataset-spline-span.json @@ -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)", diff --git a/test/fixtures/plugin.filler/fill-line-dataset-spline.json b/test/fixtures/plugin.filler/fill-line-dataset-spline.json index 55054f1f5b6..329e7123c09 100644 --- a/test/fixtures/plugin.filler/fill-line-dataset-spline.json +++ b/test/fixtures/plugin.filler/fill-line-dataset-spline.json @@ -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)", diff --git a/test/fixtures/plugin.filler/fill-line-dataset.json b/test/fixtures/plugin.filler/fill-line-dataset.json index d82bd7440b4..4224b78bcfc 100644 --- a/test/fixtures/plugin.filler/fill-line-dataset.json +++ b/test/fixtures/plugin.filler/fill-line-dataset.json @@ -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)",