Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Gap at the right end in an Area chart #5797

Closed
nagix opened this issue Oct 28, 2018 · 0 comments · Fixed by #5880
Closed

[BUG] Gap at the right end in an Area chart #5797

nagix opened this issue Oct 28, 2018 · 0 comments · Fixed by #5880

Comments

@nagix
Copy link
Contributor

nagix commented Oct 28, 2018

There is one pixel width gap at the right end in an Area chart with a category scale. This doesn't happen with other scale types or in 2.6.0 or earlier.

screenshot 2018-10-28 at 11 29 52 pm

Possible Solution

This is caused by the number rounding at

return me.left + Math.round(widthOffset);
and
return me.top + Math.round(heightOffset);

Either chart.chartArea.left or right is not rounded but getPixelForValue in a category scale returns a rounded value, so that causes one pixel gap between the edge of the filled area and the gridline at the right end.

This can be solved by removing Math.round, and actually #4944 fixed the issue by doing so. My question is if we can completely remove number rounding because it should have been introduced for performance optimization. Since chart.chartArea.left is not rounded currently, it needs to be also rounded if we really want optimization, but that rounding every data point causes the original issue in #4944. So, removing number rounding seems to be the right way.

Steps to Reproduce

See https://jsfiddle.net/nagix/qo8mxvfp/

Environment

  • Chart.js version: 2.7.0 - 2.7.3 (No issue in 2.6.0 or earlier)
  • Browser name and version: Chrome, FireFox and Safari
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant