Skip to content

Commit b7f7944

Browse files
committed
bar: skip over bars with non-numeric size in setPositions
- before dd2251d bar for non-numeric size were excluded from the calcdata, which led to wrong bar widths in traces with gaps. However, this made setPositions stack non-numeric bars.
1 parent 29019ba commit b7f7944

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/traces/bar/calc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ module.exports = function calc(gd, trace) {
3939
// create the "calculated data" to plot
4040
var serieslen = Math.min(pos.length, size.length),
4141
cd = [];
42+
4243
for(i = 0; i < serieslen; i++) {
44+
45+
// add bars with non-numeric sizes to calcdata
46+
// so that ensure that traces with gaps are
47+
// plotted in the correct order
48+
4349
if(isNumeric(pos[i])) {
4450
cd.push({p: pos[i], s: size[i], b: 0});
4551
}

src/traces/bar/set_positions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ module.exports = function setPositions(gd, plotinfo) {
142142
for(i = 0; i < bl.length; i++) { // trace index
143143
ti = gd.calcdata[bl[i]];
144144
for(j = 0; j < ti.length; j++) {
145+
146+
// skip over bars with no size,
147+
// so that we don't try to stack them
148+
if(!isNumeric(ti[j].s)) continue;
149+
145150
sv = Math.round(ti[j].p / sumround);
146151
// store the negative sum value for p at the same key, with sign flipped
147152
if(relative && ti[j].s < 0) sv = -sv;

0 commit comments

Comments
 (0)