Skip to content

Commit 1de80d9

Browse files
committed
add mock to test with and without values - and pathbar fade with depth
1 parent 35ea4b3 commit 1de80d9

8 files changed

+487
-2
lines changed

src/traces/treemap/style.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,33 @@ function styleOne(s, pt, trace, opts) {
3535
var lineWidth;
3636
var opacity;
3737

38+
var depthFn = function(n) {
39+
return Math.pow(trace.marker.opacity, n);
40+
};
41+
42+
var add = function(a, b) {
43+
return (1 - a) * (1 - b);
44+
};
45+
46+
var sumUpTo = function(n) {
47+
var sum = 0;
48+
for(var i = 0; i < n; i++) {
49+
sum += add(sum, depthFn(i));
50+
}
51+
return 1 - sum;
52+
};
53+
3854
if((opts || {}).hovered) {
3955
lineColor = trace._hovered.marker.line.color;
4056
lineWidth = trace._hovered.marker.line.width;
4157
opacity = trace._hovered.marker.opacity;
4258
} else {
4359
lineColor = Lib.castOption(trace, ptNumber, 'marker.line.color') || Color.defaultLine;
4460
lineWidth = Lib.castOption(trace, ptNumber, 'marker.line.width') || 0;
61+
4562
opacity = pt._onPathbar ?
46-
Math.pow(trace.marker.opacity, pt.depth) :
47-
Math.pow(trace.marker.opacity, pt.height);
63+
sumUpTo(pt.depth) :
64+
depthFn(pt.height);
4865
}
4966

5067
s.style('stroke-width', lineWidth)
-1.01 KB
Loading
-11 Bytes
Loading
-72 Bytes
Loading
117 KB
Loading
130 KB
Loading
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
{
2+
"data": [
3+
{
4+
"type": "treemap",
5+
"textinfo": "label+value+percent parent+percent visible+percent root",
6+
"hoverinfo": "all",
7+
"name": "without values",
8+
"level": "Oscar",
9+
"labels": [
10+
"Alpha",
11+
"Bravo",
12+
"Charlie",
13+
"Delta",
14+
"Echo",
15+
"Foxtrot",
16+
"Golf",
17+
"Hotel",
18+
"India",
19+
"Juliet",
20+
"Kilo",
21+
"Lima",
22+
"Mike",
23+
"November",
24+
"Oscar",
25+
"Papa",
26+
"Quebec",
27+
"Romeo",
28+
"Sierra",
29+
"Tango",
30+
"Uniform",
31+
"Victor",
32+
"Whiskey",
33+
"X ray",
34+
"Yankee",
35+
"Zulu"
36+
],
37+
"parents": [
38+
"",
39+
"Alpha",
40+
"Alpha",
41+
"Charlie",
42+
"Charlie",
43+
"Charlie",
44+
"Foxtrot",
45+
"Foxtrot",
46+
"Foxtrot",
47+
"Foxtrot",
48+
"Juliet",
49+
"Juliet",
50+
"Juliet",
51+
"Juliet",
52+
"Juliet",
53+
"Oscar",
54+
"Oscar",
55+
"Oscar",
56+
"Oscar",
57+
"Oscar",
58+
"Oscar",
59+
"Uniform",
60+
"Uniform",
61+
"Uniform",
62+
"Uniform",
63+
"Uniform",
64+
"Uniform"
65+
],
66+
"domain": {
67+
"x": [
68+
0,
69+
0.48
70+
]
71+
}
72+
},
73+
{
74+
"type": "treemap",
75+
"textinfo": "label+value+percent parent+percent visible+percent root",
76+
"hoverinfo": "all",
77+
"name": "with values",
78+
"level": "Oscar",
79+
"labels": [
80+
"Alpha",
81+
"Bravo",
82+
"Charlie",
83+
"Delta",
84+
"Echo",
85+
"Foxtrot",
86+
"Golf",
87+
"Hotel",
88+
"India",
89+
"Juliet",
90+
"Kilo",
91+
"Lima",
92+
"Mike",
93+
"November",
94+
"Oscar",
95+
"Papa",
96+
"Quebec",
97+
"Romeo",
98+
"Sierra",
99+
"Tango",
100+
"Uniform",
101+
"Victor",
102+
"Whiskey",
103+
"X ray",
104+
"Yankee",
105+
"Zulu"
106+
],
107+
"branchvalues": "total",
108+
"values": [
109+
20,
110+
1,
111+
19,
112+
1,
113+
1,
114+
17,
115+
1,
116+
1,
117+
1,
118+
14,
119+
1,
120+
1,
121+
1,
122+
1,
123+
10,
124+
1,
125+
1,
126+
1,
127+
1,
128+
1,
129+
5,
130+
1,
131+
1,
132+
1,
133+
1,
134+
1
135+
],
136+
"parents": [
137+
"",
138+
"Alpha",
139+
"Alpha",
140+
"Charlie",
141+
"Charlie",
142+
"Charlie",
143+
"Foxtrot",
144+
"Foxtrot",
145+
"Foxtrot",
146+
"Foxtrot",
147+
"Juliet",
148+
"Juliet",
149+
"Juliet",
150+
"Juliet",
151+
"Juliet",
152+
"Oscar",
153+
"Oscar",
154+
"Oscar",
155+
"Oscar",
156+
"Oscar",
157+
"Oscar",
158+
"Uniform",
159+
"Uniform",
160+
"Uniform",
161+
"Uniform",
162+
"Uniform",
163+
"Uniform"
164+
],
165+
"marker": {
166+
"colorscale": "Blues"
167+
},
168+
"domain": {
169+
"x": [
170+
0.52,
171+
1
172+
]
173+
}
174+
}
175+
],
176+
"layout": {
177+
"margin" : {
178+
"t": 50,
179+
"l": 0,
180+
"r": 0,
181+
"b": 0
182+
},
183+
"width": 1000,
184+
"height": 600,
185+
"annotations": [
186+
{
187+
"showarrow": false,
188+
"text": "<b>without values<br>",
189+
"x": 0.24,
190+
"xanchor": "center",
191+
"y": 0,
192+
"yanchor": "top"
193+
},
194+
{
195+
"showarrow": false,
196+
"text": "<b>with values<br>",
197+
"x": 0.76,
198+
"xanchor": "center",
199+
"y": 0,
200+
"yanchor": "top"
201+
}
202+
]
203+
}
204+
}

0 commit comments

Comments
 (0)