Skip to content

Commit dbbf8e7

Browse files
committed
bar: guard against invalid offset or width items
1 parent 2e8c7a1 commit dbbf8e7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/traces/bar/set_positions.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ function setOffsetAndWidth(gd, pa, sieve) {
230230
// if offset is an array, then clone it into t.poffset.
231231
newPoffset = offset.slice(0, calcTrace.length);
232232

233+
// guard against non-numeric items
234+
for(j = 0; j < newPoffset.length; j++) {
235+
if(!isNumeric(newPoffset[j])) newPoffset[j] = initialPoffset;
236+
}
237+
233238
// if the length of the array is too short,
234239
// then extend it with the initial value of t.poffset
235240
for(j = newPoffset.length; j < calcTrace.length; j++) {
@@ -248,6 +253,11 @@ function setOffsetAndWidth(gd, pa, sieve) {
248253
// if width is an array, then clone it into t.barwidth.
249254
var newBarwidth = width.slice(0, calcTrace.length);
250255

256+
// guard against non-numeric items
257+
for(j = 0; j < newBarwidth.length; j++) {
258+
if(!isNumeric(newBarwidth[j])) newBarwidth[j] = initialBarwidth;
259+
}
260+
251261
// if the length of the array is too short,
252262
// then extend it with the initial value of t.barwidth
253263
for(j = newBarwidth.length; j < calcTrace.length; j++) {
@@ -348,6 +358,11 @@ function setOffsetAndWidthInGroupMode(gd, pa, sieve) {
348358
// if width is an array, then clone it into t.barwidth.
349359
var newBarwidth = width.slice(0, calcTrace.length);
350360

361+
// guard against non-numeric items
362+
for(j = 0; j < newBarwidth.length; j++) {
363+
if(!isNumeric(newBarwidth[j])) newBarwidth[j] = initialBarwidth;
364+
}
365+
351366
// if the length of the array is too short,
352367
// then extend it with the initial value of t.barwidth
353368
for(j = newBarwidth.length; j < calcTrace.length; j++) {

0 commit comments

Comments
 (0)