Skip to content

Commit 1a13e0c

Browse files
committed
fix issue 5328 - pick trace root color
1 parent 0dd5467 commit 1a13e0c

File tree

4 files changed

+101
-1
lines changed

4 files changed

+101
-1
lines changed

src/traces/sunburst/calc.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ exports._runCrossTraceCalc = function(desiredType, gd) {
258258
}
259259
var dfltColorCount = 0;
260260

261+
var rootColor;
261262
function pickColor(d) {
262263
var cdi = d.data.data;
263264
var id = cdi.id;
@@ -277,7 +278,7 @@ exports._runCrossTraceCalc = function(desiredType, gd) {
277278
}
278279
} else {
279280
// set root color. no coloring by default.
280-
cdi.color = cdi.trace.root.color;
281+
cdi.color = rootColor;
281282
}
282283
}
283284
}
@@ -286,6 +287,7 @@ exports._runCrossTraceCalc = function(desiredType, gd) {
286287
var cd = calcdata[i];
287288
var cd0 = cd[0];
288289
if(cd0.trace.type === desiredType && cd0.hierarchy) {
290+
rootColor = cd0.trace.root.color;
289291
cd0.hierarchy.each(pickColor);
290292
}
291293
}
9.32 KB
Loading
+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"data": [
3+
{
4+
"hovertemplate": "labels=%{label}<br>sales=%{value}<br>parent=%{parent}<br>id=%{id}<extra></extra>",
5+
"ids": [
6+
"all/North/Tech/A",
7+
"all/North/Tech/B",
8+
"all/North/Finance/C",
9+
"all/North/Finance/D",
10+
"all/South/Tech/E",
11+
"all/South/Tech/F",
12+
"all/South/Finance/G",
13+
"all/South/Finance/H",
14+
"all/North/Finance",
15+
"all/South/Finance",
16+
"all/North/Other",
17+
"all/South/Other",
18+
"all/North/Tech",
19+
"all/South/Tech",
20+
"all/North",
21+
"all/South",
22+
"all"
23+
],
24+
"labels": [
25+
"A",
26+
"B",
27+
"C",
28+
"D",
29+
"E",
30+
"F",
31+
"G",
32+
"H",
33+
"Finance",
34+
"Finance",
35+
"Other",
36+
"Other",
37+
"Tech",
38+
"Tech",
39+
"North",
40+
"South",
41+
"all"
42+
],
43+
"name": "",
44+
"parents": [
45+
"all/North/Tech",
46+
"all/North/Tech",
47+
"all/North/Finance",
48+
"all/North/Finance",
49+
"all/South/Tech",
50+
"all/South/Tech",
51+
"all/South/Finance",
52+
"all/South/Finance",
53+
"all/North",
54+
"all/South",
55+
"all/North",
56+
"all/South",
57+
"all/North",
58+
"all/South",
59+
"all",
60+
"all",
61+
""
62+
],
63+
"type": "treemap",
64+
"branchvalues": "total",
65+
"values": [
66+
1,
67+
3,
68+
2,
69+
4,
70+
2,
71+
2,
72+
1,
73+
4,
74+
6,
75+
5,
76+
1,
77+
1,
78+
4,
79+
4,
80+
11,
81+
10,
82+
21
83+
]
84+
}
85+
],
86+
"layout": {
87+
"width": 320,
88+
"height": 200,
89+
"margin": {
90+
"t": 20,
91+
"l": 20,
92+
"r": 20,
93+
"b": 20
94+
}
95+
}
96+
}

test/jasmine/tests/mock_test.js

+2
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ var list = [
989989
'treemap_packings',
990990
'treemap_pad_mirror',
991991
'treemap_pad_transpose',
992+
'treemap_root-color',
992993
'treemap_sunburst_basic',
993994
'treemap_sunburst_marker_colors',
994995
'treemap_textfit',
@@ -2077,6 +2078,7 @@ figs['treemap_packages_colorscale_novalue'] = require('@mocks/treemap_packages_c
20772078
figs['treemap_packings'] = require('@mocks/treemap_packings');
20782079
figs['treemap_pad_mirror'] = require('@mocks/treemap_pad_mirror');
20792080
figs['treemap_pad_transpose'] = require('@mocks/treemap_pad_transpose');
2081+
figs['treemap_root-color'] = require('@mocks/treemap_root-color');
20802082
figs['treemap_sunburst_basic'] = require('@mocks/treemap_sunburst_basic');
20812083
figs['treemap_sunburst_marker_colors'] = require('@mocks/treemap_sunburst_marker_colors');
20822084
figs['treemap_textfit'] = require('@mocks/treemap_textfit');

0 commit comments

Comments
 (0)