
export function fanChart(data: any,name:string,color:any) {//扇形图
    var defaultcolor  = ['#9FCEFE', '#66B1FF','#79BBFF', '#8CC5FF', '#53A8FF'] //默认颜色
    const option = {
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            top:"50",
            left: 'right'
        },
        series: [
            {
                color:color?color:defaultcolor,
                name: name,
                type: 'pie',
                radius: ['30%', '60%'],
                data: data,
            }
        ]
    }
    return option
}

export function barChartOne(dataLists: object) {//单柱状图
    var dataList = {
         xAxisData:dataLists.xAxisData,
         series:dataLists.series
    }

    const option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                crossStyle: {
                    color: '#999'
                }
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            top: '13%',
            containLabel: true
        },
        xAxis: [
            {
                type: 'category',
                data: dataList.xAxisData,
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '',
                axisLabel: {
                    formatter: '{value}'
                }
            },
        ],
        series: [
            {
                name: '',
                type: 'bar',
                barWidth:"50%",
                data: dataLists.series
            }
        ]
    };
    return option
}

export function barChart(dataLists: object) { //双行柱状图
    var dataList = {
        legendData:dataLists.legendData?dataLists.legendData:[],
        xAxisData:dataLists.xAxisData,
        yAxisData:dataLists.yAxisData,
        series:{
            data1:dataLists.series.data1,
            data2:dataLists.series.data2?dataLists.series.data2:[],
        }
    }

    const option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                crossStyle: {
                    color: '#999'
                }
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            top: '13%',
            containLabel: true
        },
        legend: {
            data: dataList.legendData
        },
        xAxis: [
            {
                type: 'category',
                data: dataList.xAxisData,
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '',
                axisLabel: {
                    formatter: '{value}' + dataList.yAxisData[0]
                }
            },
        ],
        series: [
            {
                name: dataList.legendData[0],
                type: 'bar',
                data: dataList.series.data1
            },
            {
                name: dataList.legendData[1],
                type: 'bar',
                data: dataList.series.data2
            },
        ]
    };
    return option
}

//商品房分析  商品房住宅统计
export function barChartList(city?: any,sun?:any,prompt?:string) {//多个维度图表 商品房分析
    var suns = []
    suns = sun
    if (prompt == 1){
        var pro = 'item'
    }else {
        var pro = 'axis'
    }
    const option = {
        tooltip: {
            trigger: pro,
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            top: '13%',
            containLabel: true
        },
        legend: {},
        xAxis: [
            {
                type: 'category',
                data: city,
                axisPointer: {
                    type: 'shadow'
                }
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '',
                axisLabel: {
                    formatter: '{value}'
                }
            },
        ],
        series: suns
    };
    return option
}
//商品房分析 商品房 总量分析  折线
export function lineChartList(city:any,sun:any) {//多个维度图表 商品房分析
    const option = {
        tooltip: {
            trigger: 'axis'
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        legend: {},
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: city
        },
        yAxis: [
            {
                type: 'value',
                name: '',
                axisLabel: {
                    formatter: '{value}'
                }
            },
            {
                type: 'value',
                name: '',
                splitLine:{
                    show:false
                },
                axisLabel: {
                    formatter: '{value}'
                }
            }
        ],
        series: sun
    };
    return option
}

//商品房分析 商品房 总量分析  折线
export function yearChartList(city:any,aline:any) {//多个维度图表 商品房分析
    const option = {
        tooltip: {
            trigger: 'axis'
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        legend: {},
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: city
        },
        yAxis: [
            {
                type: 'value',
                name: '',
                axisLabel: {
                    formatter: '{value}'
                }
            },
            {
                type: 'value',
                name: '',
                splitLine:{
                    show:false
                },
                axisLabel: {
                    formatter: '{value}'
                }
            }
        ],
        series: aline
    };
    return option
}
