diff --git a/examples/multiChart.html b/examples/multiChart.html index 033e2563f..03db19f71 100644 --- a/examples/multiChart.html +++ b/examples/multiChart.html @@ -7,6 +7,11 @@ + + + + + @@ -30,48 +60,144 @@ - + \ No newline at end of file diff --git a/src/models/multiBar.js b/src/models/multiBar.js index 628d933f4..db1077a64 100644 --- a/src/models/multiBar.js +++ b/src/models/multiBar.js @@ -226,7 +226,15 @@ nv.models.multiBar = function() { .attr('y', function(d,i,j) { return y0(stacked && !data[j].nonStackable ? d.y0 : 0) || 0 }) .attr('height', 0) .attr('width', function(d,i,j) { return x.rangeBand() / (stacked && !data[j].nonStackable ? 1 : data.length) }) - .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; }) + //.attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; }) + .attr('transform', function(d,i) { + var w = (x.rangeBand() / (stacked && !data[j].nonStackable ? 1 : data.length)); + var sectionWidth = availableWidth/(bars.enter()[0].length - 1); + if(bars.enter().length == 2) + return 'translate(' + ((i-1)*w + i*w + (i*(sectionWidth - 2*w))) + ',0)'; + else + return 'translate(' + ((i-0.5)*w + i*(sectionWidth - w)) + ',0)'; + }) ; bars .style('fill', function(d,i,j){ return color(d, j, i); }) @@ -280,8 +288,15 @@ nv.models.multiBar = function() { }); bars .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'}) - .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; }) - + //.attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; }) + .attr('transform', function(d,i) { + var w = (x.rangeBand() / (stacked && !data[j].nonStackable ? 1 : data.length)); + var sectionWidth = availableWidth/(bars.enter()[0].length - 1); + if(bars.enter().length == 2) + return 'translate(' + ((i-1)*w + i*w + (i*(sectionWidth - 2*w))) + ',0)'; + else + return 'translate(' + ((i-0.5)*w + i*(sectionWidth - w)) + ',0)'; + }) if (barColor) { if (!disabled) disabled = data.map(function() { return true }); bars diff --git a/test/mocha/differenceChart.js b/test/mocha/differenceChart.js index 58bf96b21..b7cc9816b 100644 --- a/test/mocha/differenceChart.js +++ b/test/mocha/differenceChart.js @@ -217,35 +217,6 @@ describe('Processing Data', function () { it('should does not process data if series toggled off', function () { builder.model.showPredictedLine(false); -<<<<<<< HEAD - var expectedData = [{ - key: 'Predicted Data minus Actual Data (Predicted > Actual)', - type: 'area', - values: [{ x: 123, y0: 10, y1: 15 }, { x: 124, y0: 20, y1: 25 }], - yAxis: 1, - color: 'rgba(44,160,44,.9)', - processed: true, - noHighlightSeries: true - }, - { - key: 'Predicted Data minus Actual Data (Predicted < Actual)', - type: 'area', - values: [{ x: 123, y0: 10, y1: 10 }, { x: 124, y0: 20, y1: 20 }], - yAxis: 1, - color: 'rgba(234,39,40,.9)', - processed: true, - noHighlightSeries: true - }, - { - key: 'Actual Data', - type: 'line', - values: [{ x: 123, y: 10 }, { x: 124, y: 20 }], - yAxis: 1, - color: '#666666', - processed: true, - strokeWidth: 1 - }]; -======= var expectedData = [ { key: 'Predicted Data minus Actual Data (Predicted > Actual)',