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.10. Example - Pie Chart, flat with 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-pie2.html" title="5.9. Example - Pie Chart, text-data" /><link rel="next" href="ex-points1.html" title="5.11. Example - Points Plot with Error Bars" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.10. Example - Pie Chart, flat with options</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-pie2.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%" align="right"> <a accesskey="n" href="ex-points1.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-pie3"></a>5.10. Example - Pie Chart, flat with options</h2></div></div></div><p>
|
|
|
3 |
For this pie chart, we turned off shading with <a class="xref" href="SetShading.html" title="SetShading"><span class="refentrytitle">SetShading</span></a>
|
|
|
4 |
to get a flat pie instead of a 3-D look.
|
|
|
5 |
We also overrode the default colors with our own array using
|
|
|
6 |
<a class="xref" href="SetDataColors.html" title="SetDataColors"><span class="refentrytitle">SetDataColors</span></a>,
|
|
|
7 |
and used the same color names to make a legend with <a class="xref" href="SetLegend.html" title="SetLegend"><span class="refentrytitle">SetLegend</span></a>.
|
|
|
8 |
Finally, we moved the labels in towards the center with
|
|
|
9 |
<a class="xref" href="SetLabelScalePosition.html" title="SetLabelScalePosition"><span class="refentrytitle">SetLabelScalePosition</span></a>.
|
|
|
10 |
</p><div class="example"><a id="example-pie3"></a><p class="title"><strong>Example 5.10. Pie Chart, flat with options</strong></p><div class="example-contents"><div class="informalfigure"><div class="mediaobject"><img src="examples/pie3.png" alt="Pie Chart, Flat, with Options Example" /></div></div><pre class="programlisting"><?php
|
|
|
11 |
# PHPlot Example: Flat Pie with options
|
|
|
12 |
require_once 'phplot.php';
|
|
|
13 |
|
|
|
14 |
$data = array(
|
|
|
15 |
array('', 10),
|
|
|
16 |
array('', 20),
|
|
|
17 |
array('', 30),
|
|
|
18 |
array('', 35),
|
|
|
19 |
array('', 5),
|
|
|
20 |
);
|
|
|
21 |
|
|
|
22 |
$plot = new PHPlot(800,600);
|
|
|
23 |
$plot->SetImageBorderType('plain');
|
|
|
24 |
$plot->SetDataType('text-data-single');
|
|
|
25 |
$plot->SetDataValues($data);
|
|
|
26 |
$plot->SetPlotType('pie');
|
|
|
27 |
|
|
|
28 |
$colors = array('red', 'green', 'blue', 'yellow', 'cyan');
|
|
|
29 |
$plot->SetDataColors($colors);
|
|
|
30 |
$plot->SetLegend($colors);
|
|
|
31 |
$plot->SetShading(0);
|
|
|
32 |
$plot->SetLabelScalePosition(0.2);
|
|
|
33 |
|
|
|
34 |
$plot->DrawGraph();
|
|
|
35 |
</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-pie2.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-points1.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.9. Example - Pie Chart, text-data </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.11. Example - Points Plot with Error Bars</td></tr></table></div></body></html>
|