From 0507021b2b8814c80261e4c2ff4363a4b5918414 Mon Sep 17 00:00:00 2001 From: Andrew Sand <140562305+asand2113@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:22:03 -0500 Subject: [PATCH 1/3] Fix label clipping issues when rotating --- src/core/core.scale.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 3265e103d1a..77d1346da05 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -1565,7 +1565,7 @@ export default class Scale extends Element { const ctx = this.ctx; const area = this._computeLabelArea(); - if (area) { + if (area && this.labelRotation <= 90) { clipArea(ctx, area); } @@ -1578,7 +1578,7 @@ export default class Scale extends Element { renderText(ctx, label, 0, y, tickFont, renderTextOptions); } - if (area) { + if (area && this.labelRotation <= 90) { unclipArea(ctx); } } From 690789b525b1b954d0ef0d8a20e6690778178720 Mon Sep 17 00:00:00 2001 From: Andrew Sand <140562305+asand2113@users.noreply.github.com> Date: Mon, 29 Apr 2024 21:24:54 -0500 Subject: [PATCH 2/3] Implemented rotation fix --- src/helpers/helpers.canvas.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/helpers/helpers.canvas.ts b/src/helpers/helpers.canvas.ts index a959d1dea1d..5ac6a483087 100644 --- a/src/helpers/helpers.canvas.ts +++ b/src/helpers/helpers.canvas.ts @@ -456,6 +456,11 @@ export function renderText( ctx.save(); ctx.font = font.string; + + if (opts.rotation < -1 * (Math.PI / 2) && opts.rotation > -1 * Math.PI) { + opts.rotation = opts.rotation - Math.PI; + } + setRenderOpts(ctx, opts); for (i = 0; i < lines.length; ++i) { From dfb48f5010a1326f19676d9e28aac2af68c6c3c8 Mon Sep 17 00:00:00 2001 From: Andrew Sand <140562305+asand2113@users.noreply.github.com> Date: Mon, 29 Apr 2024 21:33:56 -0500 Subject: [PATCH 3/3] Appease testing requirements --- src/helpers/helpers.canvas.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/helpers.canvas.ts b/src/helpers/helpers.canvas.ts index 5ac6a483087..3fb24b8abe5 100644 --- a/src/helpers/helpers.canvas.ts +++ b/src/helpers/helpers.canvas.ts @@ -460,7 +460,7 @@ export function renderText( if (opts.rotation < -1 * (Math.PI / 2) && opts.rotation > -1 * Math.PI) { opts.rotation = opts.rotation - Math.PI; } - + setRenderOpts(ctx, opts); for (i = 0; i < lines.length; ++i) {