@@ -162,7 +162,7 @@ module.exports = function plot(gd, plotinfo, cdModule, traceLayer) {
162162                . attr ( 'd' ,  isBlank  ? 'M0,0Z'  : 'M'  +  x0  +  ','  +  y0  +  'V'  +  y1  +  'H'  +  x1  +  'V'  +  y0  +  'Z' ) 
163163                . call ( Drawing . setClipUrl ,  plotinfo . layerClipId ,  gd ) ; 
164164
165-             appendBarText ( gd ,  bar ,  cd ,  i ,  x0 ,  x1 ,  y0 ,  y1 ) ; 
165+             appendBarText ( gd ,  plotinfo ,   bar ,  cd ,  i ,  x0 ,  x1 ,  y0 ,  y1 ) ; 
166166
167167            if ( plotinfo . layerClipId )  { 
168168                Drawing . hideOutsideRangePoint ( di ,  bar . select ( 'text' ) ,  xa ,  ya ,  trace . xcalendar ,  trace . ycalendar ) ; 
@@ -179,7 +179,7 @@ module.exports = function plot(gd, plotinfo, cdModule, traceLayer) {
179179    Registry . getComponentMethod ( 'errorbars' ,  'plot' ) ( gd ,  bartraces ,  plotinfo ) ; 
180180} ; 
181181
182- function  appendBarText ( gd ,  bar ,  calcTrace ,  i ,  x0 ,  x1 ,  y0 ,  y1 )  { 
182+ function  appendBarText ( gd ,  plotinfo ,   bar ,  calcTrace ,  i ,  x0 ,  x1 ,  y0 ,  y1 )  { 
183183    var  fullLayout  =  gd . _fullLayout ; 
184184    var  textPosition ; 
185185
@@ -226,6 +226,21 @@ function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) {
226226    var  insideTextFont  =  style . getInsideTextFont ( trace ,  i ,  layoutFont ,  barColor ) ; 
227227    var  outsideTextFont  =  style . getOutsideTextFont ( trace ,  i ,  layoutFont ) ; 
228228
229+     // Special case: don't use the c2p(v, true) value on log size axes, 
230+     // so that we can get correctly inside text scaling 
231+     var  di  =  bar . datum ( ) ; 
232+     if ( orientation  ===  'h' )  { 
233+         var  xa  =  plotinfo . xaxis ; 
234+         if ( xa . type  ===  'log'  &&  di . s0  <=  0 )  { 
235+             x0  =  xa . _length ; 
236+         } 
237+     }  else  { 
238+         var  ya  =  plotinfo . yaxis ; 
239+         if ( ya . type  ===  'log'  &&  di . s0  <=  0 )  { 
240+             y0  =  ya . _length ; 
241+         } 
242+     } 
243+ 
229244    // padding excluded 
230245    var  barWidth  =  Math . abs ( x1  -  x0 )  -  2  *  TEXTPAD ; 
231246    var  barHeight  =  Math . abs ( y1  -  y0 )  -  2  *  TEXTPAD ; 
0 commit comments