douluyezhen4512 2011-05-19 10:28
浏览 35
已采纳

php pchart饼图问题0值

I have a problem with my pie chart when I have 0 values $MyData->addPoints(array(10,20,20,15,23),"Data");
This works fine and converts to percentages across a pie chart however if any of these values are 0 which could happen as I'm dealing with counts and these are really variables in my script) then everything screws up and the color of the legend don't correlate with the data values. Basically in the pie chart the color palette only assigns a value to non 0 points

10    $PieChart->setSliceColor(0,array("R"=>48,"G"=>199,"B"=>13));
20    $PieChart->setSliceColor(1,array("R"=>246,"G"=>2,"B"=>8));
20    $PieChart->setSliceColor(2,array("R"=>233,"G"=>215,"B"=>59));  
15    $PieChart->setSliceColor(3,array("R"=>38,"G"=>42,"B"=>191));       
23    $PieChart->setSliceColor(3,array("R"=>38,"G"=>42,"B"=>191));       



10    $PieChart->setSliceColor(0,array("R"=>48,"G"=>199,"B"=>13));
0     
20    $PieChart->setSliceColor(1,array("R"=>246,"G"=>2,"B"=>8));
15    $PieChart->setSliceColor(2,array("R"=>233,"G"=>215,"B"=>59));  
23    $PieChart->setSliceColor(3,array("R"=>38,"G"=>42,"B"=>191));       
     $PieChart->setSliceColor(3,array("R"=>38,"G"=>42,"B"=>191));    

Is this a common problem?

  • 写回答

3条回答 默认 最新

  • duanbi8089 2011-05-24 03:19
    关注

    I used a quick hack to bypass this bug, try to replace your zero values by -0.0001.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部