export default function getData(data, type) {
    let totle = data.reduce((a, b) => {
        return a + b.normal
    }, 0)
    let params = data.map(val => {
        return {
            value: (val.normal / totle).toFixed(4) * 100,
            name: val.deviceType
        }
    })
    return {
        title: {
            show: false,
            text: '某站点用户访问来源',
            subtext: '纯属虚构',
            left: 'center'
        },
        tooltip: {
            trigger: 'item',
            formatter: '{b}  {d}%',
        },
        legend: {
            orient: 'vertical',
            right: 0,
            top: 20,
            itemGap: 15,
            formatter: function(param) {
                return param + '    ' + params.find(val => val.name === param).value + '%';
            },
            tooltip: {
                show: true
            },
            textStyle: {
                color: "#FFF"
            }
        },
        series: [{
            // name: '访问来源',
            type: 'pie',
            radius: type === 'alarm' ? '90%' : ['50%', '90%'],
            center: ["30%", "50%"],
            label: {
                show: type === 'alarm',
                position: 'inner',
                fontSize: 14,
                align: "right",
                overflow: "truncate",
                baseline: "middle",
                color: '#FFF',
            },
            data: params,
            left: 1,
        }]
    }
}