Commit ed58b5c2 authored by Evgeny's avatar Evgeny

Fix x padding when turning for 90 degrees

parent aab38839
...@@ -2816,7 +2816,7 @@ ...@@ -2816,7 +2816,7 @@
if (axisId === 'y2' && !config.axis_y2_show) { return $$.rotated_padding_top; } if (axisId === 'y2' && !config.axis_y2_show) { return $$.rotated_padding_top; }
// Calculate x axis height when tick rotated // Calculate x axis height when tick rotated
if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) { if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) {
h = $$.getMaxTickWidthAllowed(axisId) * Math.cos(Math.PI * Math.abs(config.axis_x_tick_rotate) / 180); h = $$.getMaxTickWidthAllowed(axisId) * Math.sin(Math.PI * Math.abs(config.axis_x_tick_rotate) / 180);
} }
return h + ($$.getAxisLabelPositionById(axisId).isInner ? 10 : 15) + (axisId === 'y2' ? -10 : 0); return h + ($$.getAxisLabelPositionById(axisId).isInner ? 10 : 15) + (axisId === 'y2' ? -10 : 0);
}; };
...@@ -4873,7 +4873,7 @@ ...@@ -4873,7 +4873,7 @@
var $$ = this, config = $$.config, var $$ = this, config = $$.config,
position = $$.getXAxisLabelPosition(); position = $$.getXAxisLabelPosition();
if (config.axis_rotated) { if (config.axis_rotated) {
return position.isInner ? "1.2em" : -25 - $$.getMaxTickWidth('x'); return position.isInner ? "1.2em" : -15 - $$.getMaxTickWidth('x');
} else { } else {
if(position.isInner){ if(position.isInner){
return "-0.5em"; return "-0.5em";
...@@ -4884,7 +4884,9 @@ ...@@ -4884,7 +4884,9 @@
} }
if(config.axis_x_tick_rotate !== 0){ if(config.axis_x_tick_rotate !== 0){
return $$.getMaxTickWidth('x'); var coef = $$.getCurrentHeight() / 12;
var v = $$.getMaxTickWidth('x')*Math.sin(Math.abs(Math.PI * config.axis_x_tick_rotate / 180)) + coef;
return v;
} }
return 35; return 35;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -251,7 +251,7 @@ c3_chart_internal_fn.dyForXAxisLabel = function () { ...@@ -251,7 +251,7 @@ c3_chart_internal_fn.dyForXAxisLabel = function () {
var $$ = this, config = $$.config, var $$ = this, config = $$.config,
position = $$.getXAxisLabelPosition(); position = $$.getXAxisLabelPosition();
if (config.axis_rotated) { if (config.axis_rotated) {
return position.isInner ? "1.2em" : -25 - $$.getMaxTickWidth('x'); return position.isInner ? "1.2em" : -15 - $$.getMaxTickWidth('x');
} else { } else {
if(position.isInner){ if(position.isInner){
return "-0.5em"; return "-0.5em";
...@@ -262,7 +262,9 @@ c3_chart_internal_fn.dyForXAxisLabel = function () { ...@@ -262,7 +262,9 @@ c3_chart_internal_fn.dyForXAxisLabel = function () {
} }
if(config.axis_x_tick_rotate !== 0){ if(config.axis_x_tick_rotate !== 0){
return $$.getMaxTickWidth('x'); var coef = $$.getCurrentHeight() / 12;
var v = $$.getMaxTickWidth('x')*Math.sin(Math.abs(Math.PI * config.axis_x_tick_rotate / 180)) + coef;
return v;
} }
return 35; return 35;
......
...@@ -86,7 +86,7 @@ c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) { ...@@ -86,7 +86,7 @@ c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) {
if (axisId === 'y2' && !config.axis_y2_show) { return $$.rotated_padding_top; } if (axisId === 'y2' && !config.axis_y2_show) { return $$.rotated_padding_top; }
// Calculate x axis height when tick rotated // Calculate x axis height when tick rotated
if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) { if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) {
h = $$.getMaxTickWidthAllowed(axisId) * Math.cos(Math.PI * Math.abs(config.axis_x_tick_rotate) / 180); h = $$.getMaxTickWidthAllowed(axisId) * Math.sin(Math.PI * Math.abs(config.axis_x_tick_rotate) / 180);
} }
return h + ($$.getAxisLabelPositionById(axisId).isInner ? 10 : 15) + (axisId === 'y2' ? -10 : 0); return h + ($$.getAxisLabelPositionById(axisId).isInner ? 10 : 15) + (axisId === 'y2' ? -10 : 0);
}; };
......
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