Skip to content

Commit 14674d6

Browse files
committed
handle hover edge cases
1 parent e3a8e91 commit 14674d6

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/traces/sunburst/fx.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
4545
var traceNow = gd._fullData[trace.index];
4646
var cdi = pt.data.data;
4747
var ptNumber = cdi.i;
48+
var isRoot = helpers.isHierarchyRoot(pt);
4849

4950
var _cast = function(astr) {
5051
return Lib.castOption(traceNow, ptNumber, astr);
@@ -88,7 +89,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
8889
}
8990

9091
hoverPt.currentPath = pt.currentPath = helpers.getPath(pt.data);
91-
if(hasFlag('current path')) {
92+
if(hasFlag('current path') && !isRoot) {
9293
thisText.push(hoverPt.currentPath);
9394
}
9495

@@ -97,7 +98,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
9798
var insertPercent = function() {
9899
if(tx !== prevTx) { // no need to add redundant info
99100
thisText.push(tx);
100-
prevTx = tx;
101+
prevTx = '' + tx; // i.e. deep copy
101102
}
102103
};
103104

@@ -117,7 +118,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
117118
if(ref1 && getVal(ref1)) {
118119
hoverPt.percentEntry = pt.percentEntry = val / getVal(ref1);
119120
hoverPt.entry = pt.entry = helpers.getLabelString(ref1.data.data.label);
120-
if(hasFlag('percent entry')) {
121+
if(hasFlag('percent entry') && !isRoot && !pt._onPathbar) {
121122
tx = helpers.formatPercent(hoverPt.percentEntry, separators) + ' of ' + hoverPt.entry;
122123
insertPercent();
123124
}
@@ -127,7 +128,7 @@ module.exports = function attachFxHandlers(sliceTop, entry, gd, cd, opts) {
127128
if(ref0 && getVal(ref0)) {
128129
hoverPt.percentRoot = pt.percentRoot = val / getVal(ref0);
129130
hoverPt.root = pt.root = helpers.getLabelString(ref0.data.data.label);
130-
if(hasFlag('percent root')) {
131+
if(hasFlag('percent root') && !isRoot) {
131132
tx = helpers.formatPercent(hoverPt.percentRoot, separators) + ' of ' + hoverPt.root;
132133
insertPercent();
133134
}

test/image/mocks/treemap_packages_colorscale_allone.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"count": "leaves+branches",
66
"maxdepth": 3,
77
"textinfo": "label+percent parent",
8+
"hoverinfo": "all",
89
"tiling": {
910
"packing": "slice-dice"
1011
},

test/image/mocks/treemap_packages_colorscale_novalue.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"type": "treemap",
55
"maxdepth": 3,
66
"textinfo": "label+percent parent",
7+
"hoverinfo": "all",
78
"marker": {
89
"line": {
910
"color": "#777"

0 commit comments

Comments
 (0)