From 79693973521e4834c7952fd0ec5a4081de234160 Mon Sep 17 00:00:00 2001 From: Adam Mackler Date: Fri, 17 Feb 2017 13:01:14 -0500 Subject: [PATCH] Fix broken error bars in horizontal bar charts. --- src/models/multiBarHorizontal.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/multiBarHorizontal.js b/src/models/multiBarHorizontal.js index a9935ad39b..10f6a71fef 100644 --- a/src/models/multiBarHorizontal.js +++ b/src/models/multiBarHorizontal.js @@ -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 + ')'; }); }