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

TextHeight calculation can be improved #4

Closed
av01d opened this issue Apr 21, 2020 · 2 comments
Closed

TextHeight calculation can be improved #4

av01d opened this issue Apr 21, 2020 · 2 comments

Comments

@av01d
Copy link

av01d commented Apr 21, 2020

Line 243 of chartjs-gauge.js measures text height like this:

var textHeight = ctx.measureText('M').width;

This works fine for some fonts, but not so much for other (f.e. Google) fonts. A better method is:

var textHeight = Math.max(ctx.measureText('m').width, ctx.measureText('\uFF37').width);

Now you need to change the default padding to:

padding: { top: 5, right: 5, bottom: 10, left: 5 }

In my tests (I tested with a LOT of Google fonts), these small changes result in a much better design for the needle-value-box.

haiiaaa pushed a commit that referenced this issue Apr 23, 2020
@haiiaaa
Copy link
Owner

haiiaaa commented Apr 23, 2020

Thanks! Try version 0.1.2

@haiiaaa haiiaaa closed this as completed Apr 23, 2020
@av01d
Copy link
Author

av01d commented Apr 23, 2020

Perfect, looks much better. Thank you!

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

No branches or pull requests

2 participants