Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for displaying narrow bars in interactive mode #4568

Merged
merged 8 commits into from
Feb 12, 2020
30 changes: 17 additions & 13 deletions src/traces/bar/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,29 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback)
var y0 = xy[1][0];
var y1 = xy[1][1];

var isBlank = (
x0 === x1 ||
y0 === y1 ||
!isNumeric(x0) ||
!isNumeric(x1) ||
!isNumeric(y0) ||
!isNumeric(y1)
);
// empty bars
var isBlank = (isHorizontal ? x1 - x0 : y1 - y0) === 0;

// display zeros if line.width > 0
if(isBlank && shouldDisplayZeros &&
helpers.getLineWidth(trace, di) &&
(isHorizontal ? x0 === x1 : y0 === y1)) {
if(isBlank && shouldDisplayZeros && helpers.getLineWidth(trace, di)) {
isBlank = false;
}

// skip nulls
if(!isBlank) {
isBlank = (
!isNumeric(x0) ||
!isNumeric(x1) ||
!isNumeric(y0) ||
!isNumeric(y1)
);
}

// record isBlank
di.isBlank = isBlank;

// for empty bars, ensure start and end positions are equal when having transition
if(isBlank && withTransition) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With revised logic, now there is no need for handling transitions differently.

// for blank bars, ensure start and end positions are equal - important for smooth transitions
if(isBlank) {
if(isHorizontal) {
x1 = x0;
} else {
Expand Down