feat: allow full circle in piechart #237
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solves #186
Explanation About What Code Achieves:
The PR adds a full circle check to pie chart and donut chart, this is required when a single data point is given to these charts, or when all but one data points have the value zero.
Using the SVGs arc path, one can draw 99.999% of the circle but not a complete circle, this doesn't work because the starting point and ending point of the arc is the same for a circle, so I guess the browser does not bother to draw the SVG, it's similar to drawing a line from (10, 10) to (10, 10) you get no line. Normally it would be wise to use the
<circle>
tag, but that may require bigger changes and can be a part of a different release, so right now we use a clever hack to solve this problem.The
d
attribute will accept and draw all validpath command
strings, The trick is to have two arcs, the second one picking up where the first left off and get back to the original arc start point. [ref]Screenshots/GIFs:
Previously as mentioned here #186 the chart would not render at all. After the fix, the rendering in either cases works fine: