Skip to content

Commit 0b21578

Browse files
authored
Improved alignment of pixels in scales at low widths (#8739)
* Improved alignment of pixels in scales at low widths * Undo scale changes
1 parent b2c7baf commit 0b21578

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/helpers/helpers.canvas.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function _longestText(ctx, font, arrayOfThings, cache) {
102102
*/
103103
export function _alignPixel(chart, pixel, width) {
104104
const devicePixelRatio = chart.currentDevicePixelRatio;
105-
const halfWidth = width / 2;
105+
const halfWidth = width !== 0 ? Math.max(width / 2, 0.5) : 0;
106106
return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;
107107
}
108108

0 commit comments

Comments
 (0)