]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Improved alignment of pixels in scales at low widths (#8739)
authorEvert Timberg <evert.timberg+github@gmail.com>
Sat, 27 Mar 2021 19:00:21 +0000 (15:00 -0400)
committerGitHub <noreply@github.com>
Sat, 27 Mar 2021 19:00:21 +0000 (15:00 -0400)
* Improved alignment of pixels in scales at low widths
* Undo scale changes

src/helpers/helpers.canvas.js

index 0472bddb31b09029397516ab0b5f355b661475f9..8282b3a94255681a2f310ec5ded741b74bc8595e 100644 (file)
@@ -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;
 }