@@ -83,12 +83,11 @@ module.exports = function plot(gd, plotinfo, cdModule, traceLayer) {
8383 di . ct = [ ( x0 + x1 ) / 2 , y1 ] ;
8484 }
8585
86- if ( ! isNumeric ( x0 ) || ! isNumeric ( x1 ) ||
87- ! isNumeric ( y0 ) || ! isNumeric ( y1 ) ||
88- x0 === x1 || y0 === y1 ) {
89- bar . remove ( ) ;
90- return ;
91- }
86+ var isBlank = di . isBlank = (
87+ ! isNumeric ( x0 ) || ! isNumeric ( x1 ) ||
88+ ! isNumeric ( y0 ) || ! isNumeric ( y1 ) ||
89+ x0 === x1 || y0 === y1
90+ ) ;
9291
9392 // in waterfall mode `between` we need to adjust bar end points to match the connector width
9493 if ( adjustPixel ) {
@@ -158,7 +157,7 @@ module.exports = function plot(gd, plotinfo, cdModule, traceLayer) {
158157
159158 Lib . ensureSingle ( bar , 'path' )
160159 . style ( 'vector-effect' , 'non-scaling-stroke' )
161- . attr ( 'd' , 'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z' )
160+ . attr ( 'd' , isBlank ? 'M0,0Z' : 'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z' )
162161 . call ( Drawing . setClipUrl , plotinfo . layerClipId , gd ) ;
163162
164163 appendBarText ( gd , bar , cd , i , x0 , x1 , y0 , y1 ) ;
@@ -206,11 +205,6 @@ function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) {
206205 var text = getText ( trace , i ) ;
207206 textPosition = getTextPosition ( trace , i ) ;
208207
209- if ( ! text || textPosition === 'none' ) {
210- bar . select ( 'text' ) . remove ( ) ;
211- return ;
212- }
213-
214208 var layoutFont = fullLayout . font ;
215209 var barColor = style . getBarColor ( calcTrace [ i ] , trace ) ;
216210 var insideTextFont = style . getInsideTextFont ( trace , i , layoutFont , barColor ) ;
@@ -219,15 +213,20 @@ function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) {
219213 // compute text position
220214 var prefix = trace . type === 'waterfall' ? 'waterfall' : 'bar' ;
221215 var barmode = fullLayout [ prefix + 'mode' ] ;
222- var inStackMode = ( barmode === 'stack' ) ;
223- var inRelativeMode = ( barmode === 'relative' ) ;
224- var inStackOrRelativeMode = inStackMode || inRelativeMode ;
216+ var inStackOrRelativeMode = barmode === 'stack' || barmode === 'relative' ;
225217
226218 var calcBar = calcTrace [ i ] ;
227219 var isOutmostBar = ! inStackOrRelativeMode || calcBar . _outmost ;
228220
229- var barWidth = Math . abs ( x1 - x0 ) - 2 * TEXTPAD ; // padding excluded
230- var barHeight = Math . abs ( y1 - y0 ) - 2 * TEXTPAD ; // padding excluded
221+ // padding excluded
222+ var barWidth = Math . abs ( x1 - x0 ) - 2 * TEXTPAD ;
223+ var barHeight = Math . abs ( y1 - y0 ) - 2 * TEXTPAD ;
224+
225+ if ( ! text || textPosition === 'none' ||
226+ ( calcBar . isBlank && ( textPosition === 'auto' || textPosition === 'inside' ) ) ) {
227+ bar . select ( 'text' ) . remove ( ) ;
228+ return ;
229+ }
231230
232231 var textSelection ;
233232 var textBB ;
@@ -263,7 +262,9 @@ function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) {
263262 textSelection . remove ( ) ;
264263 textSelection = null ;
265264 }
266- } else textPosition = 'inside' ;
265+ } else {
266+ textPosition = 'inside' ;
267+ }
267268 }
268269
269270 if ( ! textSelection ) {
0 commit comments