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>Chapter 4. PHPlot Advanced Topics</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="part1.html" title="Part I. PHPlot Programming" /><link rel="prev" href="conc-errors.html" title="3.9. Error Handling" /><link rel="next" href="adv-serialize.html" title="4.2. PHPlot Object Serialization" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. PHPlot Advanced Topics</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="conc-errors.html">Prev</a> </td><th width="60%" align="center">Part I. PHPlot Programming</th><td width="20%" align="right"> <a accesskey="n" href="adv-serialize.html">Next</a></td></tr></table><hr /></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="advanced"></a>Chapter 4. PHPlot Advanced Topics</h2></div></div></div><div class="abstract"><p class="title"><strong></strong></p><p>
|
|
|
3 |
This chapter documents advanced PHPlot programming topics, going beyond the
|
|
|
4 |
material in <a class="xref" href="concepts.html" title="Chapter 3. PHPlot Concepts">Chapter 3, <em>PHPlot Concepts</em></a>.
|
|
|
5 |
</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="adv-customclass"></a>4.1. Custom PHPlot Class</h2></div></div></div><div class="abstract"><p class="title"><strong></strong></p><p>
|
|
|
6 |
This section describes how to create a custom PHPlot class.
|
|
|
7 |
</p></div><p>
|
|
|
8 |
If you have a number of applications that use PHPlot, and you want to
|
|
|
9 |
standardize some of the PHPlot default settings, you can define your
|
|
|
10 |
own class which extends the PHPlot class and changes the default settings.
|
|
|
11 |
Here is a short example of a custom PHPlot class, which changes the
|
|
|
12 |
following defaults:
|
|
|
13 |
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Use a TrueType font for all text</p></li><li class="listitem"><p>Change the default image size to 800 x 600</p></li><li class="listitem"><p>Change the default title colors to red</p></li></ul></div><p>
|
|
|
14 |
</p><p>
|
|
|
15 |
To extend the PHPlot class, declare your class as shown below. Make sure
|
|
|
16 |
your class constructor calls the PHPlot class constructor before changing
|
|
|
17 |
any settings.
|
|
|
18 |
</p><pre class="programlisting"><?php
|
|
|
19 |
# Define a custom PHPlot class
|
|
|
20 |
|
|
|
21 |
// Load the PHPlot class first
|
|
|
22 |
require_once 'phplot.php';
|
|
|
23 |
|
|
|
24 |
// Define a class which extends PHPlot:
|
|
|
25 |
class my_phplot extends PHPlot {
|
|
|
26 |
function __construct($width=800, $height=600, $out=NULL, $in=NULL)
|
|
|
27 |
{
|
|
|
28 |
parent::__construct($width, $height, $out, $in);
|
|
|
29 |
$this->SetDefaultTTFont('LiberationSans-Bold'); // System dependent
|
|
|
30 |
$this->SetTitleColor('red');
|
|
|
31 |
}
|
|
|
32 |
}
|
|
|
33 |
</pre><p>
|
|
|
34 |
</p><p>
|
|
|
35 |
To use this custom PHPlot class, use <code class="literal">require_once</code> to
|
|
|
36 |
include the file containing the class definition, then create an instance
|
|
|
37 |
of the custom class.
|
|
|
38 |
</p><pre class="programlisting">$plot = new my_phplot();
|
|
|
39 |
</pre><p>
|
|
|
40 |
You can then use the <code class="literal">$plot</code> object exactly the same as
|
|
|
41 |
you might use any other PHPlot object.
|
|
|
42 |
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="conc-errors.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="part1.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="adv-serialize.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.9. Error Handling </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 4.2. PHPlot Object Serialization</td></tr></table></div></body></html>
|