diff --git a/src/traces/sunburst/calc.js b/src/traces/sunburst/calc.js
index 58eab8ffae0..0442d664de0 100644
--- a/src/traces/sunburst/calc.js
+++ b/src/traces/sunburst/calc.js
@@ -258,6 +258,7 @@ exports._runCrossTraceCalc = function(desiredType, gd) {
}
var dfltColorCount = 0;
+ var rootColor;
function pickColor(d) {
var cdi = d.data.data;
var id = cdi.id;
@@ -277,7 +278,7 @@ exports._runCrossTraceCalc = function(desiredType, gd) {
}
} else {
// set root color. no coloring by default.
- cdi.color = cdi.trace.root.color;
+ cdi.color = rootColor;
}
}
}
@@ -286,6 +287,7 @@ exports._runCrossTraceCalc = function(desiredType, gd) {
var cd = calcdata[i];
var cd0 = cd[0];
if(cd0.trace.type === desiredType && cd0.hierarchy) {
+ rootColor = cd0.trace.root.color;
cd0.hierarchy.each(pickColor);
}
}
diff --git a/test/image/baselines/treemap_root-color.png b/test/image/baselines/treemap_root-color.png
new file mode 100644
index 00000000000..93165246750
Binary files /dev/null and b/test/image/baselines/treemap_root-color.png differ
diff --git a/test/image/compare_pixels_test.js b/test/image/compare_pixels_test.js
index 93ec06d83fc..9ec29d774ae 100644
--- a/test/image/compare_pixels_test.js
+++ b/test/image/compare_pixels_test.js
@@ -102,6 +102,7 @@ if(allMock || argv.filter) {
var FLAKY_LIST = [
'treemap_coffee',
+ 'treemap_sunburst_marker_colors',
'treemap_textposition',
'treemap_with-without_values',
'gl3d_directions-streamtube1',
diff --git a/test/image/mocks/treemap_root-color.json b/test/image/mocks/treemap_root-color.json
new file mode 100644
index 00000000000..6c5723f0a37
--- /dev/null
+++ b/test/image/mocks/treemap_root-color.json
@@ -0,0 +1,96 @@
+{
+ "data": [
+ {
+ "hovertemplate": "labels=%{label}
sales=%{value}
parent=%{parent}
id=%{id}",
+ "ids": [
+ "all/North/Tech/A",
+ "all/North/Tech/B",
+ "all/North/Finance/C",
+ "all/North/Finance/D",
+ "all/South/Tech/E",
+ "all/South/Tech/F",
+ "all/South/Finance/G",
+ "all/South/Finance/H",
+ "all/North/Finance",
+ "all/South/Finance",
+ "all/North/Other",
+ "all/South/Other",
+ "all/North/Tech",
+ "all/South/Tech",
+ "all/North",
+ "all/South",
+ "all"
+ ],
+ "labels": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "Finance",
+ "Finance",
+ "Other",
+ "Other",
+ "Tech",
+ "Tech",
+ "North",
+ "South",
+ "all"
+ ],
+ "name": "",
+ "parents": [
+ "all/North/Tech",
+ "all/North/Tech",
+ "all/North/Finance",
+ "all/North/Finance",
+ "all/South/Tech",
+ "all/South/Tech",
+ "all/South/Finance",
+ "all/South/Finance",
+ "all/North",
+ "all/South",
+ "all/North",
+ "all/South",
+ "all/North",
+ "all/South",
+ "all",
+ "all",
+ ""
+ ],
+ "type": "treemap",
+ "branchvalues": "total",
+ "values": [
+ 1,
+ 3,
+ 2,
+ 4,
+ 2,
+ 2,
+ 1,
+ 4,
+ 6,
+ 5,
+ 1,
+ 1,
+ 4,
+ 4,
+ 11,
+ 10,
+ 21
+ ]
+ }
+ ],
+ "layout": {
+ "width": 320,
+ "height": 200,
+ "margin": {
+ "t": 20,
+ "l": 20,
+ "r": 20,
+ "b": 20
+ }
+ }
+}
diff --git a/test/jasmine/tests/mock_test.js b/test/jasmine/tests/mock_test.js
index e619d5dabe3..8399be37577 100644
--- a/test/jasmine/tests/mock_test.js
+++ b/test/jasmine/tests/mock_test.js
@@ -989,6 +989,7 @@ var list = [
'treemap_packings',
'treemap_pad_mirror',
'treemap_pad_transpose',
+ 'treemap_root-color',
'treemap_sunburst_basic',
'treemap_sunburst_marker_colors',
'treemap_textfit',
@@ -2077,6 +2078,7 @@ figs['treemap_packages_colorscale_novalue'] = require('@mocks/treemap_packages_c
figs['treemap_packings'] = require('@mocks/treemap_packings');
figs['treemap_pad_mirror'] = require('@mocks/treemap_pad_mirror');
figs['treemap_pad_transpose'] = require('@mocks/treemap_pad_transpose');
+figs['treemap_root-color'] = require('@mocks/treemap_root-color');
figs['treemap_sunburst_basic'] = require('@mocks/treemap_sunburst_basic');
figs['treemap_sunburst_marker_colors'] = require('@mocks/treemap_sunburst_marker_colors');
figs['treemap_textfit'] = require('@mocks/treemap_textfit');