php pchart饼图0值问题

发布于 2024-11-08 16:23:52 字数 1066 浏览 3 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寒江雪… 2024-11-15 16:23:52

我使用了一个快速破解来绕过这个错误,尝试用 -0.0001 替换你的零值。

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

娇俏 2024-11-15 16:23:52

此问题已在最新版本的 pChart 中修复。

This issue has been fixed in the latest version of pChart.

我乃一代侩神 2024-11-15 16:23:52

作为解决方法,您可以按降序对值进行排序,并相应地排列标签。

As as work around, you can sort the values in descending and order and arrange the label accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文