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] polarArea angleLines don't align with data borders #5907

Closed
custompro12 opened this issue Dec 11, 2018 · 6 comments
Closed

[BUG] polarArea angleLines don't align with data borders #5907

custompro12 opened this issue Dec 11, 2018 · 6 comments
Milestone

Comments

@custompro12
Copy link

Expected Behavior

Enabling the angleLines for a polarArea type chart should draw angleLines that align with the borders of a data segment.

Current Behavior

Data segment borders appear to be rendering at the correct (default) startAngle, but angleLines of the chart are about -1 degree off.

Possible Solution

Not a solution but my current workaround is this:
Since you can't change the startAngle of the angleLines, instead I change the options.startAngle of the polar area chart data to -0.509 * Math.PI (which makes it crooked, but aligned with the angleLines) and then also set a CSS transform (of transform: rotate(1.5deg)) onto the canvas element itself to rotate the chart back to vertical. (See commented out parts of the jsfiddle)
Charts exported with toBase64Image() are still crooked, since the CSS doesn't apply to them.

Steps to Reproduce (for bugs)

https://jsfiddle.net/8tn903pj/

Context

I need to be able to identify empty data segments on the polar area chart, so I need to show the angleLines.

Environment

  • Chart.js version: ^2.7.3
  • Browser name and version:Chrome 70/71 and Firefox 63/64
@nagix
Copy link
Contributor

nagix commented Dec 11, 2018

startAngle option is supposed to be in radians and to start from the right of the circle, but it is interpreted as being in degrees and starting from the top of the circle here:

var startAngle = this.chart.options && this.chart.options.startAngle ?
this.chart.options.startAngle :
0;
var startAngleRadians = startAngle * Math.PI * 2 / 360;

@custompro12
Copy link
Author

Thanks for the hint @nagix. It does seem that the entire issue is isolated to the scale.radialLinear.js file as the arc is being drawn properly. My new workaround is to just set startAngleRadians = 0 on line 457. This is better than the CSS fix I had before as it allows toBase64Image() to work correctly.

@custompro12
Copy link
Author

I see the related #5919 is closed. But it looks like the issue I opened is still present in 2.8.0?

Updated Fiddle to 2.8.0:
https://jsfiddle.net/3cfzk6um/

@snio89
Copy link

snio89 commented Oct 17, 2019

Workaround: Instead of using -Math.PI/2 as startAngle, use 2 * Math.PI * 1891 - Math.PI/2
(basic idea: 2 * Math.PI * 1891 - Math.PI/2 is approximately same as 360 * 33)

This solution works well but makes little time-lag.

@custompro12
Copy link
Author

Updated Fiddle to 2.9.3:
https://jsfiddle.net/wo3c9d0j/

@etimberg etimberg added this to the Version 3.0 milestone May 25, 2020
@etimberg
Copy link
Member

Good news! This appears fixed in v3.0.0-alpha. As part of v3, the startAngle setting has been normalized and now defaults to 0. https://jsfiddle.net/q6mbjny4/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants