|
Pie Chart sector rendering bug, when using SVG? |
Posted by Line Wolff on Jun-23-2014 20:16 |
|
I'm trying to render a 3 sector pie with one sector being 100% and the others 0%. This
case renders fine in PNG, but fails to render the 100% sector correctly when using SVG. I
see a single vertical colored line at 0% instead of the sector filling the pie 100%.
I tried rendering the SVG in Firefox, IE, Chrome and Safari (iPhone), all same result.
Here's the code (based on the "Simple Pie Chart" sample):
<?php
require_once("phpchartdir.php");
# The data for the pie chart
// $data = array(25, 18, 15, 12, 8, 30, 35);
$data = array(0, 0, 100);
# The labels for the pie chart
$labels = array("Labor", "Licenses", "Taxes", "Legal", "Insurance", "Facilities",
"Production");
# Create a PieChart object of size 360 x 300 pixels
$c = new PieChart(360, 300);
$c->enableVectorOutput();
# Set the center of the pie at (180, 140) and the radius to 100 pixels
$c->setPieSize(180, 140, 100);
# Set the pie data and the pie labels
$c->setData($data, $labels);
# Output the chart
//header("Content-type: image/png");
//print($c->makeChart2(PNG));
header("Content-type: image/svg+xml");
print($c->makeChart2(SVG));
Is it a bug, or an error on my part? |
Re: Pie Chart sector rendering bug, when using SVG? |
Posted by Peter Kwan on Jun-24-2014 05:02 |
|
Hi Line,
I confirm this is in fact due to a bug in ChartDirector. To work around the problem, one
method is to replace 0 with NoValue, like:
for ($i = 0; $i < count($data); ++$i)
if ($data[$i] == 0) $data[$i] = NoValue;
Using NoValue will also disable the labels for those sectors. In other words, there will be no
sector label for the NoValue sectors, and no legend entry for those sectors (in case you
plan to add a legend box to the chart).
If you prefer the original behaviour (that is, even zero values have sector labels and legend
entries), we will need to issue a patch to you. In this case, please let me know which
operating system edition of ChartDirector you are using.
Regards
Peter Kwan |
Re: Pie Chart sector rendering bug, when using SVG? |
Posted by Line Wolff on Jun-24-2014 14:39 |
|
Hi Peter,
Thanks for quick replying.
I do indeed need the labels (unfortunately), so a patch would be welcomed.
We're using ChartDirector for PHP, Linux x86_64.
/ Line |
Re: Pie Chart sector rendering bug, when using SVG? |
Posted by Peter Kwan on Jun-25-2014 02:19 |
|
Hi Line,
Below please find an updated "libchartdir.so" for "ChartDirector for PHP for Linux (x86_64)"
that should fix this SVG problem. Please kindly replace your existing "libchartdir.so" with the
updated one. Please ensure you have replaced the "libchartdir.so" which is actually used by
your PHP (usually copied to the PHP extension directory). You may need to restart your
Apache/PHP system after replacing the shared object.
http://www.advsofteng.com/cd_linux_64_511p1.zip
Hope this can help.
Regards
Peter Kwan |
Re: Pie Chart sector rendering bug, when using SVG? |
Posted by Line Wolff on Jun-25-2014 14:04 |
|
Thanks! It worked flawlessly.
/ Line |
|