Skip to content

Commit

Permalink
Merge pull request #5171 from thierryVergult/sunburstRotation
Browse files Browse the repository at this point in the history
sunburst Rotation
  • Loading branch information
archmoj authored Oct 8, 2020
2 parents 9a88f84 + cc055fa commit dadcd06
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/traces/sunburst/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ module.exports = {
'this option won\'t have any effect and `insidetextfont` would be used.'
].join(' ')
}),
rotation: {
valType: 'angle',
role: 'style',
dflt: 0,
editType: 'plot',
description: [
'Rotates the whole diagram counterclockwise by some angle.',
'By default the first slice starts at 3 o\'clock.'
].join(' ')
},
sort: pieAttrs.sort,

domain: domainAttrs({name: 'sunburst', trace: true, editType: 'calc'})
Expand Down
2 changes: 2 additions & 0 deletions src/traces/sunburst/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout

coerce('sort');

coerce('rotation');

handleDomainDefaults(traceOut, layout, coerce);

// do not support transforms for now
Expand Down
8 changes: 8 additions & 0 deletions src/traces/sunburst/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ function plotOne(gd, cd, element, transitionOpts) {
// filter out slices that won't show up on graph
sliceData = sliceData.filter(function(pt) { return pt.y1 <= cutoff; });

if(trace.rotation && trace.rotation !== 'auto') {
var extraAngle = trace.rotation * Math.PI / 180;
sliceData.forEach(function(pt) {
pt.x0 += extraAngle;
pt.x1 += extraAngle;
});
}

// partition span ('y') to sector radial px value
var maxY = Math.min(maxHeight, maxDepth);
var y2rpx = function(y) { return (y - yOffset) / maxY * rMax; };
Expand Down

0 comments on commit dadcd06

Please sign in to comment.