import _ from 'lodash-es';
import { $echarts } from '../../index.js';

export default ({
    dom,
    param,
    opt
}) => {
    /**
     * 导出配置项
     */
    let option = {
        angleAxis: {
            axisLine: 'none',
            axisLabel: 'none',
            splitLine: 'none',
            axisTick: 'none',
            min: 0,
            max: 300,
            startAngle: 150
        },
        radiusAxis: {
            type: 'category',
            axisLine: 'none',
            axisTick: 'none',
            axisLabel: 'none',
        },
        polar: {
            radius: '170%',
            center: ['50%', '66%']
        },
        series: [{
                type: 'bar',
                coordinateSystem: 'polar',
                barMaxWidth: 42,
                label: {
                  show: true,
                  fontSize: 16,
                  fontWeight: 'bold',
                  position: 'insideBottomLeft',
                  padding: [0, 0, 10, 4],
                  formatter: param.data + '% '
                },
                data: [param.data > 100 ? 100 : param.data],
                itemStyle: {
                    color: param.color
                }
            },
            {
                type: 'bar',
                z: 0,
                silent: true,
                coordinateSystem: 'polar',
                barMaxWidth: 42,
                color: '#000228',
                barGap: '-100%',
                data: [100]
            }
        ]
    }

    /**
     * 渲染
     */
    let extensOption = $echarts.extens(opt, option);

    let echarts = $echarts.render(dom, extensOption);
};