From 0b21578a3ada5cc36739cab8af5335bb9be175cf Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sat, 27 Mar 2021 15:00:21 -0400 Subject: [PATCH] Improved alignment of pixels in scales at low widths (#8739) * Improved alignment of pixels in scales at low widths * Undo scale changes --- src/helpers/helpers.canvas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/helpers.canvas.js b/src/helpers/helpers.canvas.js index 0472bddb3..8282b3a94 100644 --- a/src/helpers/helpers.canvas.js +++ b/src/helpers/helpers.canvas.js @@ -102,7 +102,7 @@ export function _longestText(ctx, font, arrayOfThings, cache) { */ export function _alignPixel(chart, pixel, width) { const devicePixelRatio = chart.currentDevicePixelRatio; - const halfWidth = width / 2; + const halfWidth = width !== 0 ? Math.max(width / 2, 0.5) : 0; return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth; } -- 2.47.3