6种颜色 都为正则为数组 1 ,都为负则为 数组2 。 红数组1 绿数组2


//top3色块值
        $topcolor = array();
        $topColorU = array("f70a0a","ec3535","f15555");
        $topColorD = array("10f610","4cdf4c","74f274");
        $top3Value = array($top3_1_val,$top3_2_val,$top3_3_val);
        //$top3Value2 = rsort($top3Value);
        //var_dump($top3Value);die();
        rsort($top3Value);

        if ($top3Value[0] > 0) {
            $top3_01_value = "+" . $top3Value[0] . "%";
        } elseif($top3Value[0] <0) {
            $top3_01_value = "" . $top3Value[0] . "%";
        }else{
            $top3_01_value = "--";
        }
        if ($top3Value[1] > 0) {
            $top3_02_value = "+" . $top3Value[1] . "%";
        } elseif($top3Value[1] <0) {
            $top3_02_value = "" . $top3Value[1] . "%";
        }else{
            $top3_02_value = "--";
        }
        if ($top3Value[2] > 0) {
            $top3_03_value = "+" . $top3Value[2] . "%";
        } elseif($top3Value[2] <0) {
            $top3_03_value = "" . $top3Value[2] . "%";
        }else{
            $top3_03_value = "--";
        }




        //var_dump($top3Value);die();
        if(($top3_1_val == 0 and $top3_2_val == 0) and  $top3_3_val ==0){
            for($i=0;$i<3;$i++){
                $topcolor[] = $topColorU[$i];
            }
        }else{
            $i = 0;
            //var_dump($top3Value);
            foreach($top3Value as $key => $value){
                if($value>0){
                    $topcolor[] = $topColorU[$i];
                    //array_splice($top3Value,1,1);
                    unset($top3Value[$i]);
                }

                $i = $i + 1;
            }
            array_merge($top3Value);

            $top3Value = array_merge($top3Value);
            $i = 0;
            foreach($top3Value as $key => $value){
                if($value<0){
                    $topcolor[] = $topColorD[$i];
                }
                $i = $i + 1;
            }

        }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值