Skip to content

Commit dadcd06

Browse files
authored
Merge pull request #5171 from thierryVergult/sunburstRotation
sunburst Rotation
2 parents 9a88f84 + cc055fa commit dadcd06

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/traces/sunburst/attributes.js

+10
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ module.exports = {
203203
'this option won\'t have any effect and `insidetextfont` would be used.'
204204
].join(' ')
205205
}),
206+
rotation: {
207+
valType: 'angle',
208+
role: 'style',
209+
dflt: 0,
210+
editType: 'plot',
211+
description: [
212+
'Rotates the whole diagram counterclockwise by some angle.',
213+
'By default the first slice starts at 3 o\'clock.'
214+
].join(' ')
215+
},
206216
sort: pieAttrs.sort,
207217

208218
domain: domainAttrs({name: 'sunburst', trace: true, editType: 'calc'})

src/traces/sunburst/defaults.js

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
7575

7676
coerce('sort');
7777

78+
coerce('rotation');
79+
7880
handleDomainDefaults(traceOut, layout, coerce);
7981

8082
// do not support transforms for now

src/traces/sunburst/plot.js

+8
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ function plotOne(gd, cd, element, transitionOpts) {
150150
// filter out slices that won't show up on graph
151151
sliceData = sliceData.filter(function(pt) { return pt.y1 <= cutoff; });
152152

153+
if(trace.rotation && trace.rotation !== 'auto') {
154+
var extraAngle = trace.rotation * Math.PI / 180;
155+
sliceData.forEach(function(pt) {
156+
pt.x0 += extraAngle;
157+
pt.x1 += extraAngle;
158+
});
159+
}
160+
153161
// partition span ('y') to sector radial px value
154162
var maxY = Math.min(maxHeight, maxDepth);
155163
var y2rpx = function(y) { return (y - yOffset) / maxY * rMax; };

0 commit comments

Comments
 (0)