@@ -383,6 +383,60 @@ describe('end-to-end scatter tests', function() {
383
383
expect ( Plotly . d3 . selectAll ( '.textpoint' ) . size ( ) ) . toBe ( 3 ) ;
384
384
} ) . catch ( fail ) . then ( done ) ;
385
385
} ) ;
386
+
387
+ it ( 'should remove all point and text nodes on blank data' , function ( done ) {
388
+ function assertNodeCnt ( ptCnt , txCnt ) {
389
+ expect ( d3 . selectAll ( '.point' ) . size ( ) ) . toEqual ( ptCnt ) ;
390
+ expect ( d3 . selectAll ( '.textpoint' ) . size ( ) ) . toEqual ( txCnt ) ;
391
+ }
392
+
393
+ function assertText ( content ) {
394
+ d3 . selectAll ( '.textpoint' ) . each ( function ( _ , i ) {
395
+ var tx = d3 . select ( this ) . select ( 'text' ) ;
396
+ expect ( tx . text ( ) ) . toEqual ( content [ i ] ) ;
397
+ } ) ;
398
+ }
399
+
400
+ Plotly . plot ( gd , [ {
401
+ x : [ 150 , 350 , 650 ] ,
402
+ y : [ 100 , 300 , 600 ] ,
403
+ text : [ 'A' , 'B' , 'C' ] ,
404
+ mode : 'markers+text' ,
405
+ marker : {
406
+ size : [ 100 , 200 , 300 ] ,
407
+ line : { width : [ 10 , 20 , 30 ] } ,
408
+ color : 'yellow' ,
409
+ sizeref : 3 ,
410
+ gradient : {
411
+ type : 'radial' ,
412
+ color : 'white'
413
+ }
414
+ }
415
+ } ] )
416
+ . then ( function ( ) {
417
+ assertNodeCnt ( 3 , 3 ) ;
418
+ assertText ( [ 'A' , 'B' , 'C' ] ) ;
419
+
420
+ return Plotly . restyle ( gd , {
421
+ x : [ [ null , undefined , NaN ] ] ,
422
+ y : [ [ NaN , null , undefined ] ]
423
+ } ) ;
424
+ } )
425
+ . then ( function ( ) {
426
+ assertNodeCnt ( 0 , 0 ) ;
427
+
428
+ return Plotly . restyle ( gd , {
429
+ x : [ [ 150 , 350 , 650 ] ] ,
430
+ y : [ [ 100 , 300 , 600 ] ]
431
+ } ) ;
432
+ } )
433
+ . then ( function ( ) {
434
+ assertNodeCnt ( 3 , 3 ) ;
435
+ assertText ( [ 'A' , 'B' , 'C' ] ) ;
436
+ } )
437
+ . catch ( fail )
438
+ . then ( done ) ;
439
+ } ) ;
386
440
} ) ;
387
441
388
442
describe ( 'scatter hoverPoints' , function ( ) {
0 commit comments