Skip to content

Commit 35ea4b3

Browse files
committed
correct current path function - reuse listPath in helpers i.e. to have one recursive function
1 parent 1270d67 commit 35ea4b3

File tree

8 files changed

+123
-114
lines changed

8 files changed

+123
-114
lines changed

src/traces/sunburst/helpers.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,12 @@ exports.getLabelString = function(label) { // used in hover to reference to the
151151
return str ? str : '"root"';
152152
};
153153

154-
exports.getPath = function(d) {
155-
if(!d.parent) return '';
156-
return exports.getLabelStr(d.parent.data.label) + '/';
157-
};
158-
159154
exports.listPath = function(d, keyStr) {
160155
if(!d.parent) return [];
161156
var list = keyStr ? [d.parent.data[keyStr]] : [d];
162157
return exports.listPath(d.parent, keyStr).concat(list);
163158
};
159+
160+
exports.getPath = function(d) {
161+
return exports.listPath(d, 'label').join('/') + '/';
162+
};

src/traces/sunburst/plot.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,11 @@ exports.formatSliceLabel = function(pt, entry, trace, cd, fullLayout) {
485485
var cdi = pt.data.data;
486486
var hierarchy = cd0.hierarchy;
487487
var ref;
488-
var calcPercent = function() { return cdi.hasOwnProperty('v') ? cdi.v / ref.data.data.v : cdi.value / ref.data.data.value; };
488+
var calcPercent = function() {
489+
return cdi.hasOwnProperty('v') ?
490+
cdi.v / ref.data.data.v :
491+
cdi.value / ref.data.data.value;
492+
};
489493

490494
if(trace.type === 'treemap' && helpers.isHeader(pt, trace)) {
491495
return helpers.getLabelStr(cdi.label);
5.5 KB
Loading
-52 Bytes
Loading
-7 Bytes
Loading
66 Bytes
Loading

test/image/mocks/treemap_level-depth.json

Lines changed: 108 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,33 @@
6464
0
6565
],
6666
"values": [
67-
4,
68-
3,
69-
2,
70-
1,
71-
1,
72-
3,
73-
2,
74-
1,
75-
1,
76-
1,
77-
1,
78-
1,
79-
1,
80-
1,
81-
1,
82-
2,
83-
1,
84-
1,
85-
1,
86-
1,
87-
1,
88-
2,
89-
1,
90-
1,
91-
1,
92-
1,
93-
1
67+
4000000,
68+
3000000,
69+
2000000,
70+
1000000,
71+
1000000,
72+
3000000,
73+
2000000,
74+
1000000,
75+
1000000,
76+
1000000,
77+
1000000,
78+
1000000,
79+
1000000,
80+
1000000,
81+
1000000,
82+
2000000,
83+
1000000,
84+
1000000,
85+
1000000,
86+
1000000,
87+
1000000,
88+
2000000,
89+
1000000,
90+
1000000,
91+
1000000,
92+
1000000,
93+
1000000
9494
],
9595
"parents": [
9696
"",
@@ -196,33 +196,33 @@
196196
0
197197
],
198198
"values": [
199-
4,
200-
3,
201-
2,
202-
1,
203-
1,
204-
3,
205-
2,
206-
1,
207-
1,
208-
1,
209-
1,
210-
1,
211-
1,
212-
1,
213-
1,
214-
2,
215-
1,
216-
1,
217-
1,
218-
1,
219-
1,
220-
2,
221-
1,
222-
1,
223-
1,
224-
1,
225-
1
199+
4000000,
200+
3000000,
201+
2000000,
202+
1000000,
203+
1000000,
204+
3000000,
205+
2000000,
206+
1000000,
207+
1000000,
208+
1000000,
209+
1000000,
210+
1000000,
211+
1000000,
212+
1000000,
213+
1000000,
214+
2000000,
215+
1000000,
216+
1000000,
217+
1000000,
218+
1000000,
219+
1000000,
220+
2000000,
221+
1000000,
222+
1000000,
223+
1000000,
224+
1000000,
225+
1000000
226226
],
227227
"parents": [
228228
"",
@@ -334,33 +334,33 @@
334334
0
335335
],
336336
"values": [
337-
4,
338-
3,
339-
2,
340-
1,
341-
1,
342-
3,
343-
2,
344-
1,
345-
1,
346-
1,
347-
1,
348-
1,
349-
1,
350-
1,
351-
1,
352-
2,
353-
1,
354-
1,
355-
1,
356-
1,
357-
1,
358-
2,
359-
1,
360-
1,
361-
1,
362-
1,
363-
1
337+
4000000,
338+
3000000,
339+
2000000,
340+
1000000,
341+
1000000,
342+
3000000,
343+
2000000,
344+
1000000,
345+
1000000,
346+
1000000,
347+
1000000,
348+
1000000,
349+
1000000,
350+
1000000,
351+
1000000,
352+
2000000,
353+
1000000,
354+
1000000,
355+
1000000,
356+
1000000,
357+
1000000,
358+
2000000,
359+
1000000,
360+
1000000,
361+
1000000,
362+
1000000,
363+
1000000
364364
],
365365
"parents": [
366366
"",
@@ -466,33 +466,33 @@
466466
0
467467
],
468468
"values": [
469-
4,
470-
3,
471-
2,
472-
1,
473-
1,
474-
3,
475-
2,
476-
1,
477-
1,
478-
1,
479-
1,
480-
1,
481-
1,
482-
1,
483-
1,
484-
2,
485-
1,
486-
1,
487-
1,
488-
1,
489-
1,
490-
2,
491-
1,
492-
1,
493-
1,
494-
1,
495-
1
469+
4000000,
470+
3000000,
471+
2000000,
472+
1000000,
473+
1000000,
474+
3000000,
475+
2000000,
476+
1000000,
477+
1000000,
478+
1000000,
479+
1000000,
480+
1000000,
481+
1000000,
482+
1000000,
483+
1000000,
484+
2000000,
485+
1000000,
486+
1000000,
487+
1000000,
488+
1000000,
489+
1000000,
490+
2000000,
491+
1000000,
492+
1000000,
493+
1000000,
494+
1000000,
495+
1000000
496496
],
497497
"parents": [
498498
"",

test/image/mocks/treemap_packings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{
44
"type": "treemap",
55
"textinfo": "label",
6+
"hoverinfo": "all",
67
"name": "binary treemap",
78
"tiling": {
89
"packing": "binary"
@@ -90,6 +91,7 @@
9091
{
9192
"type": "treemap",
9293
"textinfo": "label",
94+
"hoverinfo": "all",
9395
"name": "dice-slice treemap",
9496
"tiling": {
9597
"packing": "dice-slice"
@@ -177,6 +179,7 @@
177179
{
178180
"type": "treemap",
179181
"textinfo": "label",
182+
"hoverinfo": "all",
180183
"name": "squarify treemap",
181184
"tiling": {
182185
"packing": "squarify"
@@ -264,6 +267,7 @@
264267
{
265268
"type": "treemap",
266269
"textinfo": "label",
270+
"hoverinfo": "all",
267271
"name": "slice treemap",
268272
"tiling": {
269273
"packing": "slice"
@@ -351,6 +355,7 @@
351355
{
352356
"type": "treemap",
353357
"textinfo": "label",
358+
"hoverinfo": "all",
354359
"name": "slice-dice treemap",
355360
"tiling": {
356361
"packing": "slice-dice"
@@ -438,6 +443,7 @@
438443
{
439444
"type": "treemap",
440445
"textinfo": "label",
446+
"hoverinfo": "all",
441447
"name": "dice treemap",
442448
"tiling": {
443449
"packing": "dice"

0 commit comments

Comments
 (0)