zoukankan      html  css  js  c++  java
  • echars 饼图使用

    option = {
          tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b}: {c} ({d}%)'
          },
          legend: {
            orient: 'vertical',
            x: 'right',
            y: 'center',
            align: 'left',//文字永远在左侧
            icon: 'circle',// 这个字段控制形状 类型包括 circle,rect ,roundRect,triangle,diamond,pin,arrow,none
            data: [
              {
                name: '红码人数',
                textStyle: {
                  fontSize: 12,
                  color: 'white'
                }
              },
              {
                name: '黄码人数',
                textStyle: {
                  fontSize: 12,
                  color: 'white'
                }
              },
              {
                name: '绿码人数',
                textStyle: {
                  fontSize: 12,
                  color: 'white'
                }
              }
            ],
            formatter(name) {   //文字显示图形数据
              var index = 0;
              var clientlabels = ['红码人数','黄码人数','绿码人数'];
              var clientcounts = [`${data.red}`,`${data.yellow}`,`${data.green}`];
              clientlabels.forEach((value,i) => {
                if (value === name){
                  index = i;
                }
              });
              return `${name}  ${clientcounts[index]}`;
            }
          },
          color: ['red', 'yellow', 'green'],
          series: [
            {
              name: '',
              type: 'pie',
              radius: ['35%', '45%'],
              center: ['35%', '50%'],
              avoidLabelOverlap: false,
              label: {
                normal: {
                  show: true,
                  position: 'center',
                  formatter(argument) {
                    var html;
                    html = `${data.number} 总人数`;
                    return html;
                  },
                  textStyle: {
                    fontSize: 15,
                    color: '#fff'
                  }
                }
              },
              labelLine: {
                show: false
              },
              data: [
                { value: `${data.red}`, name: '红码人数' },
                { value: `${data.yellow}`, name: '黄码人数' },
                { value: `${data.green}`, name: '绿码人数' }
              ]
            }
          ]
        };
    点关注各类It学习资源免费送+V 1153553800
  • 相关阅读:
    validFrom不通过submit按钮来触发表单验证
    微信小程序组件开发
    css3 单行文字溢出,多行文字溢出
    表格布局
    对象设置默认属性
    按钮样式
    判断一个json是否为空
    vue高仿饿了么(三)
    Win10 用IE打开网址默认跳转到Edge如何解决?
    VMware虚拟机安装Win11正式版
  • 原文地址:https://www.cnblogs.com/binary1010/p/13539457.html
Copyright © 2011-2022 走看看