Skip to content

Commit f90737b

Browse files
sunburst rotation
Bringing in suggestions from @alexcjohnson
1 parent b889c94 commit f90737b

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/traces/sunburst/attributes.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,13 @@ module.exports = {
204204
].join(' ')
205205
}),
206206
rotation: {
207-
valType: 'number',
207+
valType: 'angle',
208208
role: 'style',
209-
min: -180,
210-
max: 180,
211209
dflt: 0,
212210
editType: 'plot',
213211
description: [
214-
'Instead of the first slice starting at 3 o\'clock,',
215-
'rotate to some other angle.'
212+
'Rotates the whole diagram counterclockwise by some angle.',
213+
'By default the first slice starts at 3 o\'clock.'
216214
].join(' ')
217215
},
218216
sort: pieAttrs.sort,

src/traces/sunburst/plot.js

+8-4
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; };
@@ -220,10 +228,6 @@ function plotOne(gd, cd, element, transitionOpts) {
220228
s.style('pointer-events', 'all');
221229
});
222230

223-
var extraAngle = trace.rotation * Math.PI / 180;
224-
pt.x0 = pt.x0 + extraAngle;
225-
pt.x1 = pt.x1 + extraAngle;
226-
227231
pt.rpx0 = y2rpx(pt.y0);
228232
pt.rpx1 = y2rpx(pt.y1);
229233
pt.xmid = (pt.x0 + pt.x1) / 2;

0 commit comments

Comments
 (0)