Improved alignment of pixels in scales at low widths (#8739)

* Improved alignment of pixels in scales at low widths
* Undo scale changes
This commit is contained in:
Evert Timberg 2021-03-27 15:00:21 -04:00 committed by GitHub
parent b2c7baf10d
commit 0b21578a3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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;
}