From: Evert Timberg Date: Sat, 27 Mar 2021 19:00:21 +0000 (-0400) Subject: Improved alignment of pixels in scales at low widths (#8739) X-Git-Tag: v3.0.0-rc.6~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b21578a3ada5cc36739cab8af5335bb9be175cf;p=thirdparty%2FChart.js.git Improved alignment of pixels in scales at low widths (#8739) * Improved alignment of pixels in scales at low widths * Undo scale changes --- 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; }