Skip to content

Commit

Permalink
Fix filling between datasets of different lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrunel committed Jun 10, 2017
1 parent 9e6a611 commit 60aca7b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/plugins/plugin.filler.js
Expand Up @@ -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;
};
},

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/plugin.filler/fill-line-dataset-span.json
Expand Up @@ -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)",
Expand Down
Expand Up @@ -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)",
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/plugin.filler/fill-line-dataset-spline.json
Expand Up @@ -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)",
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/plugin.filler/fill-line-dataset.json
Expand Up @@ -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)",
Expand Down

0 comments on commit 60aca7b

Please sign in to comment.