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

use arc calculations to render range values #86

Merged
merged 10 commits into from
May 6, 2024

Conversation

rkyle35242
Copy link
Member

@rkyle35242 rkyle35242 commented Apr 30, 2024

Issue reported here: #84.

Ranges are placed evenly across the arc. However, there could be cases where the user wants the ranges to align with the segments. So I'm adding a flag to align the ranges display with the segments.

Before After
image image

if (previousArc) end = previousArc.end + spaceBetweenSegments;

let start = end;
if (arc) start = arc.end;
Copy link
Member Author

Choose a reason for hiding this comment

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

This was very confusing until I realized the start and end are kind of reversed. I believe it's due to the textAnchor enum on the RNSVG Text component.

dakota-kallas

This comment was marked as duplicate.

Copy link

@dakota-kallas dakota-kallas left a comment

Choose a reason for hiding this comment

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

Is there ever a case where someone wouldn't want these to line up with the segments? I am not sure this should be a flag, rather should just be the default behavior to always be aligned with the segments.

I tested out your branch and am getting issues with the first label when the arc is over 180 degrees.
image

const arc = arcs[index];
const previousArc = arcs[index - 1];

let end = 0;

Choose a reason for hiding this comment

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

Suggested change
let end = 0;
let end = arcsStart + index * (arcSegmentDegree + spaceBetweenSegments);

Copy link
Member Author

@rkyle35242 rkyle35242 May 2, 2024

Choose a reason for hiding this comment

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

The end is already calculated in the SegmentedArc component, and duplicating the calculation here might result in deviations if we change it. The initial end should just be the start of the arc rather than 0, as arcs > 180 degrees have a negative degree starting point. Now I'm realizing this was probably an issue on arcs narrower than 180 degrees as well

@rkyle35242
Copy link
Member Author

rkyle35242 commented May 2, 2024

@dakota-kallas while I don't know that there is a use case to have the ranges not aligned with scaled segments, I think it's possible that someone would want to. I'm in favor of more control over less here.

That being said, I'll look into the > 180 degrees label issue you noted and update the "alignRangesWithSegments" to default to true so it's used more as an override

Copy link

@dakota-kallas dakota-kallas left a comment

Choose a reason for hiding this comment

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

Great work!

@@ -27,6 +27,7 @@ export const SegmentedArc = ({
rangesTextStyle = styles.rangeTextStyle,
capInnerColor = '#28E037',
capOuterColor = '#FFFFFF',
alignRangesWithSegments = true,

Choose a reason for hiding this comment

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

true as the default is a good idea. It was a bit confusing before why we would want to default to false.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had a 50/50 shot of getting it right 😉

@rkyle35242 rkyle35242 merged commit 1637c59 into development May 6, 2024
3 checks passed
@rkyle35242 rkyle35242 deleted the fix-ranges-display-when-arcDegreeScale-used branch May 6, 2024 14:26
@jkhusanov jkhusanov mentioned this pull request May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants