@@ -574,31 +574,42 @@ function calcTexttemplate(fullLayout, calcTrace, index, xa, ya) {
574574 var trace = calcTrace [ 0 ] . trace ;
575575 var texttemplate = Lib . castOption ( trace , index , 'texttemplate' ) ;
576576 if ( ! texttemplate ) return '' ;
577- var isHorizontal = ( trace . orientation === 'h' ) ;
578577 var isWaterfall = ( trace . type === 'waterfall' ) ;
579578 var isFunnel = ( trace . type === 'funnel' ) ;
580579
580+ var pLetter , pAxis ;
581+ var vLetter , vAxis ;
582+ if ( trace . orientation === 'h' ) {
583+ pLetter = 'y' ;
584+ pAxis = ya ;
585+ vLetter = 'x' ;
586+ vAxis = xa ;
587+ } else {
588+ pLetter = 'x' ;
589+ pAxis = xa ;
590+ vLetter = 'y' ;
591+ vAxis = ya ;
592+ }
593+
581594 function formatLabel ( u ) {
582- var pAxis = isHorizontal ? ya : xa ;
583595 return tickText ( pAxis , u , true ) . text ;
584596 }
585597
586598 function formatNumber ( v ) {
587- var sAxis = isHorizontal ? xa : ya ;
588- return tickText ( sAxis , + v , true ) . text ;
599+ return tickText ( vAxis , + v , true ) . text ;
589600 }
590601
591602 var cdi = calcTrace [ index ] ;
592603 var obj = { } ;
593604
594605 obj . label = cdi . p ;
595- obj . labelLabel = formatLabel ( cdi . p ) ;
606+ obj . labelLabel = obj [ pLetter + 'Label' ] = formatLabel ( cdi . p ) ;
596607
597608 var tx = Lib . castOption ( trace , cdi . i , 'text' ) ;
598609 if ( tx === 0 || tx ) obj . text = tx ;
599610
600611 obj . value = cdi . s ;
601- obj . valueLabel = formatNumber ( cdi . s ) ;
612+ obj . valueLabel = obj [ vLetter + 'Label' ] = formatNumber ( cdi . s ) ;
602613
603614 var pt = { } ;
604615 appendArrayPointValue ( pt , trace , cdi . i ) ;
0 commit comments