关于echarts:echarts饼图

28次阅读

共计 670 个字符,预计需要花费 2 分钟才能阅读完成。

饼图官网手册

var set_option = function(series_data,title_text){
return {
    title: {
            text: title_text, // 饼图题目
            subtext: '',    // 饼图副标题
            left: 'center'  // 题目地位
        },
 tooltip: {
            trigger: 'item',
            formatter: "{b}: {c} ({d}%)"
        },
 legend: {
             x: 'left',  // 图释在图的地位  上下左右
             type: 'scroll',  // 可滚动图例,展现地区图例时好用
             orient: 'vertical',
             right: 0,
             top: 20,
             bottom: 10,
             data:series_data  // 如果不应用 type: 'scroll' 能够不写
         },
 series: [
            {
                name:'',
                type:'pie',
                //color: ['#73c0de', '#5470c6', '#91cc75'],// 可设置色彩
                // radius: ['0%', '80%'], // 饼图形态 ['内圆半径','外圆半径'],['30%', '80%'] 就是环形图
                data:series_data
            }
        ]
    };
 }
 
 var myChart = echarts.init(document.getElementById('state'), 'light');
 var series_data = [{value:1, name:'男'},
        {value:1, name:'女'},
    ];
var title = '性别统计';
myChart.setOption(set_option(series_data, title));

正文完
 0