Echarts柱状图的数值显示、柱宽度、横向柱状图
<script>
import * as echarts from "echarts";
export default {
data() {
return {};
},
mounted() {
var BarChart = echarts.init(document.getElementById("barChart"));
let xDataArr = ["张三", "李四", "王五","闰土","小明", "茅台","二妞", "大强"];
let yDataArr = [88, 92, 63, 77, 94, 80, 72, 86];
let option = {
xAxis: {
type: "value", //横向柱状图,交换xAxis和yAxis的type
},
yAxis: {
type: "category",
data: xDataArr,
},
series: [
{
label: {
//数据显示的位置
show: true, //数值是否显示
rotate: 60, //数值显示的角度
position: "top", //数值相对于柱状图显示的位置
},
barWidth: "30%", //柱的宽度
},
],
};
BarChart.setOption(option);
},
};
</script>