Skip to content

Commit f9d6151

Browse files
committed
fix scattergl uneven array handling
1 parent 4197c32 commit f9d6151

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

src/traces/scattergl/index.js

+8-25
Original file line numberDiff line numberDiff line change
@@ -69,36 +69,19 @@ function calc(container, trace) {
6969
}
7070

7171
// get log converted positions
72-
var rawx, rawy;
73-
if(xaxis.type === 'log') {
74-
rawx = x.slice(0, count);
75-
for(i = 0; i < count; i++) {
76-
x[i] = xaxis.d2l(x[i]);
77-
}
78-
}
79-
else {
80-
rawx = x;
81-
for(i = 0; i < count; i++) {
82-
x[i] = parseFloat(x[i]);
83-
}
84-
}
85-
if(yaxis.type === 'log') {
86-
rawy = y.slice(0, count);
87-
for(i = 0; i < count; i++) {
88-
y[i] = yaxis.d2l(y[i]);
89-
}
90-
}
91-
else {
92-
rawy = y;
93-
for(i = 0; i < count; i++) {
94-
y[i] = parseFloat(y[i]);
95-
}
96-
}
72+
var rawx = (xaxis.type === 'log' || x.length > count) ? x.slice(0, count) : x;
73+
var rawy = (yaxis.type === 'log' || y.length > count) ? y.slice(0, count) : y;
74+
75+
var convertX = (xaxis.type === 'log') ? xaxis.d2l : parseFloat;
76+
var convertY = (yaxis.type === 'log') ? yaxis.d2l : parseFloat;
9777

9878
// we need hi-precision for scatter2d
9979
positions = new Array(count * 2);
10080

10181
for(i = 0; i < count; i++) {
82+
x[i] = convertX(x[i]);
83+
y[i] = convertY(y[i]);
84+
10285
// if no x defined, we are creating simple int sequence (API)
10386
// we use parseFloat because it gives NaN (we need that for empty values to avoid drawing lines) and it is incredibly fast
10487
xx = isNumeric(x[i]) ? +x[i] : NaN;

0 commit comments

Comments
 (0)