This repository has been archived by the owner on Sep 17, 2021. It is now read-only.
Fixed #20 - renders single-item pie chart correctly now #45
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.
Fixes #20 so that a single-item pie chart renders correctly now.
This was a bit tricky as it was a bit unexpected that an arc with the same start and ending point renders nothing in svg as opposed to rendering a complete circle (which seems more natural from an end-user standpoint but maybe not natural from a pure mathematical standpoint). This issue is discussed in this StackOverflow question.
The paths-js library which this library depends on directly to provide the svg paths to draw the pie chart doesn't have any special handling for a complete-circle arc either. So, I took the approach of looking specifically for the scenario where there was only 1 data item and substituting react-native-svg
<Circle>
s - one "outer circle" with a radius ofprops.R
and one "inner circle" with a radius ofprops.r
.Along the way I also discovered we weren't probably handling inner radius values of 0 nor fallback logic for either the inner or outer radius. So, I cleaned that up a bit as well.
Also, added a jest test for the single-item pie chart scenario.