Echarts饼图
<template>
<div :id="id"></div>
</template>
<script>
import * as echarts from "echarts";
export default {
name: "bt",
props: {
id: String,
title:String,
seriesData:Array
},
data() {
return {};
},
mounted() {
this.initEchart(this.id);
},
methods: {
initEchart(id) {
var chartDom = document.getElementById(id);
var myChart = echarts.init(chartDom);
var option;
option = {
title: {
show: true,
text: this.title,
x: "center",
y: "top",
textStyle: {
fontSize: 14,
color: "#fff",
},
},
tooltip: {
trigger: "item",
},
legend: {
bottom: "0%",
textStyle: {
color: "#fff",
fontSize: 14,
},
},
grid: {
top: "5%",
left: "3%",
right: "8%",
bottom: "10%",
containLabel: true,
},
series: [
{
name: "访问来源",
type: "pie",
radius: ["36%", "60%"],
avoidLabelOverlap: false,
label: {
show: false,
position: "center",
},
emphasis: {
label: {
show: false,
fontSize: "40",
fontWeight: "bold",
},
},
labelLine: {
show: false,
},
data: this.seriesData,
},
],
};
option && myChart.setOption(option);
},
},
};
</script>