]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
When `gridLines.display` is false, the axis border is still drawn (#7014)
authorEvert Timberg <evert.timberg+github@gmail.com>
Mon, 27 Jan 2020 22:57:31 +0000 (17:57 -0500)
committerGitHub <noreply@github.com>
Mon, 27 Jan 2020 22:57:31 +0000 (17:57 -0500)
src/core/core.scale.js

index 8941c14e0ae85006728156ead79724831347e2c3..33ea3ec7e123cb78ac46b7471a0f3ca8e3c18e58 100644 (file)
@@ -1161,11 +1161,6 @@ class Scale extends Element {
        _drawGrid(chartArea) {
                const me = this;
                const gridLines = me.options.gridLines;
-
-               if (!gridLines.display) {
-                       return;
-               }
-
                const ctx = me.ctx;
                const chart = me.chart;
                let context = {
@@ -1176,34 +1171,36 @@ class Scale extends Element {
                const items = me._gridLineItems || (me._gridLineItems = me._computeGridLineItems(chartArea));
                let i, ilen;
 
-               for (i = 0, ilen = items.length; i < ilen; ++i) {
-                       const item = items[i];
-                       const width = item.width;
-                       const color = item.color;
-
-                       if (width && color) {
-                               ctx.save();
-                               ctx.lineWidth = width;
-                               ctx.strokeStyle = color;
-                               if (ctx.setLineDash) {
-                                       ctx.setLineDash(item.borderDash);
-                                       ctx.lineDashOffset = item.borderDashOffset;
-                               }
+               if (gridLines.display) {
+                       for (i = 0, ilen = items.length; i < ilen; ++i) {
+                               const item = items[i];
+                               const width = item.width;
+                               const color = item.color;
+
+                               if (width && color) {
+                                       ctx.save();
+                                       ctx.lineWidth = width;
+                                       ctx.strokeStyle = color;
+                                       if (ctx.setLineDash) {
+                                               ctx.setLineDash(item.borderDash);
+                                               ctx.lineDashOffset = item.borderDashOffset;
+                                       }
 
-                               ctx.beginPath();
+                                       ctx.beginPath();
 
-                               if (gridLines.drawTicks) {
-                                       ctx.moveTo(item.tx1, item.ty1);
-                                       ctx.lineTo(item.tx2, item.ty2);
-                               }
+                                       if (gridLines.drawTicks) {
+                                               ctx.moveTo(item.tx1, item.ty1);
+                                               ctx.lineTo(item.tx2, item.ty2);
+                                       }
 
-                               if (gridLines.drawOnChartArea) {
-                                       ctx.moveTo(item.x1, item.y1);
-                                       ctx.lineTo(item.x2, item.y2);
-                               }
+                                       if (gridLines.drawOnChartArea) {
+                                               ctx.moveTo(item.x1, item.y1);
+                                               ctx.lineTo(item.x2, item.y2);
+                                       }
 
-                               ctx.stroke();
-                               ctx.restore();
+                                       ctx.stroke();
+                                       ctx.restore();
+                               }
                        }
                }