diff --git a/src/coord/axisHelper.js b/src/coord/axisHelper.js index a20be6d1fb..ec363a7e91 100644 --- a/src/coord/axisHelper.js +++ b/src/coord/axisHelper.js @@ -387,8 +387,8 @@ function rotateTextRect(textRect, rotate) { var boundingBox = textRect.plain(); var beforeWidth = boundingBox.width; var beforeHeight = boundingBox.height; - var afterWidth = beforeWidth * Math.cos(rotateRadians) + beforeHeight * Math.sin(rotateRadians); - var afterHeight = beforeWidth * Math.sin(rotateRadians) + beforeHeight * Math.cos(rotateRadians); + var afterWidth = beforeWidth * Math.abs(Math.cos(rotateRadians)) + Math.abs(beforeHeight * Math.sin(rotateRadians)); + var afterHeight = beforeWidth * Math.abs(Math.sin(rotateRadians)) + Math.abs(beforeHeight * Math.cos(rotateRadians)); var rotatedRect = new BoundingRect(boundingBox.x, boundingBox.y, afterWidth, afterHeight); return rotatedRect; diff --git a/test/axisLabel.html b/test/axisLabel.html index 67a7352eb9..58439dce84 100644 --- a/test/axisLabel.html +++ b/test/axisLabel.html @@ -209,7 +209,10 @@ trigger: 'axis' }, xAxis: { - data: ['a', 'b', 'c', 'd', 'e'] + data: ['aaaaaa', 'bbbbbb', 'cccccc', 'ddddd', 'eeeee'], + axisLabel: { + rotate: rotate + } }, yAxis: { axisLabel: { @@ -239,6 +242,11 @@ axisLabel: { rotate: rotate } + }, + xAxis: { + axisLabel: { + rotate: rotate-180 + } } }); }, 100); @@ -378,6 +386,5 @@ - \ No newline at end of file