Skip to content

Commit 36fb510

Browse files
committed
early exit out of maxdepth elements for better transitions and avoid exit in the center
1 parent ad24987 commit 36fb510

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/traces/treemap/plot.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ function plotOne(gd, cd, element, transitionOpts) {
103103
y0 = barDifY + 0;
104104
y1 = barDifY + height;
105105
} else {
106-
var ref = clicked.zoomOut ? refRect : prevLookdown[clicked.id] || prevLookup[clicked.id];
106+
var ref = clicked.zoomOut ? refRect : (
107+
upDown ? prevLookup[clicked.id] : prevLookdown[clicked.id]
108+
);
107109

108110
if(Object.keys(ref).length === 0 && // case of an empty object - happens when maxdepth is set
109111
!helpers.isHierarchyRoot(pt)
110112
) {
111-
var q = pt.parent || pt;
112-
x0 = x1 = (q.x0 + q.x1) / 2;
113-
y0 = y1 = (q.y0 + q.y1) / 2;
113+
x0 = x1 = y0 = y1 = NaN;
114114
} else {
115115
var e = trace.tiling.pad;
116116
var isLeftOfRect = function(x) { return x - e <= ref.x0; };
@@ -190,6 +190,10 @@ function plotOne(gd, cd, element, transitionOpts) {
190190
return x + ',' + y;
191191
}
192192

193+
function noNaN(path) {
194+
return path.indexOf('NaN') > -1 ? '' : path;
195+
}
196+
193197
var xStart = viewDirX(0);
194198
var limitX0 = function(p) {
195199
p.x = Math.max(xStart, p.x);
@@ -239,7 +243,7 @@ function plotOne(gd, cd, element, transitionOpts) {
239243
limitX0(pD);
240244
limitX0(pM);
241245

242-
return (
246+
return noNaN(
243247
'M' + pos(pA.x, pA.y) +
244248
'L' + pos(pB.x, pB.y) +
245249
'L' + pos(pC.x, pC.y) +
@@ -256,7 +260,7 @@ function plotOne(gd, cd, element, transitionOpts) {
256260
var _y0 = viewMapY(d.y0);
257261
var _y1 = viewMapY(d.y1);
258262

259-
return (
263+
return noNaN(
260264
'M' + pos(_x0, _y0) +
261265
'L' + pos(_x1, _y0) +
262266
'L' + pos(_x1, _y1) +

0 commit comments

Comments
 (0)