From: Jukka Kurkela Date: Sun, 21 Feb 2021 19:27:14 +0000 (+0200) Subject: Fix ticks.mirror (#8482) X-Git-Tag: v3.0.0-beta.12~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5285735c0fc6c7ebbe764dbaffa6b270f13a8e19;p=thirdparty%2FChart.js.git Fix ticks.mirror (#8482) --- diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 10b414021..7a2674d09 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -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 index 000000000..8a54a41d1 --- /dev/null +++ b/test/fixtures/core.scale/ticks-mirror.js @@ -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 index 000000000..15a23c2f1 Binary files /dev/null and b/test/fixtures/core.scale/ticks-mirror.png differ