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

Does not display correctly when canvas width is smaller than canvas height #146

Closed
pieterjandesmedt opened this issue Oct 31, 2014 · 2 comments

Comments

@pieterjandesmedt
Copy link

See the error in this fiddle

Due to the this.canvas.customAttributes.pki path parameter formulas being wrong:

Cx = w / 2 + dx,
Cy = h / 1.25 + dy,

Xo = w / 2 + dx + Ro * Math.cos(alpha),
Yo = h - (h - Cy) + dy - Ro * Math.sin(alpha),
Xi = w / 2 + dx + Ri * Math.cos(alpha),
Yi = h - (h - Cy) + dy - Ri * Math.sin(alpha),

should be

Cx = w / 2 + dx,
Cy = h / 1.25 + dy,

Xo = Cx + Ro * Math.cos(alpha),
Yo = Cy - Ro * Math.sin(alpha),
Xi = Cx + Ri * Math.cos(alpha),
Yi = Cy - Ri * Math.sin(alpha),

because

  • h - (h - Cy) equals Cy
  • Cy is defined as h / 1.25 + dy, which contains the + dy already --> this causes the error
  • Cx = w / 2 + dx is also already defined.

I have not checked if this works for donut gauges.

@Remiz
Copy link

Remiz commented Jan 14, 2015

I confirm this issue. Gage looks weird when width is too small.

@toorshia
Copy link
Owner

Thanks, I've updated code with your formula :)

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

3 participants