Echarts双环饼状图

Echarts双环饼状图
Echarts官网:https://www.echartsjs.com/examples/zh/index.html
在这里插入图片描述

<template>
  <div :id="id" :style="chartSize" ref="chart"></div>
</template>
<script>
// eslint-disable-next-line
/* eslint-disable */
import echarts from "echarts";
export default {
  name: "hzyhChart",
  props: {
    className: {
      type: String,
      default: "chart"
    },
    id: {
      type: String
    },
    width: {
      type: String,
      default: "100%"
    },
    height: {
      type: String,
      default: "400px"
    },
     tzhyList:{
    },
    
  },
  data() {
      
    return {
      chartSize: {},
    };
  },
  created() {
    this.chartSize = {
      width: this.width,
      height: this.height
    };
  },
  mounted() {
    this.initChart();
  },
  methods: {
    initChart() {
    //   this.chart = echarts.init(document.getElementById(this.id));
      this.chart = echarts.init(this.$refs.chart);
      let option = {
          tooltip: {
              trigger: 'item',
              formatter: "{a} <br/>{b}: {c} ({d}%)"
          },
          legend: {
              orient: 'vertical', //horizontal 
              // backgroundColor:'#fff',
              color: '#fff',
              //bottom: '0%',
              x: 'right',
              data: ['data1', 'data2', 'data3']
          },
          series: [
              //内圈
              {
                  name: '单位数',
                  type: 'pie',
                  roseType: 'area', //area比例缩放 ,radius
                  radius: ['20%', '40%'],
                  center: ['50%', '55%'], //位置
                  color: [ '#078686', '#00d0d0', '#034079', '#6f81da', '#00ffb4'],
                  avoidLabelOverlap: false,
                  label: {
                      normal: {
                          show: true,
                          position: 'inner', //center 
                          formatter: '{d}%', //{d} 
                          textStyle: {
                              color: '#fff',
                              fontWeight: 'bold',
                              fontSize: 14
                          }
                      },
                      emphasis: {
                          show: true,
                          textStyle: {
                              fontSize: '30',
                              fontWeight: 'bold'
                          }
                      }
                  },
                  labelLine: {
                      normal: {
                          show: false
                      }
                  },

                  data: [{
                      value: 11100,
                      name: '物业服务'
                  }, {
                      value: 2220,
                      name: '机关团体'
                  }, {
                      value: 3303,
                      name: '事业单位'
                  }, {
                      value: 4404,
                      name: '企业单位'
                  }]
              }, //外圈
              {
                  name: '人员数',
                  type: 'pie',
                  radius: ['50%', '80%'], 
                  avoidLabelOverlap: false,
                  label: {
                      normal: {
                          show: true,
                          position: 'inner', //center  
                          formatter: function(param) {
                              return param.name + ':\n' + Math.round(param.percent) + '%';
                          },
                          textStyle: {
                              color: '#fff',
                              fontWeight: 'bold',
                              fontSize: 14
                          }
                      },

                      emphasis: {
                          show: false,
                      }
                  },
                  labelLine: {
                      normal: {
                          smooth: true,
                          lineStyle: {
                              width: 2
                          }
                      }
                  },
                  itemStyle: {
                      normal: {
                          shadowBlur: 30,
                          shadowColor: 'rgba(0, 0, 0, 0.4)'
                      }
                  },

                  data: [{
                      value: 21321,
                      name: '物业服务'
                  }, {
                      value: 1212,
                      name: '机关团体'
                  }, {
                      value: 121,
                      name: '事业单位'
                  }, {
                      value: 1212,
                      name: '企业单位'
                  }]
              }
              
          ]
      };
      this.chart.setOption(option);
    }
  }
};
</script>
<style scoped>
div {
  margin: 0 auto;
}
</style>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值