Commit 65197230 authored by Evgeny's avatar Evgeny

Fix bug with wrong axis label positioning

parent 7ba10e29
......@@ -759,6 +759,7 @@
if (flow) {
flow();
}
if (config.onrendered) {
config.onrendered.call($$);
}
......@@ -769,6 +770,7 @@
$$.redrawLine(drawLine);
$$.redrawArea(drawArea);
$$.redrawCircle(cx, cy);
if (config.onrendered) {
config.onrendered.call($$);
}
......@@ -796,7 +798,7 @@
false;
// MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called)
$$.updateSizes();
transitions = $$.generateAxisTransitions(options.withTransitionForAxis ? config.transition_duration : 0);
transitions = $$.generateAxisTransitions(0);
// MEMO: called in updateLegend in redraw if withLegend
if (!(options.withLegend && config.legend_show)) {
......@@ -809,9 +811,11 @@
$$.redrawAxis(transitions);
// MEMO: Draw with new sizes & scales
$$.updateSizes();
$$.updateScales();
$$.updateSvgSize();
$$.redraw(options, transitions);
};
c3_chart_internal_fn.redrawWithoutRescale = function () {
this.redraw({
......@@ -4806,6 +4810,7 @@
c3_chart_internal_fn.getAxisLabelPosition = function (axisId, defaultPosition) {
var option = this.getAxisLabelOptionByAxisId(axisId),
position = (option && typeof option === 'object' && option.position) ? option.position : defaultPosition;
return {
isInner: position.indexOf('inner') >= 0,
isOuter: position.indexOf('outer') >= 0,
......@@ -4861,10 +4866,12 @@
}
};
c3_chart_internal_fn.xForXAxisLabel = function () {
return this.xForAxisLabel(!this.config.axis_rotated, this.getXAxisLabelPosition());
var x = this.xForAxisLabel(!this.config.axis_rotated, this.getXAxisLabelPosition());
return x;
};
c3_chart_internal_fn.xForYAxisLabel = function () {
return this.xForAxisLabel(this.config.axis_rotated, this.getYAxisLabelPosition());
var x = this.xForAxisLabel(this.config.axis_rotated, this.getYAxisLabelPosition());
return x;
};
c3_chart_internal_fn.xForY2AxisLabel = function () {
return this.xForAxisLabel(this.config.axis_rotated, this.getY2AxisLabelPosition());
......@@ -4995,18 +5002,15 @@
axisYLabel = $$.main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel),
axisY2Label = $$.main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label);
var duration = $$.config.transition_duration;
(withTransition ? axisXLabel.transition().duration(duration) : axisXLabel)
.attr("x", $$.xForXAxisLabel.bind($$))
axisXLabel.attr("x", $$.xForXAxisLabel.bind($$))
.attr("dx", $$.dxForXAxisLabel.bind($$))
.attr("dy", $$.dyForXAxisLabel.bind($$))
.text($$.textForXAxisLabel.bind($$));
(withTransition ? axisYLabel.transition().duration(duration) : axisYLabel)
.attr("x", $$.xForYAxisLabel.bind($$))
axisYLabel.attr("x", $$.xForYAxisLabel.bind($$))
.attr("dx", $$.dxForYAxisLabel.bind($$))
.attr("dy", $$.dyForYAxisLabel.bind($$))
.text($$.textForYAxisLabel.bind($$));
(withTransition ? axisY2Label.transition().duration(duration) : axisY2Label)
.attr("x", $$.xForY2AxisLabel.bind($$))
axisY2Label.attr("x", $$.xForY2AxisLabel.bind($$))
.attr("dx", $$.dxForY2AxisLabel.bind($$))
.attr("dy", $$.dyForY2AxisLabel.bind($$))
.text($$.textForY2AxisLabel.bind($$));
......@@ -5082,9 +5086,8 @@
$$.rotateTickText($$.axes.subx, transitions.axisSubX, config.axis_x_tick_rotate);
}
//$$.updateSizes();
//$$.updateScales();
//$$.updateSvgSize();
$$.updateAxisLabels();
};
c3_chart_internal_fn.tuneAxisTicks = function(){
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -175,6 +175,7 @@ c3_chart_internal_fn.setAxisLabelText = function (axisId, text) {
c3_chart_internal_fn.getAxisLabelPosition = function (axisId, defaultPosition) {
var option = this.getAxisLabelOptionByAxisId(axisId),
position = (option && typeof option === 'object' && option.position) ? option.position : defaultPosition;
return {
isInner: position.indexOf('inner') >= 0,
isOuter: position.indexOf('outer') >= 0,
......@@ -230,10 +231,12 @@ c3_chart_internal_fn.textAnchorForAxisLabel = function (forHorizontal, position)
}
};
c3_chart_internal_fn.xForXAxisLabel = function () {
return this.xForAxisLabel(!this.config.axis_rotated, this.getXAxisLabelPosition());
var x = this.xForAxisLabel(!this.config.axis_rotated, this.getXAxisLabelPosition());
return x;
};
c3_chart_internal_fn.xForYAxisLabel = function () {
return this.xForAxisLabel(this.config.axis_rotated, this.getYAxisLabelPosition());
var x = this.xForAxisLabel(this.config.axis_rotated, this.getYAxisLabelPosition());
return x;
};
c3_chart_internal_fn.xForY2AxisLabel = function () {
return this.xForAxisLabel(this.config.axis_rotated, this.getY2AxisLabelPosition());
......@@ -364,18 +367,15 @@ c3_chart_internal_fn.updateAxisLabels = function (withTransition) {
axisYLabel = $$.main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel),
axisY2Label = $$.main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label);
var duration = $$.config.transition_duration;
(withTransition ? axisXLabel.transition().duration(duration) : axisXLabel)
.attr("x", $$.xForXAxisLabel.bind($$))
axisXLabel.attr("x", $$.xForXAxisLabel.bind($$))
.attr("dx", $$.dxForXAxisLabel.bind($$))
.attr("dy", $$.dyForXAxisLabel.bind($$))
.text($$.textForXAxisLabel.bind($$));
(withTransition ? axisYLabel.transition().duration(duration) : axisYLabel)
.attr("x", $$.xForYAxisLabel.bind($$))
axisYLabel.attr("x", $$.xForYAxisLabel.bind($$))
.attr("dx", $$.dxForYAxisLabel.bind($$))
.attr("dy", $$.dyForYAxisLabel.bind($$))
.text($$.textForYAxisLabel.bind($$));
(withTransition ? axisY2Label.transition().duration(duration) : axisY2Label)
.attr("x", $$.xForY2AxisLabel.bind($$))
axisY2Label.attr("x", $$.xForY2AxisLabel.bind($$))
.attr("dx", $$.dxForY2AxisLabel.bind($$))
.attr("dy", $$.dyForY2AxisLabel.bind($$))
.text($$.textForY2AxisLabel.bind($$));
......@@ -451,9 +451,8 @@ c3_chart_internal_fn.redrawAxis = function (transitions, isHidden) {
$$.rotateTickText($$.axes.subx, transitions.axisSubX, config.axis_x_tick_rotate);
}
//$$.updateSizes();
//$$.updateScales();
//$$.updateSvgSize();
$$.updateAxisLabels();
};
c3_chart_internal_fn.tuneAxisTicks = function(){
......
......@@ -754,6 +754,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
if (flow) {
flow();
}
if (config.onrendered) {
config.onrendered.call($$);
}
......@@ -764,6 +765,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
$$.redrawLine(drawLine);
$$.redrawArea(drawArea);
$$.redrawCircle(cx, cy);
if (config.onrendered) {
config.onrendered.call($$);
}
......@@ -791,7 +793,7 @@ c3_chart_internal_fn.updateAndRedraw = function (options) {
false;
// MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called)
$$.updateSizes();
transitions = $$.generateAxisTransitions(options.withTransitionForAxis ? config.transition_duration : 0);
transitions = $$.generateAxisTransitions(0);
// MEMO: called in updateLegend in redraw if withLegend
if (!(options.withLegend && config.legend_show)) {
......@@ -804,9 +806,11 @@ c3_chart_internal_fn.updateAndRedraw = function (options) {
$$.redrawAxis(transitions);
// MEMO: Draw with new sizes & scales
$$.updateSizes();
$$.updateScales();
$$.updateSvgSize();
$$.redraw(options, transitions);
};
c3_chart_internal_fn.redrawWithoutRescale = function () {
this.redraw({
......
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