<template>
<div class="chart">
<div id="main" style="width: 600px; height: 400px"></div>
</div>
</template>
<script>
export default {
name: "HelloWorld",
data() {
return {};
},
mounted() {
this.initChart();
},
methods: {
initChart() {
// 下载echarts包,引入echarts样式,初始化echarts实例,设置图表数据,绘制图表
var echarts = require("echarts");
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById("main"));
let options = {
title: {
text: "饼状图--南丁格尔图",
link:"baidu.com",
textStyle: {
color: "yellow",
fontSize: "30px",
},
}, //全局的title
backgroundColor: "#2c343c", //全局的背景颜色
tooltip: {}, //提示框
series: [
{
name: "访问来源",
type: "pie",
roseType: "angle",
radius: "55%",
data: [
{
value: 235,
name: "视频广告",
itemStyle: {
color: "#c23531",
},
},
{ value: 274, name: "联盟广告" },
{ value: 310, name: "邮件营销" },
{ value: 335, name: "直接访问" },
{ value: 400, name: "搜索引擎" },
],
itemStyle: {
// 阴影的大小
shadowBlur: 200,
// 阴影颜色
shadowColor: "rgba(0, 0, 0, 0.5)",
},
label: {
color: "rgba(255, 255, 0, 0.3)", // 每个系列的文本颜色
},
labelLine: {
lineStyle: {
color: "rgba(255, 255, 255, 0.3)", //label引导线的颜色
},
},
},
],
};
// 绘制图表
myChart.setOption(options, true);
},
},
};
</script>
<style scoped>
#app {
display: flex;
justify-content: center;
align-items: center;
}
.chart {
display: flex;
justify-content: center;
}
</style>
echarts中饼图基本配置
最新推荐文章于 2025-03-17 08:48:19 发布