预期的结果就像这篇文章:如何设置标签在水平栏左对齐使用chart.js?但它在Apache ECharts中实现
任何想法?
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var options = {
color: ["#3398DB"],
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow"
}
},
grid: {},
xAxis: [{
type: "value",
}],
yAxis: [{
type: "category",
axisLabel: {
align: 'left',
margin: 40
},
data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
}],
series: [{
name: "直接访问",
type: "bar",
barWidth: "60%",
data: [10, 52, 200, 334, 390, 330, 220]
}]
};
myChart.setOption(options);
#main {
height: 400px;
}
<div id="main"></div>
<p>Test</p>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.2.1/dist/echarts.min.js"></script>
您可以为axisLabel设置margin
,以使标签可见。更新了你的代码片段