@@ -1335,6 +1335,43 @@ describe('Test histogram', function() {
13351335 } )
13361336 . then ( done , done . fail ) ;
13371337 } ) ;
1338+
1339+ it ( 'should correctly recalculate autobin size for single-value overlays on Plotly.react' , function ( done ) {
1340+ var initialData = [
1341+ { x : [ '1457' ] , type : 'histogram' } ,
1342+ { x : [ '820' ] , type : 'histogram' } ,
1343+ { x : [ '720' ] , type : 'histogram' }
1344+ ] ;
1345+
1346+ var layout = {
1347+ barmode : 'overlay'
1348+ } ;
1349+
1350+ Plotly . newPlot ( gd , initialData , layout )
1351+ . then ( function ( ) {
1352+ // minDiff = 820 - 720 = 100
1353+ console . log ( "gd._fullData=" , gd . _fullData ) ;
1354+ expect ( gd . _fullData [ 0 ] . xbins . size ) . toBe ( 100 ) ;
1355+ expect ( gd . _fullData [ 1 ] . xbins . size ) . toBe ( 100 ) ;
1356+ expect ( gd . _fullData [ 2 ] . xbins . size ) . toBe ( 100 ) ;
1357+
1358+ // Use a new trace data object
1359+ var newData = [
1360+ { x : [ '1400' ] , type : 'histogram' } ,
1361+ { x : [ '800' ] , type : 'histogram' } ,
1362+ { x : [ '600' ] , type : 'histogram' }
1363+ ] ;
1364+
1365+ return Plotly . react ( gd , newData , layout ) ;
1366+ } )
1367+ . then ( function ( ) {
1368+ // minDiff = 800 - 600 = 200.
1369+ expect ( gd . _fullData [ 0 ] . xbins . size ) . toBe ( 200 ) ;
1370+ expect ( gd . _fullData [ 1 ] . xbins . size ) . toBe ( 200 ) ;
1371+ expect ( gd . _fullData [ 2 ] . xbins . size ) . toBe ( 200 ) ;
1372+ } )
1373+ . then ( done , done . fail ) ;
1374+ } ) ;
13381375 } ) ;
13391376} ) ;
13401377
0 commit comments