Blame | Last modification | View Log | RSS feed
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>5.4. Example - Bar Chart</title><link rel="stylesheet" type="text/css" href="phplotdoc.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="PHPlot Reference Manual" /><link rel="up" href="examples.html" title="Chapter 5. PHPlot Examples" /><link rel="prev" href="ex-area1.html" title="5.3. Example - Area Plot" /><link rel="next" href="ex-bars2.html" title="5.5. Example - Unshaded Bar Chart" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.4. Example - Bar Chart</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-area1.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%
" align="right"> <a accesskey="n" href="ex-bars2.html">Next</a></td></tr></table><hr /></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="ex-bars1"></a>5.4. Example - Bar Chart</h2></div></div></div><p>
This is a bar chart with three data sets plotted. The data type is
'text-data', so the X values are implicit. But the X values are
not relevant because the data labels (month names) are used instead,
and the X tick marks and labels are turned off. This plot uses the default
shading of bars.
</p><div class="example"><a id="example-bars1"></a><p class="title"><strong>Example 5.4. Bar Chart</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/bars1.png" alt="Bar Chart Example" /></div></div><pre class="programlisting"><?php
# PHPlot Example: Bar chart, 3 data sets, shaded
require_once 'phplot.php';
$data = array(
array('Jan', 40, 2, 4), array('Feb', 30, 3, 4), array('Mar', 20, 4, 4),
array('Apr', 10, 5, 4), array('May', 3, 6, 4), array('Jun', 7, 7, 4),
array('Jul', 10, 8, 4), array('Aug', 15, 9, 4), array('Sep', 20, 5, 4),
array('Oct', 18, 4, 4), array('Nov', 16, 7, 4), array('Dec', 14, 3, 4),
);
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
# Main plot title:
$plot->SetTitle('Shaded Bar Chart with 3 Data Sets');
# Make a legend for the 3 data sets plotted:
$plot->SetLegend(array('Engineering', 'Manufacturing', 'Administration'));
# Turn off X tick labels and ticks because they don't apply here:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->DrawGraph();
</pre></div></div><br class="example-break" /></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ex-area1.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="examples.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ex-bars2.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.3. Example - Area Plot </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.5. Example - Unshaded Bar Chart</td></tr></table></div></body></html>