@@ -216,6 +216,77 @@ describe('end-to-end scattergl tests', function() {
216216 . then ( done , done . fail ) ;
217217 } ) ;
218218
219+ it ( '@gl should clear error bars when toggling traces with mixed error bars' , function ( done ) {
220+ function assertNoStaleErrorGroups ( scene , msg ) {
221+ scene . error2d . groups . forEach ( function ( group , i ) {
222+ var hasSceneOptions = i < scene . count ?
223+ scene . errorXOptions [ i ] :
224+ scene . errorYOptions [ i - scene . count ] ;
225+
226+ if ( ! hasSceneOptions && group ) {
227+ expect ( group . count ) . toBe ( 0 , msg + ': group ' + i ) ;
228+ }
229+ } ) ;
230+ }
231+
232+ function assertVisibleErrorBars ( msg , exp ) {
233+ var scene = gd . _fullLayout . _plots . xy . _scene ;
234+ var countSceneErrorYOptions = scene . errorYOptions . filter ( function ( opts ) { return opts ; } ) . length ;
235+ var countDrawableErrorGroups = scene . error2d . groups . filter ( function ( group ) { return group && group . count ; } ) . length ;
236+
237+ expect ( countSceneErrorYOptions ) . toBe ( exp , msg + ' scene options' ) ;
238+ expect ( countDrawableErrorGroups ) . toBe ( exp , msg + ' renderer groups' ) ;
239+ assertNoStaleErrorGroups ( scene , msg ) ;
240+ }
241+
242+ Plotly . newPlot ( gd , [ {
243+ type : 'scattergl' ,
244+ mode : 'lines' ,
245+ name : 'no error 1' ,
246+ x : [ 0 , 1 , 2 ] ,
247+ y : [ 0 , 1 , 0 ]
248+ } , {
249+ type : 'scattergl' ,
250+ mode : 'lines' ,
251+ name : 'my' ,
252+ x : [ 0 , 1 , 2 ] ,
253+ y : [ 1 , 2 , 1 ] ,
254+ error_y : { value : 0.2 }
255+ } , {
256+ type : 'scattergl' ,
257+ mode : 'lines' ,
258+ name : 'no error 2' ,
259+ x : [ 0 , 1 , 2 ] ,
260+ y : [ 2 , 3 , 2 ]
261+ } , {
262+ type : 'scattergl' ,
263+ mode : 'lines' ,
264+ name : 'mz' ,
265+ x : [ 0 , 1 , 2 ] ,
266+ y : [ 3 , 4 , 3 ] ,
267+ error_y : { value : 0.2 }
268+ } ] )
269+ . then ( function ( ) {
270+ assertVisibleErrorBars ( 'base' , 2 ) ;
271+
272+ return Plotly . restyle ( gd , 'visible' , 'legendonly' , [ 3 ] ) ;
273+ } )
274+ . then ( function ( ) {
275+ assertVisibleErrorBars ( 'after hiding last error trace' , 1 ) ;
276+
277+ return Plotly . restyle ( gd , 'visible' , true , [ 3 ] ) ;
278+ } )
279+ . then ( function ( ) {
280+ assertVisibleErrorBars ( 'after showing last error trace' , 2 ) ;
281+
282+ return Plotly . restyle ( gd , 'visible' , 'legendonly' , [ 1 ] ) ;
283+ } )
284+ . then ( function ( ) {
285+ assertVisibleErrorBars ( 'after hiding first error trace' , 1 ) ;
286+ } )
287+ . then ( done , done . fail ) ;
288+ } ) ;
289+
219290 it ( '@gl should change plot type with incomplete data' , function ( done ) {
220291 Plotly . newPlot ( gd , [ { } ] )
221292 . then ( function ( ) {
0 commit comments