我想做一个饼图,请问需要想从数据库中取出itemname和numbers放入饼图中,应该写几个实体存数据呢?饼图哪里需要放数据呢?
我从后台取出物资信息及饼图的代码如下:
methods: {
async getStockList() {
const {data: res} = await this.$http.get("allStock", {params: this.queryInfo});
this.stockList = res.data;//用户列表
this.total = res.numbers;//总用户数
}
getEchartData2(){
var myChart = echarts.init(document.getElementById("bingtu"));
var option = {
title: {
text: '库存占比图',
left: 'left'
},
tooltip: {
trigger: 'item'
},
legend: {//图示
orient: 'vertical',
left: 'right',
right: 10,
top: 20,
bottom: 20,
},
series: [
{
name: 'Access From',
type: 'pie',
radius: "55%",
center: ["40%", "50%"],
data: [],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
myChart.setOption(option);
}