Skip to content

Commit c83839f

Browse files
committed
revise blank bar logic
1 parent 8ebc030 commit c83839f

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/traces/bar/plot.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,29 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback)
140140
var y0 = xy[1][0];
141141
var y1 = xy[1][1];
142142

143-
var isBlank = (
144-
x0 === x1 ||
145-
y0 === y1 ||
146-
!isNumeric(x0) ||
147-
!isNumeric(x1) ||
148-
!isNumeric(y0) ||
149-
!isNumeric(y1)
150-
);
143+
// empty bars
144+
var isBlank = (isHorizontal ? x1 - x0 : y1 - y0) === 0;
151145

152146
// display zeros if line.width > 0
153-
if(isBlank && shouldDisplayZeros &&
154-
helpers.getLineWidth(trace, di) &&
155-
(isHorizontal ? x0 === x1 : y0 === y1)) {
147+
if(isBlank && shouldDisplayZeros && helpers.getLineWidth(trace, di)) {
156148
isBlank = false;
157149
}
150+
151+
// skip nulls
152+
if(!isBlank) {
153+
isBlank = (
154+
!isNumeric(x0) ||
155+
!isNumeric(x1) ||
156+
!isNumeric(y0) ||
157+
!isNumeric(y1)
158+
);
159+
}
160+
161+
// record isBlank
158162
di.isBlank = isBlank;
159163

160-
// for empty bars, ensure start and end positions are equal when having transition
161-
if(isBlank && withTransition) {
164+
// for blank bars, ensure start and end positions are equal - important for smooth transitions
165+
if(isBlank) {
162166
if(isHorizontal) {
163167
x1 = x0;
164168
} else {

0 commit comments

Comments
 (0)