Skip to content

Commit 83fdb44

Browse files
committed
bar: do not stack traces that set bar base
1 parent f2a365e commit 83fdb44

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/traces/bar/set_positions.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ function setGroupPositions(gd, pa, sa, traces) {
5454

5555
var barmode = gd._fullLayout.barmode,
5656
overlay = (barmode === 'overlay'),
57-
group = (barmode === 'group');
57+
group = (barmode === 'group'),
58+
excluded,
59+
included,
60+
i, trace;
5861

5962
if(overlay) {
6063
setGroupPositionsInOverlayMode(gd, pa, sa, traces);
@@ -63,7 +66,21 @@ function setGroupPositions(gd, pa, sa, traces) {
6366
setGroupPositionsInGroupMode(gd, pa, sa, traces);
6467
}
6568
else {
66-
setGroupPositionsInStackOrRelativeMode(gd, pa, sa, traces);
69+
// exclude from the stack those traces for which the user set a base
70+
excluded = [];
71+
included = [];
72+
for(i = 0; i < traces.length; i++) {
73+
trace = traces[i];
74+
if(trace.base === undefined) included.push(trace);
75+
else excluded.push(trace);
76+
}
77+
78+
if(included.length) {
79+
setGroupPositionsInStackOrRelativeMode(gd, pa, sa, included);
80+
}
81+
if(excluded.length) {
82+
setGroupPositionsInOverlayMode(gd, pa, sa, excluded);
83+
}
6784
}
6885
}
6986

0 commit comments

Comments
 (0)