@@ -323,6 +323,10 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
323323
324324 Drawing . setClipUrl ( lineJoin , plotinfo . layerClipId ) ;
325325
326+ function clearFill ( selection ) {
327+ transition ( selection ) . attr ( 'd' , 'M0,0Z' ) ;
328+ }
329+
326330 if ( segments . length ) {
327331 if ( ownFillEl3 ) {
328332 if ( pt0 && pt1 ) {
@@ -348,30 +352,41 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
348352 }
349353 }
350354 }
351- else if ( trace . fill . substr ( 0 , 6 ) === 'tonext' && fullpath && prevRevpath ) {
352- // fill to next: full trace path, plus the previous path reversed
353- if ( trace . fill === 'tonext' ) {
354- // tonext: for use by concentric shapes, like manually constructed
355- // contours, we just add the two paths closed on themselves.
356- // This makes strange results if one path is *not* entirely
357- // inside the other, but then that is a strange usage.
358- transition ( tonext ) . attr ( 'd' , fullpath + 'Z' + prevRevpath + 'Z' )
359- . call ( Drawing . singleFillStyle ) ;
355+ else if ( tonext ) {
356+ if ( trace . fill . substr ( 0 , 6 ) === 'tonext' && fullpath && prevRevpath ) {
357+ // fill to next: full trace path, plus the previous path reversed
358+ if ( trace . fill === 'tonext' ) {
359+ // tonext: for use by concentric shapes, like manually constructed
360+ // contours, we just add the two paths closed on themselves.
361+ // This makes strange results if one path is *not* entirely
362+ // inside the other, but then that is a strange usage.
363+ transition ( tonext ) . attr ( 'd' , fullpath + 'Z' + prevRevpath + 'Z' )
364+ . call ( Drawing . singleFillStyle ) ;
365+ }
366+ else {
367+ // tonextx/y: for now just connect endpoints with lines. This is
368+ // the correct behavior if the endpoints are at the same value of
369+ // y/x, but if they *aren't*, we should ideally do more complicated
370+ // things depending on whether the new endpoint projects onto the
371+ // existing curve or off the end of it
372+ transition ( tonext ) . attr ( 'd' , fullpath + 'L' + prevRevpath . substr ( 1 ) + 'Z' )
373+ . call ( Drawing . singleFillStyle ) ;
374+ }
375+ trace . _polygons = trace . _polygons . concat ( prevPolygons ) ;
360376 }
361377 else {
362- // tonextx/y: for now just connect endpoints with lines. This is
363- // the correct behavior if the endpoints are at the same value of
364- // y/x, but if they *aren't*, we should ideally do more complicated
365- // things depending on whether the new endpoint projects onto the
366- // existing curve or off the end of it
367- transition ( tonext ) . attr ( 'd' , fullpath + 'L' + prevRevpath . substr ( 1 ) + 'Z' )
368- . call ( Drawing . singleFillStyle ) ;
378+ clearFill ( tonext ) ;
379+ trace . _polygons = null ;
369380 }
370- trace . _polygons = trace . _polygons . concat ( prevPolygons ) ;
371381 }
372382 trace . _prevRevpath = revpath ;
373383 trace . _prevPolygons = thisPolygons ;
374384 }
385+ else {
386+ if ( ownFillEl3 ) clearFill ( ownFillEl3 ) ;
387+ else if ( tonext ) clearFill ( tonext ) ;
388+ trace . _polygons = trace . _prevRevpath = trace . _prevPolygons = null ;
389+ }
375390
376391
377392 function visFilter ( d ) {
0 commit comments