zoukankan      html  css  js  c++  java
  • 实现echarts内外圈联动

    <div id="container" style="height: 100%"></div> 

    //控制都是通过控制series中data的name,那么将内外圈需要同事控制的部分设置为一样的名字,就可以实现内外圈联动。

     //但是在name相同时,会使默认分配颜色时相同,使颜色不好看,这里就需要给data自己分配颜色。

    var dom = document.getElementById("container");
    var myChart = echarts.init(dom);
    var app = {};

    app.title = '嵌套环形图';
    var colors=[
                        '#6EB6F2','#71F16F','#FFC000','#384C6C','#7577F8',
                        '#003366','#AEABAF','#00F4D2','#8084F1','#FF9F4E',
                        '#4FA2A9','#9a7fd1','#588dd5','#f5994e','#c05050',
                        '#59678c','#c9ab00','#7eb00a','#6f5553','#c14089',
                        '#FF4F7F','#CC6666','#7f7522','#2b4490','#333399',
                        '#70a19f','#009299','#78331e','#3e4145','#7bbfea',
                        '#339999','#8f4b38','#694d9f','#f26522','#8e7437',
                        '#45b97c','#74787c','#afdfe4','#fdb933','#bed742',
                        '#A20055','#AA0000','#C63300','#0000AA','#2200AA',
                        '#990099','#00AAAA','#00AA88','#00AA55','#FF1493'
                    ];
    
    
    option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            x: 'left',
            data:['直达','营销广告','搜索引擎','邮件营销','联盟广告','视频广告','百度','谷歌','必应','其他']
        },
        series: [
            {
                name:'访问来源',
                type:'pie',
                selectedMode: 'single',
                radius: [0, '30%'],
    
                label: {
                    normal: {
                        position: 'inner'
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                data:[
                    {value:335, name:'直达', selected:true},
                    {value:679, name:'营销广告'},
                ]
            },
            {
                name:'访问来源',
                type:'pie',
                radius: ['40%', '55%'],
                label: {//默认的label显示时,是显示名字,如果希望内外圈显示的label不同,可以通过自己构建label函数。
                    normal:{
                          formatter:function (params) {
                          if(params.value != 0)
                              return params.data.name;
                          else
                              return '';
                      }
                      }
                },
                data:[
                    {value:335, name:'直达',type:"直达",itemStyle:{
                            normal:{
                                color:colors[Math.floor(40*Math.random())]
                            }}},
                    {value:310, name:'直达',type:"邮件营销",itemStyle:{
                            normal:{
                                color:colors[Math.floor(40*Math.random())]
                            }}},
                    {value:234, name:'直达',type:"联盟广告",itemStyle:{
                            normal:{
                                color:colors[Math.floor(40*Math.random())]
                            }}},
                    {value:135, name:'直达',type:"视频广告",itemStyle:{
                            normal:{
                                color:colors[Math.floor(40*Math.random())]
                            }}},
                    {value:1048, name:'营销广告',type:"百度",itemStyle:{
                            normal:{
                                color:colors[Math.floor(40*Math.random())]
                            }}},
                    {value:251, name:'营销广告',type:"谷歌",itemStyle:{
                            normal:{
                                color:colors[Math.floor(40*Math.random())]
                            }}},
                    {value:147, name:'营销广告',type:"必应",itemStyle:{
                            normal:{
                                color:colors[Math.floor(40*Math.random())]
                            }}},
                    {value:102, name:'营销广告',type:"其他",itemStyle:{
                            normal:{
                                color:colors[Math.floor(40*Math.random())]
                            }}}
                ]
            }
        ]
    };

    if (option && typeof option === "object") {
      myChart.setOption(option, true);
    }

     
  • 相关阅读:
    Delphi程序流程三(2)(while)PS:最简单的任务管理器( 组件LISTVIEW的用法 增加LISTVIEW的读取 删除)
    Delphi 编译错误信息表(转载自万一博客)
    Delphi程序流程三(1)(while)PS:顺便写了个最简单的任务管理器(包含申明API 自己申明参数为结构型API 组件LISTVIEW的用法)
    Delphi程序流程二(for)
    内核编程 warning C4273: 'PsGetProcessId' : inconsistent dll linkage
    简单的SEH处理
    【转】VC6.0各个文件说明
    【转】两篇关于__security_cookie的介绍
    完美解决 error C2220: warning treated as error
    【转】IDA 与VC 加载符号表
  • 原文地址:https://www.cnblogs.com/sunBinary/p/10076960.html
Copyright © 2011-2022 走看看