|
|
|
@ -232,7 +232,7 @@ Axis.prototype.dyForXAxisLabel = function dyForXAxisLabel() {
|
|
|
|
|
if (config.axis_rotated) { |
|
|
|
|
return position.isInner ? "1.2em" : -25 - this.getMaxTickWidth('x'); |
|
|
|
|
} else { |
|
|
|
|
return position.isInner ? "-0.5em" : config.axis_x_height ? config.axis_x_height - 10 : "3em"; |
|
|
|
|
return position.isInner ? "-0.5em" : $$.getHorizontalAxisHeight('x') - 10; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
Axis.prototype.dyForYAxisLabel = function dyForYAxisLabel() { |
|
|
|
@ -265,12 +265,20 @@ Axis.prototype.textAnchorForY2AxisLabel = function textAnchorForY2AxisLabel() {
|
|
|
|
|
var $$ = this.owner; |
|
|
|
|
return this.textAnchorForAxisLabel($$.config.axis_rotated, this.getY2AxisLabelPosition()); |
|
|
|
|
}; |
|
|
|
|
Axis.prototype.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) { |
|
|
|
|
|
|
|
|
|
Axis.prototype.getMaxTickBox = function getMaxTickBox(id, withoutRecompute) { |
|
|
|
|
var $$ = this.owner, config = $$.config, |
|
|
|
|
maxWidth = 0, targetsToShow, scale, axis, dummy, svg; |
|
|
|
|
if (withoutRecompute && $$.currentMaxTickWidths[id]) { |
|
|
|
|
return $$.currentMaxTickWidths[id]; |
|
|
|
|
targetsToShow, scale, axis, dummy, svg; |
|
|
|
|
|
|
|
|
|
if (withoutRecompute && $$.currentMaxTickBoxes[id]) { |
|
|
|
|
return $$.currentMaxTickBoxes[id]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var maxBox = { |
|
|
|
|
height: 0, |
|
|
|
|
width: 0 |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if ($$.svg) { |
|
|
|
|
targetsToShow = $$.filterTargetsToShow($$.data.targets); |
|
|
|
|
if (id === 'y') { |
|
|
|
@ -284,18 +292,29 @@ Axis.prototype.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute)
|
|
|
|
|
axis = this.getXAxis(scale, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues, false, true, true); |
|
|
|
|
this.updateXAxisTickValues(targetsToShow, axis); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dummy = $$.d3.select('body').append('div').classed('c3', true); |
|
|
|
|
svg = dummy.append("svg").style('visibility', 'hidden').style('position', 'fixed').style('top', 0).style('left', 0), |
|
|
|
|
svg = dummy.append("svg").style('visibility', 'hidden').style('position', 'fixed').style('top', 0).style('left', 0); |
|
|
|
|
svg.append('g').call(axis).each(function () { |
|
|
|
|
$$.d3.select(this).selectAll('text').each(function () { |
|
|
|
|
var box = this.getBoundingClientRect(); |
|
|
|
|
if (maxWidth < box.width) { maxWidth = box.width; } |
|
|
|
|
maxBox.width = Math.max(maxBox.width, box.width); |
|
|
|
|
maxBox.height = Math.max(maxBox.height, box.height); |
|
|
|
|
}); |
|
|
|
|
dummy.remove(); |
|
|
|
|
}); |
|
|
|
|
dummy.remove(); |
|
|
|
|
} |
|
|
|
|
$$.currentMaxTickWidths[id] = maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; |
|
|
|
|
return $$.currentMaxTickWidths[id]; |
|
|
|
|
|
|
|
|
|
$$.currentMaxTickBoxes[id] = maxBox; |
|
|
|
|
return $$.currentMaxTickBoxes[id]; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Axis.prototype.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) { |
|
|
|
|
return this.getMaxTickBox(id, withoutRecompute).width; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Axis.prototype.getMaxTickHeight = function getMaxTickHeight(id, withoutRecompute) { |
|
|
|
|
return this.getMaxTickBox(id, withoutRecompute).height; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Axis.prototype.updateLabels = function updateLabels(withTransition) { |
|
|
|
|