doupi6737 2015-10-06 12:54
浏览 157
已采纳

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

I am developing php statistic part of my app with pChart, but I met a difficulty trying to set the colors of my bars with the pChart librairy. I want to change color of each bar. Is it possible to change the color ? Like for slices ?

My chart just has 1 serie, I have 4 bars.

With Pie chart I can use this

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

How will I manage it with bars ? I have no indication on documentation.

  • 写回答

1条回答 默认 最新

  • douli6605 2015-10-07 07:26
    关注

    Yes you can do that, but you have to use custom palette for that.

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

    If you want more info you can find it here. http://wiki.pchart.net/doc.chart.drawbarchart.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号