Commit 65197230 authored by Evgeny's avatar Evgeny

Fix bug with wrong axis label positioning

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