php pchart饼图0值问题
当我的值是 0 时,我的饼图出现问题 $MyData->addPoints(array(10,20,20,15,23),"数据");
这工作正常并转换为饼图上的百分比,但是如果这些值中的任何一个为 0,这可能会在我处理计数时发生,并且这些实际上是我的脚本中的变量)然后一切都会搞砸,图例的颜色也不会t 与数据值相关。基本上,在饼图中,调色板仅将值分配给非 0 点
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));
这是一个常见问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用了一个快速破解来绕过这个错误,尝试用 -0.0001 替换你的零值。
I used a quick hack to bypass this bug, try to replace your zero values by -0.0001.
此问题已在最新版本的 pChart 中修复。
This issue has been fixed in the latest version of pChart.
作为解决方法,您可以按降序对值进行排序,并相应地排列标签。
As as work around, you can sort the values in descending and order and arrange the label accordingly.