Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 30bb703

Browse files
committed
Fix line/test cases
1 parent f02f0ee commit 30bb703

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/traces/scattergl/index.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ ScatterRegl.calc = function calc(container, trace) {
190190
lineOptions.thickness = trace.line.width;
191191
lineOptions.color = trace.line.color;
192192
lineOptions.opacity = trace.opacity;
193-
lineOptions.join = trace.opacity === 1.0 ? 'rect' : 'round';
194193
lineOptions.overlay = true;
195194

196195
var dashes = (DASHES[trace.line.dash] || [1]).slice();
@@ -238,6 +237,33 @@ ScatterRegl.calc = function calc(container, trace) {
238237
else {
239238
linePositions = positions;
240239
}
240+
241+
// If we have data with gaps, we ought to use rect joins
242+
// FIXME: get rid of this
243+
var hasNaNs = false;
244+
for (i = 0; i < linePositions.length; i++) {
245+
if (isNaN(linePositions[i])) {
246+
hasNaNs = true;
247+
break;
248+
}
249+
}
250+
lineOptions.join = (hasNaNs || linePositions.length > TOO_MANY_POINTS) && !hasMarkers ? 'rect' : 'round'
251+
252+
// fill gaps
253+
if (hasNaNs && trace.connectgaps) {
254+
var lastX = linePositions[0], lastY = linePositions[1];
255+
for (i = 0; i < linePositions.length; i+=2) {
256+
if (isNaN(linePositions[i]) || isNaN(linePositions[i + 1])) {
257+
linePositions[i] = lastX
258+
linePositions[i + 1] = lastY
259+
}
260+
else {
261+
lastX = linePositions[i];
262+
lastY = linePositions[i + 1];
263+
}
264+
}
265+
}
266+
241267
lineOptions.positions = linePositions;
242268
}
243269

@@ -360,7 +386,6 @@ ScatterRegl.calc = function calc(container, trace) {
360386
Axes.expand(yaxis, y, { padded: true, ppad: sizes });
361387
}
362388
else {
363-
// console.log(x, xOptions, xa._min)
364389
var size = scatterOptions.size = markerSizeFunc(markerOpts && markerOpts.size || 10);
365390
scatterOptions.borderSizes = markerOpts.line.width * 0.5;
366391

@@ -479,6 +504,12 @@ ScatterRegl.calc = function calc(container, trace) {
479504
scene.draw();
480505
}
481506
}
507+
else {
508+
if (hasFill && !scene.fill2d) scene.fill2d = true;
509+
if (hasMarkers && !scene.marker2d) scene.marker2d = true;
510+
if (hasLines && !scene.line2d) scene.line2d = true;
511+
if (hasError && !scene.error2d) scene.error2d = true;
512+
}
482513

483514
// In case if we have scene from the last calc - reset data
484515
if(!scene.dirty) {

0 commit comments

Comments
 (0)