5.10. Example - Pie Chart, flat with options
Prev | Chapter 5. PHPlot Examples | Next

## 5.10. Example - Pie Chart, flat with options

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();

Prev | Up | Next
5.9. Example - Pie Chart, text-data | Home | 5.11. Example - Points Plot with Error Bars