ECharts 实现双饼状图

实现双饼图效果直接看series属性吧

var myChart = echarts.init(document.getElementById('main'));
 var bottomChartColor =  ["#ffa141", "#00ffec"]
var option = {
    series: [
		  //用来装饰的饼图
          {
            name: "",
            type: "pie",
            selectedMode: "single",
            silent: true,
            radius: [0, "37%"],
            center: ["45%", "50%"], //饼图位置控制
            label: {
              normal: {
                position: "inner",
                show: false,
              },
            },
            data: [
              {
                value: 0,
                name: "",
              },
            ],
            color: {
              type: "radial",
              x: 0.5,
              y: 0.5,
              z: 0.5,
              colorStops: [
                {
                  offset: 0,
                  color: "transparent",
                },
                {
                  offset: 1,
                  color: "#4872ff",
                },
              ],
              global: false,
            },
          },
          //用来展示的饼图
          {
            name: "",
            type: "pie",
            radius: ["45%", "60%"],
            center: ["45%", "50%"], //饼图位置控制
            //bottomChartData我自己的饼图数据,和正常饼图数据无异
            data: this.bottomChartData.map((item, index) => {
              item.label = {
                color: bottomChartColor[index],
              };
              return item;
            }),
            itemStyle: {
              color: (params) => {
                var index = params.dataIndex;
                return bottomChartColor[index];
              },
            },
            label: {
              color: "#FFFFFF",
              formatter: function (t) {
                return t.value;
              },
            },
            animationType: "scale",
            animationEasing: "elasticOut",
            animationDelay: function (idx) {
              return Math.random() * 200;
            },
          },
    ],
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值