]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
lower default value of grid z index so it draws behind chart elements (#9426)
authorJacco van den Berg <39033624+LeeLenaleee@users.noreply.github.com>
Fri, 16 Jul 2021 15:16:31 +0000 (17:16 +0200)
committerGitHub <noreply@github.com>
Fri, 16 Jul 2021 15:16:31 +0000 (11:16 -0400)
src/core/core.scale.js
test/fixtures/core.scale/border-behind-elements.js [new file with mode: 0644]
test/fixtures/core.scale/border-behind-elements.png [new file with mode: 0644]

index c04899d25a1505a34429a0c9afc671b6a7a06cb1..7eaa656c6ce40829ce1bbddcfd9ccce954081580 100644 (file)
@@ -1620,7 +1620,7 @@ export default class Scale extends Element {
     const me = this;
     const opts = me.options;
     const tz = opts.ticks && opts.ticks.z || 0;
-    const gz = opts.grid && opts.grid.z || 0;
+    const gz = valueOrDefault(opts.grid && opts.grid.z, -1);
 
     if (!me._isVisible() || me.draw !== Scale.prototype.draw) {
       // backward compatibility: draw has been overridden by custom scale
diff --git a/test/fixtures/core.scale/border-behind-elements.js b/test/fixtures/core.scale/border-behind-elements.js
new file mode 100644 (file)
index 0000000..c5d1718
--- /dev/null
@@ -0,0 +1,49 @@
+module.exports = {
+  config: {
+    type: 'bubble',
+    data: {
+      datasets: [
+        {
+          label: '# of Votes',
+          data: [{x: 19, y: 3, r: 3}, {x: 2, y: 2, r: 60}],
+          radius: 100,
+          backgroundColor: 'pink'
+        }
+      ]
+    },
+    options: {
+      plugins: {
+        legend: {
+          display: false
+        }
+      },
+      scales: {
+        y: {
+          ticks: {
+            display: false
+          },
+          grid: {
+            borderColor: 'red',
+            borderWidth: 5
+          }
+        },
+        x: {
+          ticks: {
+            display: false
+          },
+          grid: {
+            borderColor: 'red',
+            borderWidth: 5
+          }
+        }
+      }
+    }
+  },
+
+  options: {
+    canvas: {
+      height: 512,
+      width: 512
+    }
+  }
+};
diff --git a/test/fixtures/core.scale/border-behind-elements.png b/test/fixtures/core.scale/border-behind-elements.png
new file mode 100644 (file)
index 0000000..d3f3771
Binary files /dev/null and b/test/fixtures/core.scale/border-behind-elements.png differ