FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix arc border with circumference over 2*PI by kurkle · Pull Request #6215 · chartjs/Chart.js · GitHub

Fix arc border with circumference over 2*PI - #6215

Merged
simonbrunel merged 6 commits into
chartjs:masterfrom
kurkle:arc_border_over_2pi
Apr 30, 2019
Merged

Fix arc border with circumference over 2*PI#6215
simonbrunel merged 6 commits into
chartjs:masterfrom
kurkle:arc_border_over_2pi

Conversation

kurkle commented Apr 18, 2019
edited
Loading

Copy link
Copy Markdown
Member

Fixes: #6171

Demo

Comment thread src/elements/element.arc.js Outdated
simonbrunel added this to the Version 2.9 milestone Apr 18, 2019
etimberg previously approved these changes Apr 20, 2019
Comment thread src/elements/element.arc.js Outdated

ctx.fillStyle = vm.backgroundColor;

if (vm.circumference > Math.PI * 2) {

nagix Apr 24, 2019
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good in case 0 <= circumference <= 2*PI and 2*PI < circumference <= 4*PI, but appearance is not consistent when circumference > 4*PI. How about looping this part (endAngle - startAngle) / (Math.PI * 2) times?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Loop implemented, did some more refactoring to keep CC (and me) happy 😄
Demo updated.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Instead of a loop would doing % 2PI be more efficient?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@etimberg that was my initial approach, but with transparency it is not consistent with circumference > 4*PI.
Not sure if anyone is going to use circumference that high anyway, but now its drawn consistently.

nagix commented Apr 24, 2019

Copy link
Copy Markdown
Contributor

When borderAlign is set to 'inner', the result doesn't look correct because the border appears at next to the end angle instead of at the start angle.

Similarly, when borderAlign is 'center', the border should also be drawn and visible at the the start angle as the background is transparent.

I think we need to fill and stroke arcs multiple times if the circumference is greater than 2*PI. The first arc would have an open path (open at the end edge), the following arcs would have 2 open paths for outer and inner circumferences and the last arc would have an open path again (open at the start edge).

kurkle commented Apr 24, 2019

Copy link
Copy Markdown
Member Author

Fixed drawing of borders. But in 2 steps instead of 3, first fully open full circles and then fully closed partial.
Demo updated.

nagix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for the fix. When borderAlign is 'inner' and the overlap is very small, the result is a bit odd, but I know there is no good way to fix. The other parts look perfect, so I think it's ok now.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Doughnut chart has incorrect border when overful

5 participants


Back | FazBrowse Home | New Git URL