<template>
<div>
<div id="main" style="width: 600px;height:400px;"></div>
</div>
</template>
<script>
import * as echarts from "echarts";
export default {
name: "WorkspaceJsonApp",
data() {
return {
option: {
title: {
text: "世界人口总量",
subtext: "数据来自网络"
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow"
}
},
legend: {
data: ["2011年"]
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true
},
xAxis: {
type: "value",
boundaryGap: [0, 0.01]
},
yAxis: {
type: "category",
data: ["巴西"]
},
series: [
{
name: "2011年",
type: "bar",
data: [
{
bmid: 3, // 部门id 这里的key 可以随便定义(除value外)
num: 1, // 工号
value: 6000 // value 是展示得数值,必须是vaLUE
}
]
}
]
}
};
},
mounted() {
// 基于准备好的dom,初始化echarts实例
this.myChart = echarts.init(document.getElementById("main"));
// 使用刚指定的配置项和数据显示图表。
this.myChart.setOption(this.option);
this.myChart.on("click", function(params) {
console.log(params); //查看params参数取出你想要的
});
},
methods: {}
};
</script>
<style scoped>
.my-swipe .van-swipe-item {
color: #fff;
font-size: 20px;
line-height: 150px;
text-align: center;
background-color: #39a9ed;
}
</style>```
09-13
2449