From 8ccebbba1bdae3db7323b80cf27eb54a4d965143 Mon Sep 17 00:00:00 2001 From: thierry vergult Date: Sat, 24 Oct 2020 12:10:39 +0200 Subject: [PATCH 1/4] sunburst & treemap root color attribute --- src/traces/sunburst/attributes.js | 13 +++++++++++++ src/traces/sunburst/calc.js | 3 +++ src/traces/sunburst/defaults.js | 2 ++ src/traces/treemap/attributes.js | 1 + src/traces/treemap/defaults.js | 2 ++ 5 files changed, 21 insertions(+) diff --git a/src/traces/sunburst/attributes.js b/src/traces/sunburst/attributes.js index d8d3949a4f7..bf5efa17447 100644 --- a/src/traces/sunburst/attributes.js +++ b/src/traces/sunburst/attributes.js @@ -215,5 +215,18 @@ module.exports = { }, sort: pieAttrs.sort, + root: { + color: { + valType: 'color', + editType: 'style', + role: 'style', + dflt: null, // rgba(0,0,0,0), + description: [ + 'sets the color of the root node for a sunburst or a treemap trace.' + ].join(' ') + }, + editType: 'plot' + }, + domain: domainAttrs({name: 'sunburst', trace: true, editType: 'calc'}) }; diff --git a/src/traces/sunburst/calc.js b/src/traces/sunburst/calc.js index 35189995f45..a7e56959bcb 100644 --- a/src/traces/sunburst/calc.js +++ b/src/traces/sunburst/calc.js @@ -278,6 +278,9 @@ exports._runCrossTraceCalc = function(desiredType, gd) { } else { // root gets no coloring by default cdi.color = 'rgba(0,0,0,0)'; + if (cdi.trace.root) { + cdi.color = cdi.trace.root.color; + } } } } diff --git a/src/traces/sunburst/defaults.js b/src/traces/sunburst/defaults.js index b02e3ac81e7..2ddd3da5a3f 100644 --- a/src/traces/sunburst/defaults.js +++ b/src/traces/sunburst/defaults.js @@ -77,6 +77,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('rotation'); + coerce('root.color'); + handleDomainDefaults(traceOut, layout, coerce); // do not support transforms for now diff --git a/src/traces/treemap/attributes.js b/src/traces/treemap/attributes.js index 0188e564957..ea58032199f 100644 --- a/src/traces/treemap/attributes.js +++ b/src/traces/treemap/attributes.js @@ -269,6 +269,7 @@ module.exports = { ].join(' ') }, sort: pieAttrs.sort, + root: sunburstAttrs.root, domain: domainAttrs({name: 'treemap', trace: true, editType: 'calc'}), }; diff --git a/src/traces/treemap/defaults.js b/src/traces/treemap/defaults.js index 4a2315fa7bb..1b0e6f2116e 100644 --- a/src/traces/treemap/defaults.js +++ b/src/traces/treemap/defaults.js @@ -116,6 +116,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('sort'); + coerce('root.color'); + handleDomainDefaults(traceOut, layout, coerce); // do not support transforms for now From 12cd7e62e2fda02550b10d4dffadcccc15cc921a Mon Sep 17 00:00:00 2001 From: thierry vergult Date: Sat, 24 Oct 2020 12:22:15 +0200 Subject: [PATCH 2/4] fix lint remark --- src/traces/sunburst/calc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traces/sunburst/calc.js b/src/traces/sunburst/calc.js index a7e56959bcb..e6cdac99fd5 100644 --- a/src/traces/sunburst/calc.js +++ b/src/traces/sunburst/calc.js @@ -278,7 +278,7 @@ exports._runCrossTraceCalc = function(desiredType, gd) { } else { // root gets no coloring by default cdi.color = 'rgba(0,0,0,0)'; - if (cdi.trace.root) { + if(cdi.trace.root) { cdi.color = cdi.trace.root.color; } } From 53f3712dd1e0ab511f6d5b4e93fc07458fa737e8 Mon Sep 17 00:00:00 2001 From: thierry vergult Date: Sun, 25 Oct 2020 09:33:22 +0100 Subject: [PATCH 3/4] editType calc & default no coloring --- src/traces/sunburst/attributes.js | 4 ++-- src/traces/sunburst/calc.js | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/traces/sunburst/attributes.js b/src/traces/sunburst/attributes.js index bf5efa17447..1a0e2353bb0 100644 --- a/src/traces/sunburst/attributes.js +++ b/src/traces/sunburst/attributes.js @@ -220,12 +220,12 @@ module.exports = { valType: 'color', editType: 'style', role: 'style', - dflt: null, // rgba(0,0,0,0), + dflt: 'rgba(0,0,0,0)', description: [ 'sets the color of the root node for a sunburst or a treemap trace.' ].join(' ') }, - editType: 'plot' + editType: 'calc' }, domain: domainAttrs({name: 'sunburst', trace: true, editType: 'calc'}) diff --git a/src/traces/sunburst/calc.js b/src/traces/sunburst/calc.js index e6cdac99fd5..58eab8ffae0 100644 --- a/src/traces/sunburst/calc.js +++ b/src/traces/sunburst/calc.js @@ -276,11 +276,8 @@ exports._runCrossTraceCalc = function(desiredType, gd) { dfltColorCount++; } } else { - // root gets no coloring by default - cdi.color = 'rgba(0,0,0,0)'; - if(cdi.trace.root) { - cdi.color = cdi.trace.root.color; - } + // set root color. no coloring by default. + cdi.color = cdi.trace.root.color; } } } From 2f079635b9788608790e71d938ceb06b510a4123 Mon Sep 17 00:00:00 2001 From: thierry vergult Date: Mon, 26 Oct 2020 20:44:10 +0100 Subject: [PATCH 4/4] set edittype to calc, and exclude colorscale attribute settings --- src/traces/sunburst/attributes.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/traces/sunburst/attributes.js b/src/traces/sunburst/attributes.js index 1a0e2353bb0..31e51c3c019 100644 --- a/src/traces/sunburst/attributes.js +++ b/src/traces/sunburst/attributes.js @@ -218,11 +218,12 @@ module.exports = { root: { color: { valType: 'color', - editType: 'style', + editType: 'calc', role: 'style', dflt: 'rgba(0,0,0,0)', description: [ - 'sets the color of the root node for a sunburst or a treemap trace.' + 'sets the color of the root node for a sunburst or a treemap trace.', + 'this has no effect when a colorscale is used to set the markers.' ].join(' ') }, editType: 'calc'