Skip to content

Commit

Permalink
Improved alignment of pixels in scales at low widths (#8739)
Browse files Browse the repository at this point in the history
* Improved alignment of pixels in scales at low widths
* Undo scale changes
  • Loading branch information
etimberg authored Mar 27, 2021
1 parent b2c7baf commit 0b21578
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers/helpers.canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0b21578

Please sign in to comment.