From bac32bfc0ceb4a1535edc4bfb7602991d19ad60e Mon Sep 17 00:00:00 2001 From: thierry vergult Date: Mon, 28 Sep 2020 21:24:30 +0200 Subject: [PATCH 1/6] sunburst Rotation Reuse rotation attribute from Pie --- src/traces/sunburst/attributes.js | 1 + src/traces/sunburst/defaults.js | 2 ++ src/traces/sunburst/plot.js | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/src/traces/sunburst/attributes.js b/src/traces/sunburst/attributes.js index 4ccd65b80d9..933d05fe0ff 100644 --- a/src/traces/sunburst/attributes.js +++ b/src/traces/sunburst/attributes.js @@ -203,6 +203,7 @@ module.exports = { 'this option won\'t have any effect and `insidetextfont` would be used.' ].join(' ') }), + rotation: pieAttrs.rotation, domain: domainAttrs({name: 'sunburst', trace: true, editType: 'calc'}) }; diff --git a/src/traces/sunburst/defaults.js b/src/traces/sunburst/defaults.js index cd034ca75fb..af94dd7a0c2 100644 --- a/src/traces/sunburst/defaults.js +++ b/src/traces/sunburst/defaults.js @@ -73,6 +73,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('insidetextorientation'); + coerce('rotation'); + handleDomainDefaults(traceOut, layout, coerce); // do not support transforms for now diff --git a/src/traces/sunburst/plot.js b/src/traces/sunburst/plot.js index ef3616e4b88..c546872b958 100644 --- a/src/traces/sunburst/plot.js +++ b/src/traces/sunburst/plot.js @@ -220,6 +220,10 @@ function plotOne(gd, cd, element, transitionOpts) { s.style('pointer-events', 'all'); }); + var extraAngle = trace.rotation * Math.PI / 180; + pt.x0 = pt.x0 + extraAngle; + pt.x1 = pt.x1 + extraAngle; + pt.rpx0 = y2rpx(pt.y0); pt.rpx1 = y2rpx(pt.y1); pt.xmid = (pt.x0 + pt.x1) / 2; From 9d43204f0768db85551d4a7b29042d15ef95fb16 Mon Sep 17 00:00:00 2001 From: thierry vergult Date: Mon, 28 Sep 2020 22:00:58 +0200 Subject: [PATCH 2/6] sunburst Rotation lint - some spaces --- src/traces/sunburst/defaults.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/traces/sunburst/defaults.js b/src/traces/sunburst/defaults.js index b4c9aebb9d8..b02e3ac81e7 100644 --- a/src/traces/sunburst/defaults.js +++ b/src/traces/sunburst/defaults.js @@ -76,7 +76,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('sort'); coerce('rotation'); - handleDomainDefaults(traceOut, layout, coerce); From b889c9424a7519f743a77caffc60747795904a33 Mon Sep 17 00:00:00 2001 From: thierry vergult Date: Tue, 29 Sep 2020 21:52:06 +0200 Subject: [PATCH 3/6] sunburst rotation - attribute Redefine attribute rotation (from @archmoj ; 2af75a8). Not from pie anymore. The extra angle is *counterclockwise* --- src/traces/sunburst/attributes.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/traces/sunburst/attributes.js b/src/traces/sunburst/attributes.js index ffbea5232fe..2e16764b009 100644 --- a/src/traces/sunburst/attributes.js +++ b/src/traces/sunburst/attributes.js @@ -203,7 +203,18 @@ module.exports = { 'this option won\'t have any effect and `insidetextfont` would be used.' ].join(' ') }), - rotation: pieAttrs.rotation, + rotation: { + valType: 'number', + role: 'style', + min: -180, + max: 180, + dflt: 0, + editType: 'plot', + description: [ + 'Instead of the first slice starting at 3 o\'clock,', + 'rotate to some other angle.' + ].join(' ') + }, sort: pieAttrs.sort, domain: domainAttrs({name: 'sunburst', trace: true, editType: 'calc'}) From f90737b963c712bdd5fa373b3aa8f37da28ce1bb Mon Sep 17 00:00:00 2001 From: thierry vergult Date: Sat, 3 Oct 2020 15:33:47 +0200 Subject: [PATCH 4/6] sunburst rotation Bringing in suggestions from @alexcjohnson --- src/traces/sunburst/attributes.js | 8 +++----- src/traces/sunburst/plot.js | 12 ++++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/traces/sunburst/attributes.js b/src/traces/sunburst/attributes.js index 2e16764b009..d8d3949a4f7 100644 --- a/src/traces/sunburst/attributes.js +++ b/src/traces/sunburst/attributes.js @@ -204,15 +204,13 @@ module.exports = { ].join(' ') }), rotation: { - valType: 'number', + valType: 'angle', role: 'style', - min: -180, - max: 180, dflt: 0, editType: 'plot', description: [ - 'Instead of the first slice starting at 3 o\'clock,', - 'rotate to some other angle.' + 'Rotates the whole diagram counterclockwise by some angle.', + 'By default the first slice starts at 3 o\'clock.' ].join(' ') }, sort: pieAttrs.sort, diff --git a/src/traces/sunburst/plot.js b/src/traces/sunburst/plot.js index c546872b958..dc69381c685 100644 --- a/src/traces/sunburst/plot.js +++ b/src/traces/sunburst/plot.js @@ -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; }; @@ -220,10 +228,6 @@ function plotOne(gd, cd, element, transitionOpts) { s.style('pointer-events', 'all'); }); - var extraAngle = trace.rotation * Math.PI / 180; - pt.x0 = pt.x0 + extraAngle; - pt.x1 = pt.x1 + extraAngle; - pt.rpx0 = y2rpx(pt.y0); pt.rpx1 = y2rpx(pt.y1); pt.xmid = (pt.x0 + pt.x1) / 2; From 18d77db60f5f8091580b9e1d80a9bc2784a94313 Mon Sep 17 00:00:00 2001 From: thierry vergult Date: Sat, 3 Oct 2020 20:13:00 +0200 Subject: [PATCH 5/6] sunburst rotation - no auto --- src/traces/sunburst/plot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traces/sunburst/plot.js b/src/traces/sunburst/plot.js index dc69381c685..ef7ce7a00cb 100644 --- a/src/traces/sunburst/plot.js +++ b/src/traces/sunburst/plot.js @@ -150,7 +150,7 @@ 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') { + if(trace.rotation) { var extraAngle = trace.rotation * Math.PI / 180; sliceData.forEach(function(pt) { pt.x0 += extraAngle; From cc055fa288a04d94ae8eab51b2bbf3b19332a436 Mon Sep 17 00:00:00 2001 From: thierry vergult Date: Tue, 6 Oct 2020 21:36:41 +0200 Subject: [PATCH 6/6] sunburst rotation - add check on auto again --- src/traces/sunburst/plot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traces/sunburst/plot.js b/src/traces/sunburst/plot.js index ef7ce7a00cb..dc69381c685 100644 --- a/src/traces/sunburst/plot.js +++ b/src/traces/sunburst/plot.js @@ -150,7 +150,7 @@ 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) { + if(trace.rotation && trace.rotation !== 'auto') { var extraAngle = trace.rotation * Math.PI / 180; sliceData.forEach(function(pt) { pt.x0 += extraAngle;