5.14. Example - Stacked Bars, Shaded

This is a stacked bar chart, with the default 3-D shaded look. (Compare with Example 5.15, “Stacked Bars, Unshaded” which has no shading.) The only valid data types for stacked bars are 'text-data' (for vertical plots), and 'text-data-yx' (for horizontal plots).

Example 5.14. Stacked Bars, Shaded

Stacked Bars, Shaded Example
<?php
# PHPlot Example: Stacked Bars, shaded
require_once 'phplot.php';

$data = array(
  array('Jan', 40, 5, 10, 3), array('Feb', 90, 8, 15, 4),
  array('Mar', 50, 6, 10, 4), array('Apr', 40, 3, 20, 4),
  array('May', 75, 2, 10, 5), array('Jun', 45, 6, 15, 5),
  array('Jul', 40, 5, 20, 6), array('Aug', 35, 6, 12, 6),
  array('Sep', 50, 5, 10, 7), array('Oct', 45, 6, 15, 8),
  array('Nov', 35, 6, 20, 9), array('Dec', 40, 7, 12, 9),
);

$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');

$plot->SetPlotType('stackedbars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);

$plot->SetTitle('Candy Sales by Month and Product');
$plot->SetYTitle('Millions of Units');
$plot->SetLegend(array('Chocolates', 'Mints', 'Hard Candy', 'Sugar-Free'));

$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');

$plot->DrawGraph();

SourceForge.net Logo

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.