Vue饼状图
<template>
<div>
<div :id="chartId" style="height:500px; width:100%"></div>
</div>
</template>
<script>
import echarts from "echarts";
export default {
name: "e5",
data() {
return{
option : {
title: {
text: '便民热线办结率统计',
subtext: 'Fake Data',
left: 'center'
},
tooltip: {
trigger: 'item'
},
legend: {
orient: 'vertical',
left: 'left',
textStyle:{
fontSize:12
}
},
series: [
{
name: 'Access From',
type: 'pie',
radius: '50%',
label:{
show: true,
fontSize: 20
},
data: [
{ value: 1048, name: 'Search Engine' },
{ value: 735, name: '已办结' },
{ value: 580, name: 'Email' },
{ value: 484, name: 'Union Ads' },
{ value: 300, name: 'Video Ads' }
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
},
label: {
show: true,
fontSize: 8,
fontWeight: 'bold'
}
}
}
]
}
}
},
created() {
//随机ID
this.chartId = "chartId" + Math.random();
},
mounted() {
if (this.echart == null) {
this.echart = echarts.init(
document.getElementById(this.chartId)
);
}
this.echart.clear();
this.echart.setOption(this.option);
}
}
</script>
<style scoped>
</style>
择善人而交,择善书而读,择善言而听,择善行而从。