This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/includes/jpgraph/docs/chunkhtml/ch31.html
2011-05-28 19:51:52 +10:00

109 lines
11 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 31. Creating original themes</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="pt07.html" title="Part VII. Theme Class"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 31. Creating original themes</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Part VII. Theme Class</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="chapter" title="Chapter 31. Creating original themes"><div class="titlepage"><div><div><h2 class="title"><a name="id2619583"></a>Chapter 31. Creating original themes</h2></div></div></div>
<p>You can create an original theme class yourself.
You can easily create new theme classes by extending the 'Theme' class and adding your own settings.
</p>
<p>Let's say that you like 'AquaTheme' but want to make some changes.
In 'AquaTheme', the y axis and y scale are not displayed. To change these settings and to display both, you can use the following. However, it can be time-consuming to add these lines to each graph individually.
</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">yaxis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">HideLine</span><span class="hl-brackets">(</span><span class="hl-reserved">false</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">yaxis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">HideTicks</span><span class="hl-brackets">(</span><span class="hl-reserved">false</span><span class="hl-code">,</span><span class="hl-reserved">false</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p>
<p>It may be easier to create a new theme based on the original but which has some different settings. Lets create 'MyAquaTheme'.
You should put the new theme class file in the 'Theme' folder, This is where all theme classes are kept.
</p>
<p>At first, create a file at Themes/MyAquaTheme.class.php.
The code for 'MyAquaTheme' class is the following.
</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-reserved">class</span><span class="hl-code"> </span><span class="hl-identifier">MyAquaTheme</span><span class="hl-code"> </span><span class="hl-reserved">extends</span><span class="hl-code"> </span><span class="hl-identifier">AquaTheme</span><span class="hl-code">
</span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">SetupGraph</span><span class="hl-brackets">(</span><span class="hl-var">$graph</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-identifier">parent</span><span class="hl-code">::</span><span class="hl-identifier">SetupGraph</span><span class="hl-brackets">(</span><span class="hl-var">$graph</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">yaxis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">HideLine</span><span class="hl-brackets">(</span><span class="hl-reserved">false</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">yaxis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">HideTicks</span><span class="hl-brackets">(</span><span class="hl-reserved">false</span><span class="hl-code">,</span><span class="hl-reserved">false</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p>
<p>When redefining a method of parent class, please call the parent method.
In this way, all settings of the parent class method are applied and you can add the original settings.
Font, x axis, y axis colors etc are all defined as class properties. The following code shows how to change these settings.
</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">__construct</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-var">$this</span><span class="hl-code">-&gt;</span><span class="hl-identifier">font_color</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">#009900</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-var">$this</span><span class="hl-code">-&gt;</span><span class="hl-identifier">background_color</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">#EEFFDD</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-var">$this</span><span class="hl-code">-&gt;</span><span class="hl-identifier">axis_color</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">#00CC00</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-var">$this</span><span class="hl-code">-&gt;</span><span class="hl-identifier">grid_color</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">#33CC33</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p>
<p>You can set four properties, $font_color, $background_color, $axs_color and $grid_color.
You can also change values individually.
</p>
<p>
</p><div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags">&lt;?php</span><span class="hl-code">
</span><span class="hl-reserved">class</span><span class="hl-code"> </span><span class="hl-identifier">MyAquaTheme</span><span class="hl-code"> </span><span class="hl-reserved">extends</span><span class="hl-code"> </span><span class="hl-identifier">AquaTheme</span><span class="hl-code">
</span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">__construct</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-var">$this</span><span class="hl-code">-&gt;</span><span class="hl-identifier">font_color</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">#009900</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-var">$this</span><span class="hl-code">-&gt;</span><span class="hl-identifier">background_color</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">#EEFFDD</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-var">$this</span><span class="hl-code">-&gt;</span><span class="hl-identifier">axis_color</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">#00CC00</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-var">$this</span><span class="hl-code">-&gt;</span><span class="hl-identifier">grid_color</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">#33CC33</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">SetupGraph</span><span class="hl-brackets">(</span><span class="hl-var">$graph</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
</span><span class="hl-identifier">parent</span><span class="hl-code">::</span><span class="hl-identifier">SetupGraph</span><span class="hl-brackets">(</span><span class="hl-var">$graph</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">yaxis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">HideLine</span><span class="hl-brackets">(</span><span class="hl-reserved">false</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$graph</span><span class="hl-code">-&gt;</span><span class="hl-identifier">yaxis</span><span class="hl-code">-&gt;</span><span class="hl-identifier">HideTicks</span><span class="hl-brackets">(</span><span class="hl-reserved">false</span><span class="hl-code">,</span><span class="hl-reserved">false</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-inlinetags">?&gt;</span></pre></td></tr></table></div><p>
</p>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="pt07.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>