Skip to content

Commit

Permalink
Merge pull request #1969 from mackler/fix-error-bars
Browse files Browse the repository at this point in the history
Fix broken error bars in horizontal bar charts.
  • Loading branch information
liquidpele authored Apr 29, 2017
2 parents f78139d + 7969397 commit 6bfd678
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/models/multiBarHorizontal.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ nv.models.multiBarHorizontal = function() {
var xerr = getYerr(d,i)
, mid = 0.8 * x.rangeBand() / ((stacked ? 1 : data.length) * 2);
xerr = xerr.length ? xerr : [-Math.abs(xerr), Math.abs(xerr)];
xerr = xerr.map(function(e) { return y(e) - y(0); });
xerr = xerr.map(function(e) { return y(e + ((getY(d,i) < 0) ? 0 : getY(d,i))) - y(0); });
var a = [[xerr[0],-mid], [xerr[0],mid], [xerr[0],0], [xerr[1],0], [xerr[1],-mid], [xerr[1],mid]];
return a.map(function (path) { return path.join(',') }).join(' ');
})
.attr('transform', function(d,i) {
var mid = x.rangeBand() / ((stacked ? 1 : data.length) * 2);
return 'translate(' + (getY(d,i) < 0 ? 0 : y(getY(d,i)) - y(0)) + ', ' + mid + ')'
return 'translate(0, ' + mid + ')';
});
}

Expand Down

0 comments on commit 6bfd678

Please sign in to comment.