饼状图

createOptions = (data) => {
      const myOptions = {
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
            type: 'scroll',
            orient: 'vertical',
            textStyle:{
                color: '#ffffff'//字体颜色
            },
            right: 10,
            top: 20,
            bottom: 20,
            data: data[0]
        },
        grid: {
            left: '6%',
            // right: '5%',
            bottom: '3%',
            top: '15%',
            containLabel: true
          },
        series: [
            {
                type: 'pie',
                radius: ['50%', '65%'],
                center: ['40%', '60%'],
                data: data[1],
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                     },
                    normal:{
                        label:{ 
                            show: false, 
                            formatter: '{b} : {c} ({d}%)' 
                            }, 
                            labelLine :{show:true} ,
                            color:function(params) {
                              if(params && params.data && params.data.color){
                                return params.data.color
                              }
                            const colorList = [          
                                '#0091FF', '#8EEF24', '#50E3C2', '#F8E71C', '#7A4AA4', '#FE8463','#FE8463','#FE8463','#FE8463'
                            ];
                             return colorList[params.dataIndex]
                         }
                    }
              },
               
            }
        ]
    };
      return myOptions
    }
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容