すべての棒グラフの色を単一の色でオーバーライドするために単一の色を配列にプッシュしていますが、意図したとおりに機能しません。配列に問題があります。
私の元の質問: 配列を 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 ) ) )