我將單一顏色推入一個數組,以便用單一顏色覆蓋每個條形圖的顏色,但其不能按預期工作,數組有問題。如何糾正一個foreach循環並獲得想要的數組深度?
我原來的問題:如何將數組推到barChart和顏色覆蓋pChart中的單色?
已更新問題: print_r結果顯示額外的2組數組,它應該只是一個數組,它不會更深,它們在哪裏被添加?我如何糾正它?
PHP/pChart:
$prop_open=(1,5,8,4,2,66);
$j=0;
$palette_cycle=array();
foreach($prop_open as $value) {
array_push($palette_cycle,array("$j"=>array("R"=>108,"G"=>157,"B"=>49,"Alpha"=>100)));
$j++;
}
$palette=$palette_cycle;
$myPicture->drawBarChart(array("OverrideColors"=>$palette,"DisplayOrientation"=>ORIENTATION_HORIZONTAL,"DisplayPos"=>LABEL_POS_INSIDE,"DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_MANUAL,"DisplayR"=>0,"DisplayG"=>0,"DisplayB"=>0,"Surrounding"=>-60,"InnerSurrounding"=>60));
這是我的$ palette_cycle數組應該如何結束後對其做期待(但所有RGB是相同的):
$palette_cycle = array("0"=>array("R"=>188,"G"=>224,"B"=>46,"Alpha"=>100),
"1"=>array("R"=>224,"G"=>100,"B"=>46,"Alpha"=>100),
"2"=>array("R"=>224,"G"=>214,"B"=>46,"Alpha"=>100),
"3"=>array("R"=>46,"G"=>151,"B"=>224,"Alpha"=>100),
"4"=>array("R"=>176,"G"=>46,"B"=>224,"Alpha"=>100),
"5"=>array("R"=>224,"G"=>46,"B"=>117,"Alpha"=>100),
"6"=>array("R"=>92,"G"=>224,"B"=>46,"Alpha"=>100),
"7"=>array("R"=>224,"G"=>176,"B"=>46,"Alpha"=>100));
print_r的結果$ palette_cycle :
Array (
[0] => Array ([0] => Array ([R] => 108 [G] => 157 [B] => 49 [Alpha] => 100))
[1] => Array ([1] => Array ([R] => 108 [G] => 157 [B] => 49 [Alpha] => 100))
[2] => Array ([2] => Array ([R] => 108 [G] => 157 [B] => 49 [Alpha] => 100))
[3] => Array ([3] => Array ([R] => 108 [G] => 157 [B] => 49 [Alpha] => 100))
[4] => Array ([4] => Array ([R] => 108 [G] => 157 [B] => 49 [Alpha] => 100))
[5] => Array ([5] => Array ([R] => 108 [G] => 157 [B] => 49 [Alpha] => 100)))
我使用'for($ i = 0; $ i 108,「G」=> 157,「B」 => 49,「Alpha」=> 100));}'但是,謝謝! –
2012-04-25 16:39:54
np,很高興你知道了 – squarephoenix 2012-04-25 16:40:39