export const changeEchartsList = (arr: any) => {
    // 用来循环
    let ForArr: any = JSON.parse(JSON.stringify(arr));
    // return出去的数组
    let newArr: any = JSON.parse(JSON.stringify(arr));

    // for (let j = 0; j < ForArr.length; j++) {
    //     console.log('--------',ForArr.length)
    //     getMaxMin(ForArr)
    // }
    while (ForArr.length > 1) {
        getMaxMin(ForArr)
    }
    function getMaxMin(arr: any) {
        let maxValue = {
            search_rank: arr[0].search_rank,
            index: 0
        };
        let minValue = {
            search_rank: arr[0].search_rank,
            index: 0
        };
        for (let i = 1; i < arr.length; i++) {
            // 拿到最大值
            if (arr[i].search_rank >= maxValue.search_rank) {
                maxValue.search_rank = arr[i].search_rank;
                maxValue.index = i;
            }
        }
        ForArr.splice(maxValue.index, 1)
        for (let i = 1; i < arr.length; i++) {
            // 拿到最小值
            if (arr[i].search_rank <= minValue.search_rank) {
                minValue.search_rank = arr[i].search_rank;
                minValue.index = i;
            }
        }
        ForArr.splice(minValue.index, 1)
        // 当前最大值的下标
        let curIndexMax = newArr.findIndex((item: any, index: number) => item.search_rank === maxValue.search_rank)
        // 当前最小值得下标
        let curIndexMin = newArr.findIndex((item: any, index: number) => item.search_rank === minValue.search_rank)
        newArr[curIndexMax].value = minValue.search_rank
        newArr[curIndexMin].value = maxValue.search_rank
    }
    if (ForArr.length === 1) {
        let curIndex = newArr.findIndex((item: any, index: number) => item.search_rank === ForArr[0].search_rank)
        newArr[curIndex].newValue = ForArr[0].search_rank
    }
    return newArr
}