国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

html5 - echarts legend
曾經(jīng)蠟筆沒有小新
曾經(jīng)蠟筆沒有小新 2017-05-16 13:37:59
0
1
546

As shown in the figure, I want to directly obtain the name of each segment of the pie chart in the background and use it as the legend directly, replacing the red "test" at the top. How to get the name of each segment? Thanks!

曾經(jīng)蠟筆沒有小新
曾經(jīng)蠟筆沒有小新

reply all(1)
習(xí)慣沉默
    var myChart = echarts.init(document.getElementById('main')),
        option = {
            tooltip: {},
            legend: {},
            series: [{
                name: '訪問來源',
                type: 'pie',
                radius: '55%',
                center: ['50%', '60%'],
                data: [],
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }]
        };
    myChart.setOption(option);

    //以下為ajax獲取到的數(shù)據(jù)
    var data = [{
            value: 335,
            name: '直接訪問'
        }, {
            value: 310,
            name: '郵件營銷'
        }, {
            value: 234,
            name: '聯(lián)盟廣告'
        }, {
            value: 135,
            name: '視頻廣告'
        }, {
            value: 1548,
            name: '搜索引擎'
        }],
        legends = []
    data.forEach(function(e, i) {
        legends.push(e.name)
    })
    myChart.setOption({
        legend: {
            data: legends
        },
        series: [{
            data: data
        }]

    });
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template