question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sunburst chart calculate radius not counted exists of root area and inner radius

See original GitHub issue

Sunburst 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
the3vercommented, Feb 12, 2020

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/

0reactions
gordonwoodhullcommented, Mar 5, 2020

Fixed by #1655 in 3.2.0 / 4.0.2

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found