|
|
@@ -205,9 +205,20 @@ nv.models.growingDiscreteBarChart = function() {
|
|
|
var xTicks = g.select('.nv-x.nv-axis').selectAll('g');
|
|
|
|
|
|
if (staggerLabels) {
|
|
|
+ var rangeBand = x.rangeBand();
|
|
|
xTicks
|
|
|
.selectAll('text')
|
|
|
- .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' })
|
|
|
+ .attr('transform', function(d,i,j) {
|
|
|
+ var self = d3.select(this),
|
|
|
+ textLength = self.node().getComputedTextLength(),
|
|
|
+ text = self.text();
|
|
|
+ while (textLength > rangeBand && text.length > 0) {
|
|
|
+ text = text.slice(0, -1);
|
|
|
+ self.text(text + '...');
|
|
|
+ textLength = self.node().getComputedTextLength();
|
|
|
+ }
|
|
|
+ return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')'
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|