douluyezhen4512 2011-05-19 18:28
浏览 34
已采纳

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 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题