]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix ticks.mirror (#8482)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Sun, 21 Feb 2021 19:27:14 +0000 (21:27 +0200)
committerGitHub <noreply@github.com>
Sun, 21 Feb 2021 19:27:14 +0000 (14:27 -0500)
src/core/core.scale.js
test/fixtures/core.scale/ticks-mirror.js [new file with mode: 0644]
test/fixtures/core.scale/ticks-mirror.png [new file with mode: 0644]

index 10b4140216728134525f41f034fda97d274cb3f8..7a2674d09241765f7f46630ff6ae0572754d567e 100644 (file)
@@ -1524,6 +1524,11 @@ export default class Scale extends Element {
         */
   _computeLabelArea() {
     const me = this;
+
+    if (me.options.ticks.mirror) {
+      return;
+    }
+
     const chart = me.chart;
     const position = me.options.position;
 
@@ -1532,8 +1537,6 @@ export default class Scale extends Element {
     } if (position === 'top' || position === 'bottom') {
       return {top: me.top, left: 0, bottom: me.bottom, right: chart.width};
     }
-
-    return null;
   }
 
   /**
diff --git a/test/fixtures/core.scale/ticks-mirror.js b/test/fixtures/core.scale/ticks-mirror.js
new file mode 100644 (file)
index 0000000..8a54a41
--- /dev/null
@@ -0,0 +1,27 @@
+module.exports = {
+  config: {
+    type: 'line',
+    data: {
+      datasets: [{
+        data: [1, -1, 3],
+      }],
+      labels: ['Label1', 'Label2', 'Label3']
+    },
+    options: {
+      scales: {
+        y: {
+          ticks: {
+            mirror: true
+          }
+        }
+      }
+    }
+  },
+  options: {
+    spriteText: true,
+    canvas: {
+      height: 256,
+      width: 512
+    }
+  }
+};
diff --git a/test/fixtures/core.scale/ticks-mirror.png b/test/fixtures/core.scale/ticks-mirror.png
new file mode 100644 (file)
index 0000000..15a23c2
Binary files /dev/null and b/test/fixtures/core.scale/ticks-mirror.png differ