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