douluyezhen4512 2011-05-19 18: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 11:19
    关注

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

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

报告相同问题?

悬赏问题

  • ¥15 软件供应链安全是跟可靠性有关还是跟安全性有关?
  • ¥15 电脑蓝屏logfilessrtsrttrail问题
  • ¥20 关于wordpress建站遇到的问题!(语言-php)(相关搜索:云服务器)
  • ¥15 【求职】怎么找到一个周围人素质都很高不会欺负他人,并且未来月薪能够达到一万以上(技术岗)的工作?希望可以收到写有具体,可靠,已经实践过了的路径的回答?
  • ¥15 Java+vue部署版本反编译
  • ¥100 对反编译和ai熟悉的开发者。
  • ¥15 带序列特征的多输出预测模型
  • ¥15 Python 如何安装 distutils模块
  • ¥15 关于#网络#的问题:网络是从楼上引一根网线下来,接了2台傻瓜交换机,也更换了ip还是不行
  • ¥15 资源泄露软件闪退怎么解决?