File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ function drawOne(gd, opts) {
113113
114114 calcdata . push ( [ { trace : shapeLegend } ] ) ;
115115 }
116- if ( ! calcdata . length ) return ;
116+
117117 legendData = fullLayout . showlegend && getLegendData ( calcdata , legendObj , fullLayout . _legends . length > 1 ) ;
118118 } else {
119119 if ( ! legendObj . entries ) return ;
Original file line number Diff line number Diff line change @@ -1204,6 +1204,36 @@ describe('legend relayout update', function() {
12041204 . then ( done , done . fail ) ;
12051205 } ) ;
12061206
1207+ it ( 'should clear an empty legend & add legend using react' , function ( done ) {
1208+ var fig1 = {
1209+ data : [ { y : [ 1 , 2 ] } ] ,
1210+ layout : { showlegend : true }
1211+ } ;
1212+
1213+ var fig2 = {
1214+ data : [ ] ,
1215+ layout : { showlegend : true }
1216+ } ;
1217+
1218+ Plotly . newPlot ( gd , fig1 )
1219+ . then ( function ( ) {
1220+ expect ( d3SelectAll ( '.legend' ) [ 0 ] . length ) . toBe ( 1 ) ;
1221+ } )
1222+ . then ( function ( ) {
1223+ return Plotly . react ( gd , fig2 ) ;
1224+ } )
1225+ . then ( function ( ) {
1226+ expect ( d3SelectAll ( '.legend' ) [ 0 ] . length ) . toBe ( 0 ) ;
1227+ } )
1228+ . then ( function ( ) {
1229+ return Plotly . react ( gd , fig1 ) ;
1230+ } )
1231+ . then ( function ( ) {
1232+ expect ( d3SelectAll ( '.legend' ) [ 0 ] . length ) . toBe ( 1 ) ;
1233+ } )
1234+ . then ( done , done . fail ) ;
1235+ } ) ;
1236+
12071237 it ( 'should be able to add & clear multiple legends using react' , function ( done ) {
12081238 var fig1 = {
12091239 data : [ {
You can’t perform that action at this time.
0 commit comments