@@ -259,15 +259,28 @@ function sceneUpdate(gd, subplot) {
259
259
// draw traces in proper order
260
260
scene . draw = function draw ( ) {
261
261
var i ;
262
+ var allReadyDrawLines = Lib . repeat ( false , scene . count ) ;
263
+ var allReadyDrawMarkers = Lib . repeat ( false , scene . count ) ;
262
264
for ( i = 0 ; i < scene . count ; i ++ ) {
263
265
if ( scene . fill2d && scene . fillOptions [ i ] ) {
264
266
// must do all fills first
265
267
scene . fill2d . draw ( i ) ;
268
+ if ( scene . line2d && scene . lineOptions [ i ] && ( scene . fillOptions [ i ] . fillmode === 'tozeroy' || scene . fillOptions [ i ] . fillmode === 'tozerox' ) ) {
269
+ scene . line2d . draw ( i ) ;
270
+ allReadyDrawLines [ i ] = true ;
271
+ }
272
+ if ( scene . scatter2d && scene . markerOptions [ i ] && ( ! scene . selectBatch || ! scene . selectBatch [ i ] ) && ( scene . fillOptions [ i ] . fillmode === 'tozeroy' || scene . fillOptions [ i ] . fillmode === 'tozerox' ) ) {
273
+ // traces in no-selection mode
274
+ scene . scatter2d . draw ( i ) ;
275
+ allReadyDrawMarkers [ i ] = true ;
276
+ }
266
277
}
267
278
}
268
279
for ( i = 0 ; i < scene . count ; i ++ ) {
269
280
if ( scene . line2d && scene . lineOptions [ i ] ) {
270
- scene . line2d . draw ( i ) ;
281
+ if ( ! allReadyDrawLines [ i ] ) {
282
+ scene . line2d . draw ( i ) ;
283
+ }
271
284
}
272
285
if ( scene . error2d && scene . errorXOptions [ i ] ) {
273
286
scene . error2d . draw ( i ) ;
@@ -277,7 +290,9 @@ function sceneUpdate(gd, subplot) {
277
290
}
278
291
if ( scene . scatter2d && scene . markerOptions [ i ] && ( ! scene . selectBatch || ! scene . selectBatch [ i ] ) ) {
279
292
// traces in no-selection mode
280
- scene . scatter2d . draw ( i ) ;
293
+ if ( ! allReadyDrawMarkers [ i ] ) {
294
+ scene . scatter2d . draw ( i ) ;
295
+ }
281
296
}
282
297
}
283
298
@@ -419,6 +434,24 @@ function plot(gd, subplot, cdata) {
419
434
}
420
435
if ( scene . line2d ) {
421
436
scene . line2d . update ( scene . lineOptions ) ;
437
+ scene . lineOptions = scene . lineOptions . map ( function ( lineOptions ) {
438
+ if ( lineOptions && lineOptions . positions ) {
439
+ var pos = [ ] , srcPos = lineOptions . positions ;
440
+
441
+ var firstptdef = 0 ;
442
+ while ( isNaN ( srcPos [ firstptdef ] ) || isNaN ( srcPos [ firstptdef + 1 ] ) ) {
443
+ firstptdef += 2 ;
444
+ }
445
+ var lastptdef = srcPos . length - 2 ;
446
+ while ( isNaN ( srcPos [ lastptdef ] ) || isNaN ( srcPos [ lastptdef + 1 ] ) ) {
447
+ lastptdef += - 2 ;
448
+ }
449
+ pos = pos . concat ( srcPos . slice ( firstptdef , lastptdef + 2 ) ) ;
450
+ lineOptions . positions = pos ;
451
+ }
452
+ return lineOptions ;
453
+ } ) ;
454
+ scene . line2d . update ( scene . lineOptions ) ;
422
455
}
423
456
if ( scene . error2d ) {
424
457
var errorBatch = ( scene . errorXOptions || [ ] ) . concat ( scene . errorYOptions || [ ] ) ;
@@ -441,16 +474,38 @@ function plot(gd, subplot, cdata) {
441
474
var pos = [ ] , srcPos = ( lineOptions && lineOptions . positions ) || stash . positions ;
442
475
443
476
if ( trace . fill === 'tozeroy' ) {
444
- pos = [ srcPos [ 0 ] , 0 ] ;
445
- pos = pos . concat ( srcPos ) ;
446
- pos . push ( srcPos [ srcPos . length - 2 ] ) ;
447
- pos . push ( 0 ) ;
477
+ var firstpdef = 0 ;
478
+ while ( isNaN ( srcPos [ firstpdef + 1 ] ) ) {
479
+ firstpdef += 2 ;
480
+ }
481
+ var lastpdef = srcPos . length - 2 ;
482
+ while ( isNaN ( srcPos [ lastpdef + 1 ] ) ) {
483
+ lastpdef += - 2 ;
484
+ }
485
+ if ( srcPos [ firstpdef + 1 ] !== 0 ) {
486
+ pos = [ srcPos [ firstpdef ] , 0 ] ;
487
+ }
488
+ pos = pos . concat ( srcPos . slice ( firstpdef , lastpdef + 2 ) ) ;
489
+ if ( srcPos [ lastpdef + 1 ] !== 0 ) {
490
+ pos = pos . concat ( [ srcPos [ lastpdef ] , 0 ] ) ;
491
+ }
448
492
}
449
493
else if ( trace . fill === 'tozerox' ) {
450
- pos = [ 0 , srcPos [ 1 ] ] ;
451
- pos = pos . concat ( srcPos ) ;
452
- pos . push ( 0 ) ;
453
- pos . push ( srcPos [ srcPos . length - 1 ] ) ;
494
+ var firstptdef = 0 ;
495
+ while ( isNaN ( srcPos [ firstptdef ] ) ) {
496
+ firstptdef += 2 ;
497
+ }
498
+ var lastptdef = srcPos . length - 2 ;
499
+ while ( isNaN ( srcPos [ lastptdef ] ) ) {
500
+ lastptdef += - 2 ;
501
+ }
502
+ if ( srcPos [ firstptdef ] !== 0 ) {
503
+ pos = [ 0 , srcPos [ firstptdef + 1 ] ] ;
504
+ }
505
+ pos = pos . concat ( srcPos . slice ( firstptdef , lastptdef + 2 ) ) ;
506
+ if ( srcPos [ lastptdef ] !== 0 ) {
507
+ pos = pos . concat ( [ 0 , srcPos [ lastptdef + 1 ] ] ) ;
508
+ }
454
509
}
455
510
else if ( trace . fill === 'toself' || trace . fill === 'tonext' ) {
456
511
pos = [ ] ;
@@ -508,7 +563,8 @@ function plot(gd, subplot, cdata) {
508
563
pos = pos . concat ( prevLinePos ) ;
509
564
fillOptions . hole = hole ;
510
565
}
511
-
566
+
567
+ fillOptions . fillmode = trace . fill ;
512
568
fillOptions . opacity = trace . opacity ;
513
569
fillOptions . positions = pos ;
514
570
0 commit comments