For this pie chart, we turned off shading with SetShading to get a flat pie instead of a 3-D look. We also overrode the default colors with our own array using SetDataColors, and used the same color names to make a legend with SetLegend. Finally, we moved the labels in towards the center with SetLabelScalePosition.
Example 5.10. Pie Chart, flat with options
<?php # PHPlot Example: Flat Pie with options require_once 'phplot.php'; $data = array( array('', 10), array('', 20), array('', 30), array('', 35), array('', 5), ); $plot = new PHPlot(800,600); $plot->SetImageBorderType('plain'); $plot->SetDataType('text-data-single'); $plot->SetDataValues($data); $plot->SetPlotType('pie'); $colors = array('red', 'green', 'blue', 'yellow', 'cyan'); $plot->SetDataColors($colors); $plot->SetLegend($colors); $plot->SetShading(0); $plot->SetLabelScalePosition(0.2); $plot->DrawGraph();
This version of the manual was produced for the
PHPlot Sourceforge project web service site, which requires the logo on each
page.
To download a logo-free copy of the manual, see the
PHPlot project downloads
area.