Skip to content

Commit

Permalink
Allow line chart to use pointBorderWidth of 0 correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Nov 18, 2016
1 parent 0b4123b commit f7d60c2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/controllers/controller.line.js
Expand Up @@ -139,11 +139,11 @@ module.exports = function(Chart) {
var dataset = this.getDataset();
var custom = point.custom || {};

if (custom.borderWidth) {
if (!isNaN(custom.borderWidth)) {
borderWidth = custom.borderWidth;
} else if (dataset.pointBorderWidth) {
} else if (!isNaN(dataset.pointBorderWidth)) {
borderWidth = helpers.getValueAtIndexOrDefault(dataset.pointBorderWidth, index, borderWidth);
} else if (dataset.borderWidth) {
} else if (!isNaN(dataset.borderWidth)) {
borderWidth = dataset.borderWidth;
}

Expand Down
19 changes: 19 additions & 0 deletions test/controller.line.tests.js
Expand Up @@ -753,4 +753,23 @@ describe('Line controller tests', function() {
expect(point._model.borderWidth).toBe(5.5);
expect(point._model.radius).toBe(4.4);
});

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

var meta = chart.getDatasetMeta(0);
var point = meta.data[0];

expect(point._model.borderWidth).toBe(0);
});
});
17 changes: 17 additions & 0 deletions test/controller.radar.tests.js
Expand Up @@ -452,4 +452,21 @@ describe('Radar controller tests', function() {
expect(point._model.borderWidth).toBe(5.5);
expect(point._model.radius).toBe(4.4);
});

it('should allow pointBorderWidth to be set to 0', function() {
var chart = window.acquireChart({
type: 'radar',
data: {
datasets: [{
data: [10, 15, 0, 4],
pointBorderWidth: 0
}],
labels: ['label1', 'label2', 'label3', 'label4']
}
});

var meta = chart.getDatasetMeta(0);
var point = meta.data[0];
expect(point._model.borderWidth).toBe(0);
});
});

0 comments on commit f7d60c2

Please sign in to comment.