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.28. Example - Horizontal Stacked 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-horizbar.html" title="5.27. Example - Horizontal Bar Chart" /><link rel="next" href="ex-horizthinbarline.html" title="5.29. Example - Horizontal Thin Bar Line Plot" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.28. Example - Horizontal Stacked Bar Chart</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-horizbar.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%" align="right"> <a accesskey="n" href="ex-horizthinbarline.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-horizstackedbar"></a>5.28. Example - Horizontal Stacked Bar Chart</h2></div></div></div><p>
3
This example shows a horizontal stacked bar chart.
4
As always, the X axis is horizontal, and the Y axis is vertical.
5
But the data array contains the X value for each implicit Y.
6
The data type 'text-data-yx' indicates this is a
7
horizontal plot.
8
</p><div class="example"><a id="example-horizstackedbar"></a><p class="title"><strong>Example 5.28. Horizontal Stacked Bar Chart</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/horizstackedbar.png" alt="Horizontal Stacked Bar Chart Example" /></div></div><pre class="programlisting">&lt;?php
9
# PHPlot Example - Horizontal Stacked Bars
10
require_once 'phplot.php';
11
 
12
$column_names = array(
13
                 'Beef', 'Fish', 'Pork', 'Chicken', 'Butter',
14
                                                         'Cheese',
15
                                                               'Ice Cream');
16
//                   |       |       |       |       |       |       |
17
$data = array(
18
    array('1910',   48.5,   11.2,   38.2,   11.0,   18.4,    3.9,    1.9),
19
    array('1930',   33.7,   10.2,   41.1,   11.1,   17.6,    4.7,    9.7),
20
    array('1950',   44.6,   11.9,   43.0,   14.3,   10.9,    7.7,   17.4),
21
    array('1970',   79.6,   11.7,   48.1,   27.4,    5.4,   11.4,   17.8),
22
    array('1990',   63.9,   14.9,   46.4,   42.4,    4.0,   24.6,   15.8),
23
);
24
$plot = new PHPlot(800, 500);
25
$plot-&gt;SetImageBorderType('plain'); // Improves presentation in the manual
26
$plot-&gt;SetTitle("U.S. Annual Per-Capita Consumption\n"
27
              . "of Selected Meat and Dairy Products");
28
$plot-&gt;SetLegend($column_names);
29
#  Move the legend to the lower right of the plot area:
30
$plot-&gt;SetLegendPixels(700, 300);
31
$plot-&gt;SetDataValues($data);
32
$plot-&gt;SetDataType('text-data-yx');
33
$plot-&gt;SetPlotType('stackedbars');
34
$plot-&gt;SetXTitle('Pounds Consumed Per Capita');
35
#  Show data value labels:
36
$plot-&gt;SetXDataLabelPos('plotstack');
37
#  Rotate data value labels to 90 degrees:
38
$plot-&gt;SetXDataLabelAngle(90);
39
#  Format the data value labels with 1 decimal place:
40
$plot-&gt;SetXDataLabelType('data', 1);
41
#  Specify a whole number for the X tick interval:
42
$plot-&gt;SetXTickIncrement(20);
43
#  Disable the Y tick marks:
44
$plot-&gt;SetYTickPos('none');
45
$plot-&gt;DrawGraph();
46
</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-horizbar.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-horizthinbarline.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.27. Example - Horizontal 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.29. Example - Horizontal Thin Bar Line Plot</td></tr></table></div></body></html>