Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@uson1x
Copy link

@uson1x uson1x commented Mar 6, 2025

Hey

Thank you for your great work on this library.

I saw a few innerRadius sunburst PRs and decided to make a fresh version with a storyboard for you.

Please, let me know if you need to change anything in order to get this PR to be ready to be merged. I'd be happy to rewrite the PR as needed.

Right now we are pressed to use a custom version of nivo because in our project we need to control the innerRadius, but it would be so much easier to work with if it was in the main repository.

Thank you for taking a look at it!

Fixes #1649

PS: to give credit, this is based on #2219

@vercel
Copy link

vercel bot commented Mar 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nivo ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2025 9:07pm
nivo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2025 9:07pm

@plouc
Copy link
Owner

plouc commented Mar 16, 2025

@uson1x, I reviewed the previous PR as it already came from another PR 😅
I think you could submit a PR once the other one is merged, with the added story.

@plouc
Copy link
Owner

plouc commented Apr 14, 2025

As the previous one seems inactive, we should probably go for yours instead.

id = defaultProps.id,
value = defaultProps.value,
innerRadius = defaultProps.innerRadius,
renderRootNode = defaultProps.renderRootNode,
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think we should use the same rendering as for the arcs for the root node, it generates a shape that doesn't really make sense:

CleanShot 2025-04-18 at 21 34 05@2x

Which means it cannot have a color, interactivity doesn't work...

Copy link
Author

Choose a reason for hiding this comment

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

I think there was a bug, innerRadius was used instead of innerRadiusOffset
here
this resulted in 0.4 radius.

Fixed now, but, please, let me know if you implied a different approach / mode edits

Copy link
Owner

Choose a reason for hiding this comment

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

It's a bit better, but I think using an arc doesn't work very well tbh.
When enabling/disabling the root node, we can clearly see that the shape for the root node isn't a circle but more like a donut, since it's an arc of 360 degrees.
While the donut shape isn't necessarily critical, the impact it has on the position of the root node label is IMHO, the text should be at the center.
An option (and a bit of a hack) would be to adjust computeArcCenter so that it handles arcs of 360 deg with an inner radius of 0 differently (and arcLabelsRadiusOffset should probably be ignored for this case). That's probably the easiest option.

Copy link
Owner

Choose a reason for hiding this comment

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

If we go for this approach, we should test the position of the text in the root node, and also make sure that a ring of 360 deg still behave as before.

@uson1x uson1x force-pushed the uson1x/add-inner-radius-to-sunburst branch from ed8ed35 to 38f6979 Compare May 13, 2025 14:07
@vercel
Copy link

vercel bot commented May 13, 2025

@uson1x is attempting to deploy a commit to the plouc's projects Team on Vercel.

A member of the Team first needs to authorize it.

@uson1x uson1x force-pushed the uson1x/add-inner-radius-to-sunburst branch from 38f6979 to 3817b8a Compare May 13, 2025 14:10
@uson1x uson1x force-pushed the uson1x/add-inner-radius-to-sunburst branch from 3817b8a to 5a55c73 Compare May 13, 2025 20:15
Copy link
Author

@uson1x uson1x left a comment

Choose a reason for hiding this comment

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

Hi @plouc

Thanks a lot for the review, I have hopefully addressed the feedback.
Please, let me know if I missed something.

id = defaultProps.id,
value = defaultProps.value,
innerRadius = defaultProps.innerRadius,
renderRootNode = defaultProps.renderRootNode,
Copy link
Author

Choose a reason for hiding this comment

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

I think there was a bug, innerRadius was used instead of innerRadiusOffset
here
this resulted in 0.4 radius.

Fixed now, but, please, let me know if you implied a different approach / mode edits


const innerRadiusOffset = radius * Math.min(innerRadius, 1)

const maxDepth = Math.max(...sortedNodes.map(n => n.depth))
Copy link
Owner

Choose a reason for hiding this comment

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

As nodes are already sorted, we can simply get the depth of the last one, should be faster for larger datasets. We just need to handle the case where there are no nodes.

@plouc
Copy link
Owner

plouc commented May 13, 2025

@uson1x, I think you forgot to run make fmt.

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.

Sunburst: add props.innerRadius similar to how Pie works

2 participants