Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
98 - 1
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
2
<!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.6. Example - Bar Chart, Label Options</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-bars2.html" title="5.5. Example - Unshaded Bar Chart" /><link rel="next" href="ex-linepoints1.html" title="5.7. Example - Line/Point Plot, Point Shapes" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.6. Example - Bar Chart, Label Options</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-bars2.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%" align="right"> <a accesskey="n" href="ex-linepoints1.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-bars3"></a>5.6. Example - Bar Chart, Label Options</h2></div></div></div><p>
3
This is a bar chart showing data per year. Because the Y values are so
4
large, we enable numeric formatting of Y tick labels, with precision 0.
5
This results in a comma separator between thousands.
6
This example also shows how to force the Y tick marks to start at zero and
7
use a nice whole number for the tick interval.
8
</p><div class="example"><a id="example-bars3"></a><p class="title"><strong>Example 5.6. Bar Chart - Label Options</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/bars3.png" alt="Bar Chart with Labels Example" /></div></div><pre class="programlisting">&lt;?php
9
# PHPlot Example: Bar chart, annual data
10
require_once 'phplot.php';
11
 
12
$data = array(
13
  array('1985', 340),    array('1986', 682),    array('1987', 1231),
14
  array('1988', 2069),   array('1989', 3509),   array('1990', 5283),
15
  array('1991', 7557),   array('1992', 11033),  array('1993', 16009),
16
  array('1994', 24134),  array('1995', 33768),  array('1996', 44043),
17
  array('1997', 55312),  array('1998', 69209),  array('1999', 86047),
18
  array('2000', 109478), array('2001', 128375), array('2002', 140767),
19
);
20
 
21
$plot = new PHPlot(800, 600);
22
$plot-&gt;SetImageBorderType('plain');
23
 
24
$plot-&gt;SetPlotType('bars');
25
$plot-&gt;SetDataType('text-data');
26
$plot-&gt;SetDataValues($data);
27
 
28
# Let's use a new color for these bars:
29
$plot-&gt;SetDataColors('magenta');
30
 
31
# Force bottom to Y=0 and set reasonable tick interval:
32
$plot-&gt;SetPlotAreaWorld(NULL, 0, NULL, NULL);
33
$plot-&gt;SetYTickIncrement(10000);
34
# Format the Y tick labels as numerics to get thousands separators:
35
$plot-&gt;SetYLabelType('data');
36
$plot-&gt;SetPrecisionY(0);
37
 
38
# Main plot title:
39
$plot-&gt;SetTitle('US Cell Phone Subscribership');
40
# Y Axis title:
41
$plot-&gt;SetYTitle('Thousands of Subscribers');
42
 
43
# Turn off X tick labels and ticks because they don't apply here:
44
$plot-&gt;SetXTickLabelPos('none');
45
$plot-&gt;SetXTickPos('none');
46
 
47
$plot-&gt;DrawGraph();
48
</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-bars2.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-linepoints1.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.5. Example - Unshaded Bar Chart </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.7. Example - Line/Point Plot, Point Shapes</td></tr></table></div></body></html>