File tree 2 files changed +40
-3
lines changed
2 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -52,10 +52,13 @@ proto.update = function(graphInfo, buttons) {
52
52
else this . element . className = 'modebar' ;
53
53
54
54
// if buttons or logo have changed, redraw modebar interior
55
- var needsNewButtons = ! this . hasButtons ( buttons ) ,
56
- needsNewLogo = ( this . hasLogo !== context . displaylogo ) ;
55
+ var needsNewButtons = ! this . hasButtons ( buttons ) ;
56
+ var needsNewLogo = ( this . hasLogo !== context . displaylogo ) ;
57
+ var needsNewLocale = ( this . locale !== context . locale ) ;
57
58
58
- if ( needsNewButtons || needsNewLogo ) {
59
+ this . locale = context . locale ;
60
+
61
+ if ( needsNewButtons || needsNewLogo || needsNewLocale ) {
59
62
this . removeAllButtons ( ) ;
60
63
61
64
this . updateButtons ( buttons ) ;
Original file line number Diff line number Diff line change @@ -369,4 +369,38 @@ describe('localization', function() {
369
369
. catch ( failTest )
370
370
. then ( done ) ;
371
371
} ) ;
372
+
373
+ it ( 'updates ticks and modebar tooltips on Plotly.react' , function ( done ) {
374
+ Plotly . register ( {
375
+ moduleType : 'locale' ,
376
+ name : 'xx' ,
377
+ dictionary : { Zoom : 'Bigger' } ,
378
+ format : { month : '%Y %b' }
379
+ } ) ;
380
+
381
+ function getZoomTip ( ) {
382
+ return gd . querySelector ( '.modebar-btn[data-val="zoom"]' ) . getAttribute ( 'data-title' ) ;
383
+ }
384
+
385
+ plot ( 'en' )
386
+ . then ( function ( ) {
387
+ expect ( firstXLabel ( ) ) . toBe ( 'Jan 2001' ) ;
388
+ expect ( getZoomTip ( ) ) . toBe ( 'Zoom' ) ;
389
+
390
+ return Plotly . react ( gd , gd . data , gd . layout , { locale : 'xx' } ) ;
391
+ } )
392
+ . then ( function ( ) {
393
+ expect ( firstXLabel ( ) ) . toBe ( '2001 Jan' ) ;
394
+ expect ( getZoomTip ( ) ) . toBe ( 'Bigger' ) ;
395
+
396
+ // this is discouraged usage, but it works
397
+ return Plotly . plot ( gd , [ ] , { } , { locale : 'en' } ) ;
398
+ } )
399
+ . then ( function ( ) {
400
+ expect ( firstXLabel ( ) ) . toBe ( 'Jan 2001' ) ;
401
+ expect ( getZoomTip ( ) ) . toBe ( 'Zoom' ) ;
402
+ } )
403
+ . catch ( failTest )
404
+ . then ( done ) ;
405
+ } ) ;
372
406
} ) ;
You can’t perform that action at this time.
0 commit comments