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
  • 相关阅读:
    学习比较-列表
    查看Linux下系统资源占用常用命令
    eclipse加载maven工程提示pom.xml无法解析org.apache.maven.plugins:maven-resources-plugin:2.4.3解决方案
    springmvc 注解扫描失败的可能原因
    单例模式:懒加载(延迟加载)和即时加载
    nginx 正向代理和反向代理
    LINUX中错误 SELinux is disabled
    修改Win10默认窗口背景色为护眼色的方法
    搜索引擎之Lucene
    MongoDB系列(一):MongoDB安装及基础语法
  • 原文地址:https://www.cnblogs.com/binary1010/p/13539457.html
Copyright © 2011-2022 走看看