From: Simon Brunel Date: Sat, 10 Jun 2017 11:52:37 +0000 (+0200) Subject: Fix filling between datasets of different lengths X-Git-Tag: v2.7.0~1^2~92 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e581148486c310ff96c777e32701dcae3df8a57;p=thirdparty%2FChart.js.git Fix filling between datasets of different lengths --- diff --git a/src/plugins/plugin.filler.js b/src/plugins/plugin.filler.js index c0219a051..9354e4ed5 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 7cd4e7c92..34b4ddc7f 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 6f89e62c4..a37ce02a9 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 55054f1f5..329e7123c 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 d82bd7440..4224b78bc 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)",