]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Allow line chart to use pointBorderWidth of 0 correctly
authoretimberg <evert.timberg@gmail.com>
Mon, 14 Nov 2016 01:38:50 +0000 (20:38 -0500)
committerEvert Timberg <evert.timberg+github@gmail.com>
Fri, 18 Nov 2016 02:05:47 +0000 (21:05 -0500)
src/controllers/controller.line.js
test/controller.line.tests.js
test/controller.radar.tests.js

index 59d097b1be79ec54e959d791c426c1487c00c63e..23d4eedc4029d9ecb739f720a567461ffbdfe9ce 100644 (file)
@@ -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;
                        }
 
index 3c66b268ec07572bac4dd9ee038b79bd2ef66220..f15c693703ba75dc1057d92ab5755e3cbc962db7 100644 (file)
@@ -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);
+       });
 });
index b3ee711e16a9fdf2437c57f7f72c8e15ee807d5e..4b9c1f696dc271228cc532bdcb09e5e19ac2f1aa 100644 (file)
@@ -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);
+       });
 });