plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
17.06k stars 1.87k forks source link

enable rotation of sunburst plots to change starting point #4728

Open bishonen opened 4 years ago

bishonen commented 4 years ago

Hi,

adding the option to decide at which angle the sunburst chart starts would be a nice feature. Currently the first slice is rendered at 90 degrees.

archmoj commented 4 years ago

@bishonen In terms of roadmap, at the moment we aren't planning on working on this for the next few months, but if anyone here works for an organization that has a software budget, we do accept sponsorship for features, which would enable us to build this feature faster :)

thierryVergult commented 4 years ago

+1 for this request.

Moving away from Highcharts, where this option is avaible.

thierryVergult commented 4 years ago

The code to modify the angle is found in ./traces/sunburst/plot.js

        pt.rpx0 = y2rpx(pt.y0);
        pt.rpx1 = y2rpx(pt.y1);
        pt.xmid = (pt.x0 + pt.x1) / 2;
        pt.pxmid = rx2px(pt.rpx1, pt.xmid);
        pt.midangle = -(pt.xmid - Math.PI / 2);
        pt.startangle = -(pt.x0 - Math.PI / 2);
        pt.stopangle = -(pt.x1 - Math.PI / 2);
        pt.halfangle = 0.5 * Math.min(Lib.angleDelta(pt.x0, pt.x1) || Math.PI, Math.PI);
        pt.ring = 1 - (pt.rpx0 / pt.rpx1);
        pt.rInscribed = getInscribedRadiusFraction(pt, trace);

Adding a value (in radians) to x0 & x1 worked for my 1st test

... pt.x0 = pt.x0 + (Math.PI / 2); // adding 90 degrees to x0 pt.x1 = pt.x1 + (Math.PI / 2); // adding 90 degrees to x1

    pt.rpx0 = y2rpx(pt.y0);
    pt.rpx1 = y2rpx(pt.y1);
    pt.xmid = (pt.x0 + pt.x1) / 2;

...

I will explore how to turn this in a configuration option.

gvwilson commented 4 months ago

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

janosh commented 4 months ago

i'd be happy to sponsor this feature with 100 USD

gvwilson commented 4 months ago

THanks @janosh - I'll see if I can find someone to do the work.