Skip to content

Commit

Permalink
Support an array for line chart pointBorderWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Jul 4, 2017
1 parent 225bfd3 commit cc9e88a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/controllers/controller.line.js
Expand Up @@ -137,7 +137,7 @@ module.exports = function(Chart) {

if (!isNaN(custom.borderWidth)) {
borderWidth = custom.borderWidth;
} else if (!isNaN(dataset.pointBorderWidth)) {
} else if (!isNaN(dataset.pointBorderWidth) || helpers.isArray(dataset.pointBorderWidth)) {
borderWidth = helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, borderWidth);
} else if (!isNaN(dataset.borderWidth)) {
borderWidth = dataset.borderWidth;
Expand Down
20 changes: 20 additions & 0 deletions test/specs/controller.line.tests.js
Expand Up @@ -730,4 +730,24 @@ describe('Line controller tests', function() {

expect(point._model.borderWidth).toBe(0);
});

it('should allow an array as the point border width setting', function() {
var chart = window.acquireChart({
type: 'line',
data: {
datasets: [{
data: [10, 15, 0, -4],
label: 'dataset1',
pointBorderWidth: [1, 2, 3, 4]
}],
labels: ['label1', 'label2', 'label3', 'label4']
}
});

var meta = chart.getDatasetMeta(0);
expect(meta.data[0]._model.borderWidth).toBe(1);
expect(meta.data[1]._model.borderWidth).toBe(2);
expect(meta.data[2]._model.borderWidth).toBe(3);
expect(meta.data[3]._model.borderWidth).toBe(4);
});
});

0 comments on commit cc9e88a

Please sign in to comment.