@@ -33,12 +33,15 @@ function LineWithMarkers(scene, uid) {
33
33
this . scene = scene ;
34
34
this . uid = uid ;
35
35
36
+ this . pickXData = [ ] ;
37
+ this . pickYData = [ ] ;
36
38
this . xData = [ ] ;
37
39
this . yData = [ ] ;
38
40
this . textLabels = [ ] ;
39
41
this . color = 'rgb(0, 0, 0)' ;
40
42
this . name = '' ;
41
43
this . hoverinfo = 'all' ;
44
+ this . connectgaps = true ;
42
45
43
46
this . idToIndex = [ ] ;
44
47
this . bounds = [ 0 , 0 , 0 , 0 ] ;
@@ -103,14 +106,17 @@ function LineWithMarkers(scene, uid) {
103
106
var proto = LineWithMarkers . prototype ;
104
107
105
108
proto . handlePick = function ( pickResult ) {
106
- var index = this . idToIndex [ pickResult . pointId ] ;
109
+ var index = pickResult . pointId ;
110
+ if ( pickResult . object !== this . line || this . connectgaps ) {
111
+ index = this . idToIndex [ pickResult . pointId ] ;
112
+ }
107
113
108
114
return {
109
115
trace : this ,
110
116
dataCoord : pickResult . dataCoord ,
111
117
traceCoord : [
112
- this . xData [ index ] ,
113
- this . yData [ index ]
118
+ this . pickXData [ index ] ,
119
+ this . pickYData [ index ]
114
120
] ,
115
121
textLabel : Array . isArray ( this . textLabels ) ?
116
122
this . textLabels [ index ] :
@@ -248,6 +254,7 @@ proto.update = function(options) {
248
254
this . name = options . name ;
249
255
this . hoverinfo = options . hoverinfo ;
250
256
this . bounds = [ Infinity , Infinity , - Infinity , - Infinity ] ;
257
+ this . connectgaps = ! ! options . connectgaps ;
251
258
252
259
if ( this . isFancy ( options ) ) {
253
260
this . updateFancy ( options ) ;
@@ -262,8 +269,8 @@ proto.update = function(options) {
262
269
} ;
263
270
264
271
proto . updateFast = function ( options ) {
265
- var x = this . xData = options . x ;
266
- var y = this . yData = options . y ;
272
+ var x = this . xData = this . pickXData = options . x ;
273
+ var y = this . yData = this . pickYData = options . y ;
267
274
268
275
var len = x . length ,
269
276
idToIndex = new Array ( len ) ,
@@ -344,8 +351,11 @@ proto.updateFancy = function(options) {
344
351
bounds = this . bounds ;
345
352
346
353
// makeCalcdata runs d2c (data-to-coordinate) on every point
347
- var x = this . xData = xaxis . makeCalcdata ( options , 'x' ) ;
348
- var y = this . yData = yaxis . makeCalcdata ( options , 'y' ) ;
354
+ var x = this . pickXData = xaxis . makeCalcdata ( options , 'x' ) . slice ( ) ;
355
+ var y = this . pickYData = yaxis . makeCalcdata ( options , 'y' ) . slice ( ) ;
356
+
357
+ this . xData = x . slice ( ) ;
358
+ this . yData = y . slice ( ) ;
349
359
350
360
// get error values
351
361
var errorVals = ErrorBars . calcFromTrace ( options , scene . fullLayout ) ;
@@ -370,8 +380,8 @@ proto.updateFancy = function(options) {
370
380
var i , j , xx , yy , ex0 , ex1 , ey0 , ey1 ;
371
381
372
382
for ( i = 0 ; i < len ; ++ i ) {
373
- xx = getX ( x [ i ] ) ;
374
- yy = getY ( y [ i ] ) ;
383
+ this . xData [ i ] = xx = getX ( x [ i ] ) ;
384
+ this . yData [ i ] = yy = getY ( y [ i ] ) ;
375
385
376
386
if ( isNaN ( xx ) || isNaN ( yy ) ) continue ;
377
387
@@ -460,16 +470,29 @@ proto.updateFancy = function(options) {
460
470
} ;
461
471
462
472
proto . updateLines = function ( options , positions ) {
473
+ var i ;
463
474
if ( this . hasLines ) {
464
- this . lineOptions . positions = positions ;
475
+ var linePositions = positions ;
476
+ if ( ! options . connectgaps ) {
477
+ var p = 0 ;
478
+ var x = this . xData ;
479
+ var y = this . yData ;
480
+ linePositions = new Float32Array ( 2 * x . length ) ;
481
+
482
+ for ( i = 0 ; i < x . length ; ++ i ) {
483
+ linePositions [ p ++ ] = x [ i ] ;
484
+ linePositions [ p ++ ] = y [ i ] ;
485
+ }
486
+ }
487
+ this . lineOptions . positions = linePositions ;
465
488
466
489
var lineColor = str2RGBArray ( options . line . color ) ;
467
490
if ( this . hasMarkers ) lineColor [ 3 ] *= options . marker . opacity ;
468
491
469
492
var lineWidth = Math . round ( 0.5 * this . lineOptions . width ) ,
470
493
dashes = ( DASHES [ options . line . dash ] || [ 1 ] ) . slice ( ) ;
471
494
472
- for ( var i = 0 ; i < dashes . length ; ++ i ) dashes [ i ] *= lineWidth ;
495
+ for ( i = 0 ; i < dashes . length ; ++ i ) dashes [ i ] *= lineWidth ;
473
496
474
497
switch ( options . fill ) {
475
498
case 'tozeroy' :
0 commit comments