echarts中饼图基本配置

<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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值