echarts rotate
时间: 2023-10-08 11:04:06 浏览: 134
To rotate the chart in Echarts, you can use the "rotate" configuration option. Set the "rotate" value to the desired angle in degrees, and it will rotate the entire chart.
Here's an example of how you can rotate a bar chart in Echarts:
```javascript
option = {
xAxis: {
type: 'category',
data: ['A', 'B', 'C', 'D', 'E'],
axisLabel: {
rotate: 45 // rotate the labels by 45 degrees
}
},
yAxis: {
type: 'value'
},
series: [{
data: [10, 20, 30, 40, 50],
type: 'bar'
}]
};
// Render the chart
var myChart = echarts.init(document.getElementById('chart'));
myChart.setOption(option);
```
In this example, the `axisLabel.rotate` property is set to 45 degrees, which will rotate the x-axis labels of the bar chart. You can adjust the angle to your preference.
Remember to replace `'chart'` with the ID of the HTML element where you want to render the chart.
You can rotate other types of charts in a similar way by setting the `rotate` property on the appropriate axis or label.
阅读全文