/**
 * Created by Administrator on 2017/12/20.
 */
function creatPie(list, divId) {
    switch (divId) {
        case "statistics2Div2":
            var myChart = echarts.init(document.getElementById(divId));
            var da = [];
            for (var i = 0; i < list.length; i++) {
                da.push({
                    value: list[i].数量,
                    name: list[i].名称
                })
            }
            option = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{b} : {c} ({d}%)"
                },
                series: [
                    {
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '60%'],
                        data: da
                    }
                ]
            };
            myChart.setOption(option);
            break;
    }

}//饼状图
function createBar(list, divId) {
    switch (divId) {
        case "statistics2Div3":
            var myChart = echarts.init(document.getElementById(divId));
            var da1 = [];
            var da2 = [];
            for (var i = 0; i < list.length; i++) {
                if (i % 2 == 1) {
                    da1.push("\n" + list[i].名称)
                } else {
                    da1.push(list[i].名称)
                }

                da2.push(list[i].数量)
            }
            var option = {

                tooltip: {},

                xAxis: {
                    'axisLabel': {'interval': 0},
                    data: da1
                },
                yAxis: {},
                series: [{
                    type: 'bar',//柱状图
                    barWidth: '20%',
                    data: da2
                }]
            };
            myChart.setOption(option);
            break;
    }

}//柱状图