Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAdjust the size of rectRounded/rectRot points to fit the circle with pointRadius #5858
Conversation
|
@nagix awesome! I'm wondering if we could refactor the Could you also compare performance in IE11 and Edge? And out of curiosity, what's the |
This comment has been minimized.
This comment has been minimized.
|
I have added the benchmark results using Chrome, FireFox, IE11 and Edge on Windows 10 PC. The performance is improved for all the tests. Interestingly, there is also huge improvement in Chrome on Windows. It seems that Chrome has some performance problem in The size of |
This comment has been minimized.
This comment has been minimized.
|
It would be good to add a comment to the code explaining it or linking to this PR. If I read the code alone without reading the description in this PR I would not be able to follow it or understand where .516 comes from, etc. |
This comment has been minimized.
This comment has been minimized.
|
I have refactored |
This comment has been minimized.
This comment has been minimized.
|
I have also added a reference to this PR and #5597 to the comment. |
31ae280
to
7f16657
|
Thanks @nagix for the extra benchmarks. I like the new |
This comment has been minimized.
This comment has been minimized.
Yes, for the best performance, I decided not to call |
|
Thanks @nagix |
nagix commentedNov 23, 2018
•
edited
Most of the
pointStyleshapes are inscribed in the circle that has the radius ofpointRadius, but'roundedRect'and'rectRot'shapes are inscribed in the rectangle that is inscribed in the circle and they look relatively smaller than others. To achieve more consistent appearance, this PR adjusts the size of those shapes to fit the circle.This PR also fix the regression introduced by #5319 by removing
ctx.translate()andctx.rotate(), and calculating the absolute coordinates of each rendering point.Chart.js 2.7.3: https://jsfiddle.net/nagix/ye9kcxaf/

This PR: https://jsfiddle.net/nagix/6rnfspu3/

For

'roundedRect', the corner radius is calculated using a new factor of0.516which is derived from the following:Regarding the performance impact, I performed a benchmark using 50,000 random points on my MacBook and Dell laptop. The following charts show the difference from v2.7.3. The rendering time doesn't increase in most of the symbols except for
'rect'with rotation and 'rectRot'. The performance is even better with Chrome in particular.https://jsfiddle.net/nagix/4nkucft6/







Fixes #5839