import * as echarts from "echarts";

export default function getData(params = .23, color = ['#0099ff', '#00d5ff'], name = '处置率') {
    return {
        // backgroundColor:{
        //       type: 'radial',
        //       x: 0.5,
        //       y: 0.5,
        //       r: 0.5,
        //       colorStops: [
        //         { offset: 0,color: "#122c7a",},
        //         { offset: 0.9,color: "#122c7a",},
        //         { offset: 0.9,color: "#0b1f61",},
        //         { offset: 1,color: "#0b1f61",},
        //         { offset: 1,color: "transparent",},
        //       ],
        //       global: true // 缺省为 false
        // },
        title: {
            show: true,
            text: name,
            left: "center",
            right: "center",
            bottom: "center",
            top: "52%",
            center: 20,
            textStyle: {
                color: "#FFF",
                fontSize: 14,
                align: "center",
                fontWeight: "100",
                fontFamily: '"DS", "DS-B", "DS-BB", "DS-BS"',
            },
        },
        series: [{
            type: "gauge",
            radius: "90%",
            // center: ["50%","70%"],
            startAngle: 225, //开始角度 左侧角度
            endAngle: -135, //结束角度 右侧
            z: 4,
            axisLine: {
                show: true,
                roundCap: true,
                lineStyle: {
                    width: 10,
                    color: [
                        [1,
                            new echarts.graphic.LinearGradient(0, 0, 1, 0, [
                                { offset: 0, color: color[2] },
                                { offset: 1, color: color[0] },
                            ]),
                        ],
                        [
                            params > .5 ? params : 1 - params, color[1]
                        ],
                    ],
                },
            },
            //分隔线样式。
            splitLine: {
                show: false,
            },
            axisLabel: {
                show: false,
            },
            axisTick: {
                show: false,
            },
            pointer: {
                show: false,
                length: "70%",
                width: "2%",
            },
            title: {
                show: false,
            },
            //仪表盘详情，用于显示数据。
            detail: {
                show: true,
                offsetCenter: [0, "-20%"],
                color: "#ffffff",
                textStyle: {
                    fontSize: 26,
                    color: color[2],
                    fontWeight: "500",
                    fontFamily: '"DS", "DS-B", "DS-BB", "DS-BS"',
                },
                formatter: function(v) {
                    return v * 100 + "%";
                },
            },
            data: [{
                value: params,
            }, ],
        }, ],
    }
}