Coder Social home page Coder Social logo

Comments (3)

georgejohnson-us avatar georgejohnson-us commented on June 2, 2024 1

Without seeing your raw data, it could be that any element that has children should NOT have a size property. If parent elements have a size property, their node size will calculate incorrectly. It would be great if the sunburst could automatically discard a "size" property if a node has children.

I used this code to disregard the size attribute if a node has children.
Sunburst()
.data(data3)
.size(function(d) {
if (d.children) {
return null;
} else {
return d.size;
}
})

from sunburst-chart.

schobernoise avatar schobernoise commented on June 2, 2024

So how would I go at it, if I wanted to divide my four root-segments into four equal parts?

from sunburst-chart.

georgejohnson-us avatar georgejohnson-us commented on June 2, 2024

I suppose it would be even better if the size attribute was directly calculated against its parent irregardless of child nodes, but it seems that this tool does it the other way. So the issue request here should go something like this:

Describe the bug:
Node sizes don't calculate in ways that support a hierarchical visualization.

To reproduce:
Create a JSON file where all nodes have size attributes, choose an element that has children and give it a large size value. The children will not cover the parent node - there will be gaps in the visualization. The following workaround code is used to prevent this behavior:
Sunburst()
.data(data3)
.size(function(d) {
if (d.children) {
return null;
} else {
return d.size;
}
})

Hoped for behavior:
Root node should (obviously) always be 100%, each child element from there down should use the size attribute to calculate against its parent node. If no size is given then each element should be spread equally (if there are two children they are each 50%, 4 would get 25%, etc.) across its parent node. If a child element has children with sizes that don't calculate to 100%, then the children should be automatically spread proportionately to get to 100% of the parent.

I can't foresee a use case where a parent element should be larger than the combined size value of the children.

from sunburst-chart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.