]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Use the correct base for linear scales. This gives the correct fill for lines and... 1180/head
authorEvert Timberg <evert.timberg@gmail.com>
Mon, 8 Jun 2015 23:03:47 +0000 (19:03 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Mon, 8 Jun 2015 23:03:47 +0000 (19:03 -0400)
src/Chart.Line.js
src/Chart.Radar.js
src/Chart.Scatter.js

index 6598d8d1309f9a326719978168f5e134e2234d6a..c715855ed466525c9c8e957966000fa6554b0fc3 100644 (file)
             // Update the lines
             this.eachDataset(function(dataset, datasetIndex) {
                 var yScale = this.scales[dataset.yAxisID];
+                var scaleBase;
+
+                if (yScale.min < 0 && yScale.max < 0) {
+                    scaleBase = yScale.getPixelForValue(yScale.max);
+                } else if (yScale.min > 0 && yScale.max > 0) {
+                    scaleBase = yScale.getPixelForValue(yScale.min);
+                } else {
+                    scaleBase = yScale.getPixelForValue(0);
+                }
 
                 helpers.extend(dataset.metaDataset, {
                     // Utility
                         // Scale
                         scaleTop: yScale.top,
                         scaleBottom: yScale.bottom,
-                        scaleZero: yScale.getPixelForValue(0),
+                        scaleZero: scaleBase,
                     },
                 });
 
index 5f58cce7e545f727840555d3d723e6b4d5ddd408..cb2d819914d37b2530de1f8345da04a3e291fb43 100644 (file)
 
             // Update the lines
             this.eachDataset(function(dataset, datasetIndex) {
+                var scaleBase;
+
+                if (this.scale.min < 0 && this.scale.max < 0) {
+                    scaleBase = this.scale.getPointPosition(0, this.scale.max);
+                } else if (this.scale.min > 0 && this.scale.max > 0) {
+                    scaleBase = this.scale.getPointPosition(0, this.scale.min);
+                } else {
+                    scaleBase = this.scale.getPointPosition(0, 0);
+                }
+
                 helpers.extend(dataset.metaDataset, {
                     // Utility
                     _datasetIndex: datasetIndex,
                         // Scale
                         scaleTop: this.scale.top,
                         scaleBottom: this.scale.bottom,
-                        scaleZero: this.scale.getPointPosition(0),
+                        scaleZero: scaleBase,
                     },
                 });
 
index 09f2b643f4740425a7deaf355b4d003fdb34da18..c32b876a49be366a61be868bc9648b260ba4b4da 100644 (file)
             // Update the lines
             this.eachDataset(function(dataset, datasetIndex) {
                 var yScale = this.scales[dataset.yAxisID];
+                var scaleBase;
+
+                if (yScale.min < 0 && yScale.max < 0) {
+                    scaleBase = yScale.getPixelForValue(yScale.max);
+                } else if (yScale.min > 0 && yScale.max > 0) {
+                    scaleBase = yScale.getPixelForValue(yScale.min);
+                } else {
+                    scaleBase = yScale.getPixelForValue(0);
+                }
 
                 helpers.extend(dataset.metaDataset, {
                     // Utility
                         // Scale
                         scaleTop: yScale.top,
                         scaleBottom: yScale.bottom,
-                        scaleZero: yScale.getPixelForValue(0),
+                        scaleZero: scaleBase,
                     },
                 });