File tree 2 files changed +31
-1
lines changed
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) {
113
113
114
114
calcdata . push ( [ { trace : shapeLegend } ] ) ;
115
115
}
116
- if ( ! calcdata . length ) return ;
116
+
117
117
legendData = fullLayout . showlegend && getLegendData ( calcdata , legendObj , fullLayout . _legends . length > 1 ) ;
118
118
} else {
119
119
if ( ! legendObj . entries ) return ;
Original file line number Diff line number Diff line change @@ -1204,6 +1204,36 @@ describe('legend relayout update', function() {
1204
1204
. then ( done , done . fail ) ;
1205
1205
} ) ;
1206
1206
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
+
1207
1237
it ( 'should be able to add & clear multiple legends using react' , function ( done ) {
1208
1238
var fig1 = {
1209
1239
data : [ {
You can’t perform that action at this time.
0 commit comments