Browse Source

Merge pull request #1766 from alexbain/master

Ensure height calculate correctly for negative rotations
pull/2321/head
Anthony Pessy 7 years ago committed by GitHub
parent
commit
818f8b9894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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: { x: {
tick: { tick: {
format: function () { return "hogehogehogehogehoge"; }, format: function () { return "hogehogehogehogehoge"; },
rotate: 30, rotate: -30,
}, },
label: { label: {
text: 'Hogehoge', text: 'Hogehoge',

4
src/size.js

@ -105,11 +105,11 @@ 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 = 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 // Calculate y axis height when tick rotated
if (axisId === 'y' && config.axis_rotated && config.axis_y_tick_rotate) { 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); return h + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + (axisId === 'y2' ? -10 : 0);
}; };

Loading…
Cancel
Save