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

Improve linear tick generators collision estimation #8983

Merged
merged 4 commits into from Apr 28, 2021

Conversation

kurkle
Copy link
Member

@kurkle kurkle commented Apr 27, 2021

Resolves #8982

Roughly estimate the space needed for min/max tick in scale units.

  • scale_range / (width / font.lineHeight / 0.7) * number_of_digits for horizontal,
  • scale_range / (height / fint.lineHeight) for vertical

I'm sure this won't work with all fonts, but its a lot closer to the truth than previous estimation, which is based on the number of spaced between ticks, and does not take the font or chart dimensions into account at all.

0.7 is a quick estimation on the width/height ratio of a digit in average font.

@kurkle kurkle marked this pull request as draft April 27, 2021 07:22
@kurkle kurkle changed the title Increase distance to min/max tick to 1/3 space Improve linear tick generators collision estimation Apr 28, 2021
@kurkle kurkle marked this pull request as ready for review April 28, 2021 07:32
@kurkle
Copy link
Member Author

kurkle commented Apr 28, 2021

Filename Size Change
dist/chart.esm.js 69.8 kB +122 B (0%)
dist/chart.js 88.5 kB +126 B (0%)
dist/chart.min.js 63.1 kB +99 B (0%)

Copy link
Member

@etimberg etimberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Only risk is if the font size is scriptable, the heuristic breaks down, but that's a very slow case to deal with.

@etimberg etimberg added this to the Version 3.2.1 milestone Apr 28, 2021
@etimberg etimberg merged commit 44e62e7 into chartjs:master Apr 28, 2021
@kurkle kurkle deleted the linear-gen-skip branch May 30, 2021 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After zooming sometimes Y axis labels getting over lapping
2 participants