Browse Source

Ensure height calculate correctly for negative rotations

pull/1766/head
Alex Bain 8 years ago
parent
commit
bebbf4bd22
  1. 2
      htdocs/samples/axes_x_tick_rotate.html
  2. 4
      src/size.js

2
htdocs/samples/axes_x_tick_rotate.html

@ -20,7 +20,7 @@
x: {
tick: {
format: function () { return "hogehogehogehogehoge"; },
rotate: 30,
rotate: -30,
},
label: {
text: 'Hogehoge',

4
src/size.js

@ -101,11 +101,11 @@ c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) {
if (axisId === 'y2' && !config.axis_y2_show) { return $$.rotated_padding_top; }
// Calculate x axis height when tick rotated
if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) {
h = 30 + $$.axis.getMaxTickWidth(axisId) * Math.cos(Math.PI * (90 - config.axis_x_tick_rotate) / 180);
h = 30 + $$.axis.getMaxTickWidth(axisId) * Math.cos(Math.PI * (90 - Math.abs(config.axis_x_tick_rotate)) / 180);
}
// Calculate y axis height when tick rotated
if (axisId === 'y' && config.axis_rotated && config.axis_y_tick_rotate) {
h = 30 + $$.axis.getMaxTickWidth(axisId) * Math.cos(Math.PI * (90 - config.axis_y_tick_rotate) / 180);
h = 30 + $$.axis.getMaxTickWidth(axisId) * Math.cos(Math.PI * (90 - Math.abs(config.axis_y_tick_rotate)) / 180);
}
return h + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + (axisId === 'y2' ? -10 : 0);
};

Loading…
Cancel
Save