Skip to content

Commit c91f9db

Browse files
committed
revisit ancestors draw - avoid overlaps - end pathbar with edgeshape
1 parent d7b06a1 commit c91f9db

File tree

7 files changed

+32
-22
lines changed

7 files changed

+32
-22
lines changed

src/traces/treemap/draw_ancestors.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ module.exports = function drawAncestors(gd, cd, entry, slices, opts) {
6464
if(level === -1) return false;
6565

6666
pt.x0 = eachWidth * level;
67-
pt.x1 = width;
68-
pt.y0 = barDifY + 0;
67+
pt.x1 = eachWidth * (level + 1);
68+
pt.y0 = barDifY;
6969
pt.y1 = barDifY + height;
7070

71+
pt._onPathbar = true;
72+
7173
return true;
7274
});
7375

src/traces/treemap/plot.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,9 @@ function plotOne(gd, cd, element, transitionOpts) {
169169
}
170170

171171
var xStart = viewBarX(0);
172-
var limitX0 = function(p) {
173-
p.x = Math.max(xStart, p.x);
174-
};
172+
var limitX0 = function(p) { p.x = Math.max(xStart, p.x); };
175173

176174
var edgeshape = trace.pathbar.edgeshape;
177-
var hasExtraPoint = (edgeshape !== '|');
178175

179176
// pathbar(directory) path generation fn
180177
var pathAncestor = function(d) {
@@ -185,17 +182,13 @@ function plotOne(gd, cd, element, transitionOpts) {
185182

186183
var halfH = barH / 2;
187184

188-
var pM = {};
189-
var midLeft;
190-
if(hasExtraPoint) {
191-
midLeft = true;
192-
pM.x = _x0;
185+
var pL = {};
186+
var pR = {};
193187

194-
pM.y = (
195-
edgeshape === '>' ||
196-
edgeshape === '<'
197-
) ? _y0 + halfH : _y0;
198-
}
188+
pL.x = _x0;
189+
pR.x = _x1;
190+
191+
pL.y = pR.y = (_y0 + _y1) / 2;
199192

200193
var pA = {x: _x0, y: _y0};
201194
var pB = {x: _x1, y: _y0};
@@ -204,25 +197,39 @@ function plotOne(gd, cd, element, transitionOpts) {
204197

205198
if(edgeshape === '>') {
206199
pA.x -= halfH;
200+
pB.x -= halfH;
201+
pC.x -= halfH;
207202
pD.x -= halfH;
208203
} else if(edgeshape === '/') {
204+
pC.x -= halfH;
209205
pD.x -= halfH;
206+
pL.x -= halfH / 2;
207+
pR.x -= halfH / 2;
210208
} else if(edgeshape === '\\') {
211-
pM.x -= halfH;
209+
pA.x -= halfH;
210+
pB.x -= halfH;
211+
pL.x -= halfH / 2;
212+
pR.x -= halfH / 2;
212213
} else if(edgeshape === '<') {
213-
pM.x -= halfH;
214+
pL.x -= halfH;
215+
pR.x -= halfH;
214216
}
215217

216218
limitX0(pA);
217219
limitX0(pD);
218-
limitX0(pM);
220+
limitX0(pL);
221+
222+
limitX0(pB);
223+
limitX0(pC);
224+
limitX0(pR);
219225

220226
return noNaN(
221227
'M' + pos(pA.x, pA.y) +
222228
'L' + pos(pB.x, pB.y) +
229+
'L' + pos(pR.x, pR.y) +
223230
'L' + pos(pC.x, pC.y) +
224231
'L' + pos(pD.x, pD.y) +
225-
(midLeft ? 'L' + pos(pM.x, pM.y) : '') +
232+
'L' + pos(pL.x, pL.y) +
226233
'Z'
227234
);
228235
};
@@ -376,7 +383,6 @@ function plotOne(gd, cd, element, transitionOpts) {
376383
// for new pts:
377384
if(upDown) {
378385
prev = pathbarOrigin;
379-
if(helpers.isEntry(pt)) prev.x0 = 0;
380386
} else {
381387
if(prevEntry) {
382388
// if trace was visible before

src/traces/treemap/style.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ function styleOne(s, pt, trace, opts) {
4242
} else {
4343
lineColor = Lib.castOption(trace, ptNumber, 'marker.line.color') || Color.defaultLine;
4444
lineWidth = Lib.castOption(trace, ptNumber, 'marker.line.width') || 0;
45-
opacity = Math.pow(trace.marker.opacity, pt.height);
45+
opacity = pt._onPathbar ?
46+
Math.pow(trace.marker.opacity, pt.depth) :
47+
Math.pow(trace.marker.opacity, pt.height);
4648
}
4749

4850
s.style('stroke-width', lineWidth)
108 Bytes
Loading
94 Bytes
Loading
241 Bytes
Loading
252 Bytes
Loading

0 commit comments

Comments
 (0)