PHP pChart改变条形图条形的颜色

时间:2015-10-06 12:54:31

标签: php codeigniter charts pchart

我正在使用pChart开发我的应用程序的php统计信息部分,但我遇到了尝试使用pChart librairy设置我的酒吧颜色的难度。我想改变每个酒吧的颜色。有可能改变颜色吗?喜欢切片?

我的图表只有1个系列,我有4个小节。

使用饼图我可以使用此

$PieChart = $this->pchart->pPie($myPicture,$MyData);
$PieChart->setSliceColor(0,array("R"=>255,"G"=>128,"B"=>0));
$PieChart->setSliceColor(1,array("R"=>255,"G"=>255,"B"=>255));
$PieChart->setSliceColor(2,array("R"=>25,"G"=>128,"B"=>0));
$PieChart->setSliceColor(4,array("R"=>55,"G"=>255,"B"=>25));

我如何用酒吧管理它?我没有关于文件的说明。

1 个答案:

答案 0 :(得分:3)

是的,你可以这样做,但你必须使用自定义调色板。

$Palette = 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));

$myPicture->drawBarChart(array("OverrideColors"=>$Palette));

如果您想了解更多信息,可以在此处找到。 http://wiki.pchart.net/doc.chart.drawbarchart.html