Sunburst chart calculate radius not counted exists of root area and inner radius
See original GitHub issueSunburst chart use d3.partition() to calculate the data size. This function reserved first level as root, but this area should not show in sunburst chart. Currently, second level shared this area, so the second level always larger that other level if inner radius is 0. In contrast, if setting inner radius too large, the first few levels cannot show.
So I suggest change the partition size setting to:
var partition = d3.partition()
// .size([2 * Math.PI, _radius * _radius]);
.size([2 * Math.PI, 1]);
partition(hierarchy);
_rootOffset = hierarchy.y1;
And then change radius calculation in buildArcs() to:
.innerRadius(function (d) {
// return d.data.path && d.data.path.length === 1 ? _innerRadius : Math.sqrt(d.y0);
return _innerRadius + ((d.y0 - _rootOffset) / (1 - _rootOffset) * (_radius - _innerRadius));
})
.outerRadius(function (d) {
// return Math.sqrt(d.y1);
return _innerRadius + ((d.y1 - _rootOffset) / (1 - _rootOffset) * (_radius - _innerRadius));
});
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
D3 Sunburst Chart - Nick Coughlin
If we check the root object again we now have starting and ending angles in radians, and inner and outer radius. x and...
Read more >dc.js Class: sunburstChart
Get or set the inner radius of the sunburst chart. If the inner radius is greater than 0px then the sunburst chart will...
Read more >anychart.charts.Sunburst class
Returns pixel bounds of the chart. height(), Height setting. innerRadius(), Inner radius. left(), Left bound setting. margin() ...
Read more >Sunburst – amCharts 5 Documentation
Sunburst. Type class. Builds a sunburst diagram. Click here for more info ... Setting to negative number will mean pixels from outer radius....
Read more >Sunburst Chart in Excel - Example and Explanations
The sunburst chart is part of the hierarchical chart family. It allows you to see at a glance the number of hierarchical levels...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @moononournation your fix is working.
This behavior is actually an issue for us. The arcs of the actual values are beeing “eaten up” by the white inner radius. Or in other words, the radiusses of the value arcs do not adopt to the inner radius (root). Here is a minimal js fiddle : https://jsfiddle.net/the3ver/j1qedybp/14/ (dc.js 3.1.9): Changing the inner radius does not affect the distance of the outer ring from the center. If you set inner radius to 0 the additional space is not distributed to the rings.
We are using version 3.x. unfortuanetly and would need a fix there. Here is a fiddle with dc.js 4, though: https://jsfiddle.net/the3ver/6ysokq1z/6/
Fixed by #1655 in 3.2.0 / 4.0.2