Skip to content

Commit 2e8c7a1

Browse files
committed
bar: guard against invalid base items
1 parent 8d75c3a commit 2e8c7a1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/traces/bar/calc.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ module.exports = function calc(gd, trace) {
2525
var xa = Axes.getFromId(gd, trace.xaxis || 'x'),
2626
ya = Axes.getFromId(gd, trace.yaxis || 'y'),
2727
orientation = trace.orientation || ((trace.x && !trace.y) ? 'h' : 'v'),
28-
pos, size, i;
28+
sa, pos, size, i;
2929

3030
if(orientation === 'h') {
31+
sa = xa;
3132
size = xa.makeCalcdata(trace, 'x');
3233
pos = ya.makeCalcdata(trace, 'y');
3334
}
3435
else {
36+
sa = ya;
3537
size = ya.makeCalcdata(trace, 'y');
3638
pos = xa.makeCalcdata(trace, 'x');
3739
}
@@ -53,18 +55,21 @@ module.exports = function calc(gd, trace) {
5355
}
5456

5557
// set base
56-
var base = trace.base;
58+
var base = trace.base,
59+
b;
5760

5861
if(Array.isArray(base)) {
5962
for(i = 0; i < Math.min(base.length, cd.length); i++) {
60-
cd[i].b = base[i];
63+
b = sa.d2c(base[i]);
64+
cd[i].b = (isNumeric(b)) ? b : 0;
6165
}
6266
for(; i < cd.length; i++) {
6367
cd[i].b = 0;
6468
}
6569
}
6670
else {
67-
var b = (base === undefined) ? 0 : base;
71+
b = sa.d2c(base);
72+
b = (isNumeric(b)) ? b : 0;
6873
for(i = 0; i < cd.length; i++) {
6974
cd[i].b = b;
7075
}

0 commit comments

Comments
 (0)