echarts 饼图动态赋值

$sql2 = “SELECT lg.name,count(lg.name) as lgnumber from lt_gchannel as lg LEFT JOIN lt_player as lp on lg.id = lp.gchannel_id GROUP BY lg.name“;

    $result = db::query($sql2);

echarts 饼图动态赋值_第1张图片

var test = {
tests:{:json_encode(array_values($result))}
}
整成 json 格式

{tests: Array(4)}tests: Array(4)0: {name: “360”, lgnumber: 13}1: {name: “91”, lgnumber: 11}2: {name: “百度”, lgnumber: 7}3: {name: “谷歌”, lgnumber: 4}

var danaChart = Echarts.init(document.getElementById(‘danaChart’), ‘walden’);

        danaChart.setOption({
            title: {
                text: '',
                subtext: '',
                x:'center'
            },
            tooltip : {
                trigger: 'item',
                formatter: "{a} 
{b} : {c} ({d}%)" }, backgroundColor: '#2c343c', legend: { data: danaName.column }, toolbox: { show : true, feature : { mark : {show: true}, dataView : {show: true, readOnly: false}, magicType : { show: true, type: ['pie', 'funnel'] }, restore : {show: true}, saveAsImage : {show: true} } }, series : [ { name: '渠道来源', type: 'pie', radius: '55%', roseType: 'angle', data:(function () { var arrNum = []; var testd = test.tests; for(var i=0;i

echarts 饼图动态赋值_第2张图片

参考:http://blog.csdn.net/a854507555/article/details/64444357

你可能感兴趣的:(json)