我将一种颜色推入一个数组,以用一种颜色覆盖每个条形图颜色,但它没有按预期工作,数组有问题。
我的原始问题:如何将数组推送到 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));
$palette_cycle 的 Print_R 结果:
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 ) ) )