Commit 3746404f authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix tick width when no tick exists - #295

parent c4914d3d
...@@ -378,6 +378,7 @@ ...@@ -378,6 +378,7 @@
var isLegendRight = __legend_position === 'right'; var isLegendRight = __legend_position === 'right';
var legendStep = 0, legendItemWidth = 0, legendItemHeight = 0, legendOpacityForHidden = 0.15; var legendStep = 0, legendItemWidth = 0, legendItemHeight = 0, legendOpacityForHidden = 0.15;
var currentMaxTickWidth = 0;
/*-- Define Functions --*/ /*-- Define Functions --*/
...@@ -951,11 +952,14 @@ ...@@ -951,11 +952,14 @@
} }
function getMaxTickWidth(id) { function getMaxTickWidth(id) {
var maxWidth = 0, axisClass = id === 'x' ? CLASS.axisX : id === 'y' ? CLASS.axisY : CLASS.axisY2; var maxWidth = 0, axisClass = id === 'x' ? CLASS.axisX : id === 'y' ? CLASS.axisY : CLASS.axisY2;
d3.selectAll('.' + axisClass + ' .tick text').each(function () { if (svg) {
var box = this.getBoundingClientRect(); svg.selectAll('.' + axisClass + ' .tick text').each(function () {
if (maxWidth < box.width) { maxWidth = box.width; } var box = this.getBoundingClientRect();
}); if (maxWidth < box.width) { maxWidth = box.width; }
return maxWidth < 0 ? 0 : maxWidth; });
}
currentMaxTickWidth = maxWidth <= 0 ? currentMaxTickWidth : maxWidth;
return currentMaxTickWidth;
} }
function updateAxisLabels(withTransition) { function updateAxisLabels(withTransition) {
var axisXLabel = main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel), var axisXLabel = main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel),
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment