Skip to content

Commit

Permalink
Issue #281 bars on multibar and discretebar now are 1 px high even if…
Browse files Browse the repository at this point in the history
… they are 0
  • Loading branch information
bobmonteverde committed Oct 25, 2012
1 parent b0947dc commit cf9bb41
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions nv.d3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2248,13 +2248,13 @@ nv.models.discreteBar = function() {
.attr('width', x.rangeBand() / data.length);
d3.transition(bars)
//.delay(function(d,i) { return i * 1200 / data[0].values.length })
.attr('transform', function(d,i) {
.attr('transform', function(d,i) {
return 'translate(' + x(getX(d,i)) + ', ' + (getY(d,i) < 0 ? y(0) : y(getY(d,i))) + ')'
})
.select('rect')
.attr('height', function(d,i) {
return Math.abs(y(getY(d,i)) - y(0))
});
.select('rect')
.attr('height', function(d,i) {
return Math.max(Math.abs(y(getY(d,i)) - y(0)) || 1)
});


//store old scales for use in transitions on update
Expand Down Expand Up @@ -5126,7 +5126,7 @@ nv.models.multiBar = function() {
return y(getY(d,i) + (stacked ? d.y0 : 0));
})
.attr('height', function(d,i) {
return Math.abs(y(d.y + (stacked ? d.y0 : 0)) - y((stacked ? d.y0 : 0)))
return Math.max(Math.abs(y(d.y + (stacked ? d.y0 : 0)) - y((stacked ? d.y0 : 0))),1);
})
.each('end', function() {
d3.transition(d3.select(this))
Expand All @@ -5150,7 +5150,7 @@ nv.models.multiBar = function() {
y(getY(d,i))
})
.attr('height', function(d,i) {
return Math.abs(y(getY(d,i)) - y(0))
return Math.max(Math.abs(y(getY(d,i)) - y(0)),1);
});
})

Expand Down
10 changes: 5 additions & 5 deletions nv.d3.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/models/discreteBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ nv.models.discreteBar = function() {
.attr('width', x.rangeBand() / data.length);
d3.transition(bars)
//.delay(function(d,i) { return i * 1200 / data[0].values.length })
.attr('transform', function(d,i) {
.attr('transform', function(d,i) {
return 'translate(' + x(getX(d,i)) + ', ' + (getY(d,i) < 0 ? y(0) : y(getY(d,i))) + ')'
})
.select('rect')
.attr('height', function(d,i) {
return Math.abs(y(getY(d,i)) - y(0))
});
.select('rect')
.attr('height', function(d,i) {
return Math.max(Math.abs(y(getY(d,i)) - y(0)) || 1)
});


//store old scales for use in transitions on update
Expand Down
4 changes: 2 additions & 2 deletions src/models/multiBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ nv.models.multiBar = function() {
return y(getY(d,i) + (stacked ? d.y0 : 0));
})
.attr('height', function(d,i) {
return Math.abs(y(d.y + (stacked ? d.y0 : 0)) - y((stacked ? d.y0 : 0)))
return Math.max(Math.abs(y(d.y + (stacked ? d.y0 : 0)) - y((stacked ? d.y0 : 0))),1);
})
.each('end', function() {
d3.transition(d3.select(this))
Expand All @@ -246,7 +246,7 @@ nv.models.multiBar = function() {
y(getY(d,i))
})
.attr('height', function(d,i) {
return Math.abs(y(getY(d,i)) - y(0))
return Math.max(Math.abs(y(getY(d,i)) - y(0)),1);
});
})

Expand Down

0 comments on commit cf9bb41

Please sign in to comment.