|
|
@ -478,13 +478,7 @@ |
|
|
|
if (targetsToShow.length) { |
|
|
|
if (targetsToShow.length) { |
|
|
|
$$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain); |
|
|
|
$$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain); |
|
|
|
if (!config.axis_x_tick_values) { |
|
|
|
if (!config.axis_x_tick_values) { |
|
|
|
if (config.axis_x_tick_fit || config.axis_x_tick_count) { |
|
|
|
tickValues = $$.updateXAxisTickValues(targetsToShow); |
|
|
|
tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targetsToShow), config.axis_x_tick_count, $$.isTimeSeries()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
tickValues = undefined; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$$.xAxis.tickValues(tickValues); |
|
|
|
|
|
|
|
$$.subXAxis.tickValues(tickValues); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$$.xAxis.tickValues([]); |
|
|
|
$$.xAxis.tickValues([]); |
|
|
@ -4068,13 +4062,14 @@ |
|
|
|
.attr("transform", config.axis_rotated ? "" : "rotate(-90)") |
|
|
|
.attr("transform", config.axis_rotated ? "" : "rotate(-90)") |
|
|
|
.style("text-anchor", $$.textAnchorForY2AxisLabel.bind($$)); |
|
|
|
.style("text-anchor", $$.textAnchorForY2AxisLabel.bind($$)); |
|
|
|
}; |
|
|
|
}; |
|
|
|
c3_chart_internal_fn.getXAxis = function (scale, orient, tickFormat, tickValues, withOuterTick) { |
|
|
|
c3_chart_internal_fn.getXAxis = function (scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition) { |
|
|
|
var $$ = this, config = $$.config, |
|
|
|
var $$ = this, config = $$.config, |
|
|
|
axisParams = { |
|
|
|
axisParams = { |
|
|
|
isCategory: $$.isCategorized(), |
|
|
|
isCategory: $$.isCategorized(), |
|
|
|
withOuterTick: withOuterTick, |
|
|
|
withOuterTick: withOuterTick, |
|
|
|
tickMultiline: config.axis_x_tick_multiline, |
|
|
|
tickMultiline: config.axis_x_tick_multiline, |
|
|
|
tickWidth: config.axis_x_tick_width |
|
|
|
tickWidth: config.axis_x_tick_width, |
|
|
|
|
|
|
|
withoutTransition: withoutTransition, |
|
|
|
}, |
|
|
|
}, |
|
|
|
axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient); |
|
|
|
axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient); |
|
|
|
|
|
|
|
|
|
|
@ -4101,6 +4096,19 @@ |
|
|
|
|
|
|
|
|
|
|
|
return axis; |
|
|
|
return axis; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
c3_chart_internal_fn.updateXAxisTickValues = function (targets, axis) { |
|
|
|
|
|
|
|
var $$ = this, config = $$.config, tickValues; |
|
|
|
|
|
|
|
if (config.axis_x_tick_fit || config.axis_x_tick_count) { |
|
|
|
|
|
|
|
tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targets), config.axis_x_tick_count, $$.isTimeSeries()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (axis) { |
|
|
|
|
|
|
|
axis.tickValues(tickValues); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$$.xAxis.tickValues(tickValues); |
|
|
|
|
|
|
|
$$.subXAxis.tickValues(tickValues); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return tickValues; |
|
|
|
|
|
|
|
}; |
|
|
|
c3_chart_internal_fn.getYAxis = function (scale, orient, tickFormat, tickValues, withOuterTick) { |
|
|
|
c3_chart_internal_fn.getYAxis = function (scale, orient, tickFormat, tickValues, withOuterTick) { |
|
|
|
var axisParams = {withOuterTick: withOuterTick}, |
|
|
|
var axisParams = {withOuterTick: withOuterTick}, |
|
|
|
axis = c3_axis(this.d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat); |
|
|
|
axis = c3_axis(this.d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat); |
|
|
@ -4304,7 +4312,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
c3_chart_internal_fn.getMaxTickWidth = function (id, withoutRecompute) { |
|
|
|
c3_chart_internal_fn.getMaxTickWidth = function (id, withoutRecompute) { |
|
|
|
var $$ = this, config = $$.config, |
|
|
|
var $$ = this, config = $$.config, |
|
|
|
maxWidth = 0, targetsToShow, scale, axis; |
|
|
|
maxWidth = 0, targetsToShow, scale, axis, body, svg; |
|
|
|
if (withoutRecompute && $$.currentMaxTickWidths[id]) { |
|
|
|
if (withoutRecompute && $$.currentMaxTickWidths[id]) { |
|
|
|
return $$.currentMaxTickWidths[id]; |
|
|
|
return $$.currentMaxTickWidths[id]; |
|
|
|
} |
|
|
|
} |
|
|
@ -4319,13 +4327,21 @@ |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
scale = $$.x.copy().domain($$.getXDomain(targetsToShow)); |
|
|
|
scale = $$.x.copy().domain($$.getXDomain(targetsToShow)); |
|
|
|
axis = $$.getXAxis(scale, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues); |
|
|
|
axis = $$.getXAxis(scale, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues); |
|
|
|
|
|
|
|
$$.updateXAxisTickValues(targetsToShow, axis); |
|
|
|
} |
|
|
|
} |
|
|
|
$$.d3.select('body').append("g").style('visibility', 'hidden').call(axis).each(function () { |
|
|
|
body = this.d3.select('body').classed('c3', true); |
|
|
|
|
|
|
|
svg = body.append('svg').style('visibility', 'hidden'); |
|
|
|
|
|
|
|
svg.append('g').call(axis).each(function () { |
|
|
|
$$.d3.select(this).selectAll('text tspan').each(function () { |
|
|
|
$$.d3.select(this).selectAll('text tspan').each(function () { |
|
|
|
var box = this.getBoundingClientRect(); |
|
|
|
var box = this.getBoundingClientRect(); |
|
|
|
if (box.left > 0 && maxWidth < box.width) { maxWidth = box.width; } |
|
|
|
if (box.left >= 0 && maxWidth < box.width) { maxWidth = box.width; } |
|
|
|
}); |
|
|
|
}); |
|
|
|
}).remove(); |
|
|
|
}); |
|
|
|
|
|
|
|
// TODO: time lag to get maxWidth
|
|
|
|
|
|
|
|
window.setTimeout(function () { |
|
|
|
|
|
|
|
svg.remove(); |
|
|
|
|
|
|
|
}, 100); |
|
|
|
|
|
|
|
body.classed('c3', false); |
|
|
|
} |
|
|
|
} |
|
|
|
$$.currentMaxTickWidths[id] = maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; |
|
|
|
$$.currentMaxTickWidths[id] = maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; |
|
|
|
return $$.currentMaxTickWidths[id]; |
|
|
|
return $$.currentMaxTickWidths[id]; |
|
|
|