240 lines
32 KiB
HTML
240 lines
32 KiB
HTML
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Using layout classes to position Windrose plots</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="ch21.html" title="Chapter 21. Windrose"></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">Using layout classes to position Windrose plots</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 21. Windrose</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="Using layout classes to position Windrose plots"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec.windrose-layout-classes"></a>Using layout classes to position Windrose plots</h2></div></div></div>
|
|||
|
|
|||
|
<p>Normally we don't want to have to calculate the absolute x and y coordinates when
|
|||
|
positioning multiple Windrose plots in graph as was done in <a class="xref" href="ch21s02.html#fig.windrose_2plots_ex1" title="Figure 21.7. Adding two windrose plots to the same graph (windrose_2plots_ex1.php)">Figure 21.7. Adding two windrose plots to the same graph <code class="uri"><a class="uri" href="example_src/windrose_2plots_ex1.html" target="_top">(<code class="filename">windrose_2plots_ex1.php</code>)</a></code> </a>. A much better concept would be to just tell
|
|||
|
the library to position three windrose plots horizontally or vertically without having
|
|||
|
to figure out the exact coordinates our self.</p>
|
|||
|
<p>This is where layout classes come in handy.</p>
|
|||
|
<p>There are two types of layouts; horizontal and vertical. To specify that two windroses
|
|||
|
should be positioned side by side (horizontal) a new horizontal layout object is created
|
|||
|
and then the two windroses plots are added as object within the horizontal layout class.
|
|||
|
Later on when the objects are about to be stroked on the graph the horizontal layout
|
|||
|
class will take all its objects and spread them out evenly along a horizontal line
|
|||
|
depending on the individual size of each windrose. The same principle applies to the
|
|||
|
vertical layout class with the obvious change in direction.</p>
|
|||
|
<p>The layout object are added to the graph in exactly the same was as odometers, by
|
|||
|
calling the <code class="code">WindroseGraph::Add()</code> method. </p>
|
|||
|
<p>The following line would create a horizontal line of three windrose plots</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
|
|||
|
18
|
|||
|
19
|
|||
|
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$graph</span><span class="hl-code"> = </span><span class="hl-identifier">WindroseGraph</span><span class="hl-brackets">(</span><span class="hl-var">$width</span><span class="hl-code">,</span><span class="hl-var">$height</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
...
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> Create three plots</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$w1</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">WindrosePlot</span><span class="hl-brackets">(</span><span class="hl-var">$data1</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w1</span><span class="hl-code">-></span><span class="hl-identifier">SetSize</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.25</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w2</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">WindrosePlot</span><span class="hl-brackets">(</span><span class="hl-var">$data2</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w2</span><span class="hl-code">-></span><span class="hl-identifier">SetSize</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.25</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w3</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">WindrosePlot</span><span class="hl-brackets">(</span><span class="hl-var">$data3</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w3</span><span class="hl-code">-></span><span class="hl-identifier">SetSize</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.25</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> Position them even horizontally</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$hor</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LayoutHor</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-var">$w1</span><span class="hl-code">, </span><span class="hl-var">$w2</span><span class="hl-code">, </span><span class="hl-var">$w3</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> add and send back to the client</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$graph</span><span class="hl-code">-></span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$hor</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$graph</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div><p>
|
|||
|
</p>
|
|||
|
<p>Since both horizontal en vertical layout can be combined it is possible to create
|
|||
|
almost any rectangular layout. For example to create a 4x4 graph first two horizontal
|
|||
|
layouts would be created and they would then be included in a vertical layout as the
|
|||
|
following principle code snippet shows.</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
|
|||
|
18
|
|||
|
19
|
|||
|
20
|
|||
|
21
|
|||
|
22
|
|||
|
23
|
|||
|
24
|
|||
|
25
|
|||
|
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$graph</span><span class="hl-code"> = </span><span class="hl-identifier">WindroseGraph</span><span class="hl-brackets">(</span><span class="hl-var">$width</span><span class="hl-code">,</span><span class="hl-var">$height</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
...
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> Create three plots</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$w1</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">WindrosePlot</span><span class="hl-brackets">(</span><span class="hl-var">$data1</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w1</span><span class="hl-code">-></span><span class="hl-identifier">SetSize</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.24</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w2</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">WindrosePlot</span><span class="hl-brackets">(</span><span class="hl-var">$data2</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w2</span><span class="hl-code">-></span><span class="hl-identifier">SetSize</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.24</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w3</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">WindrosePlot</span><span class="hl-brackets">(</span><span class="hl-var">$data3</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w3</span><span class="hl-code">-></span><span class="hl-identifier">SetSize</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.24</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w4</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">WindrosePlot</span><span class="hl-brackets">(</span><span class="hl-var">$data4</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$w4</span><span class="hl-code">-></span><span class="hl-identifier">SetSize</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.24</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> Create the two rows</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$hor1</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LayoutHor</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-var">$w1</span><span class="hl-code">, </span><span class="hl-var">$w2</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">$hor2</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LayoutHor</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-var">$w3</span><span class="hl-code">, </span><span class="hl-var">$w4</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> positioned on top of each other</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$vert</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LayoutVert</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-var">$hor1</span><span class="hl-code">, </span><span class="hl-var">$hor2</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> add and send back to the client</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$graph</span><span class="hl-code">-></span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$vert</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$graph</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div><p>
|
|||
|
</p>
|
|||
|
<p>An example of this is shown in <a class="xref" href="ch21s06.html#fig.windrose_layout_ex0" title="Figure 21.17. Using layout classes to position 4 windrose plots (windrose_layout_ex0.php)">Figure 21.17. Using layout classes to position 4 windrose plots <code class="uri"><a class="uri" href="example_src/windrose_layout_ex0.html" target="_top">(<code class="filename">windrose_layout_ex0.php</code>)</a></code> </a></p>
|
|||
|
<p>
|
|||
|
</p><div class="figure"><a name="fig.windrose_layout_ex0"></a><p class="title"><b>Figure 21.17. Using layout classes to position 4 windrose plots <code class="uri"><a class="uri" href="example_src/windrose_layout_ex0.html" target="_top">(<code class="filename">windrose_layout_ex0.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/windrose_layout_ex0.png" alt="Using layout classes to position 4 windrose plots (windrose_layout_ex0.php)"></span> </div></div><p><br class="figure-break">
|
|||
|
</p>
|
|||
|
<p>A slightly more complex example where some more formatting have been added is shown in
|
|||
|
<a class="xref" href="ch21s06.html#fig.windrose_layout_ex1" title="Figure 21.18. Using layout classes to position 5 windrose plots (windrose_layout_ex1.php)">Figure 21.18. Using layout classes to position 5 windrose plots <code class="uri"><a class="uri" href="example_src/windrose_layout_ex1.html" target="_top">(<code class="filename">windrose_layout_ex1.php</code>)</a></code> </a> where two larger plots are in the top
|
|||
|
row and three smaller plots are shown in the bottom row.</p>
|
|||
|
<p>
|
|||
|
</p><div class="example"><a name="example.windrose_layout_ex1"></a><p class="title"><b>Example 21.6. Using layout classes to position 5 windrose plots (<code class="filename">windrose_layout_ex1.php</code>) </b></p><div class="example-contents"> <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
|
|||
|
18
|
|||
|
19
|
|||
|
20
|
|||
|
21
|
|||
|
22
|
|||
|
23
|
|||
|
24
|
|||
|
25
|
|||
|
26
|
|||
|
27
|
|||
|
28
|
|||
|
29
|
|||
|
30
|
|||
|
31
|
|||
|
32
|
|||
|
33
|
|||
|
34
|
|||
|
35
|
|||
|
36
|
|||
|
37
|
|||
|
38
|
|||
|
39
|
|||
|
40
|
|||
|
41
|
|||
|
42
|
|||
|
43
|
|||
|
44
|
|||
|
45
|
|||
|
46
|
|||
|
47
|
|||
|
48
|
|||
|
49
|
|||
|
50
|
|||
|
51
|
|||
|
52
|
|||
|
53
|
|||
|
54
|
|||
|
55
|
|||
|
56
|
|||
|
57
|
|||
|
58
|
|||
|
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
|
|||
|
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/jpgraph.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/jpgraph_windrose.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> Some data for the five windrose plots</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$data</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code">
|
|||
|
</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code">
|
|||
|
</span><span class="hl-number">1</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">10</span><span class="hl-code">,</span><span class="hl-number">10</span><span class="hl-code">,</span><span class="hl-number">13</span><span class="hl-code">,</span><span class="hl-number">7</span><span class="hl-brackets">)</span><span class="hl-code">,
|
|||
|
</span><span class="hl-number">2</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">2</span><span class="hl-code">,</span><span class="hl-number">8</span><span class="hl-code">,</span><span class="hl-number">10</span><span class="hl-brackets">)</span><span class="hl-code">,
|
|||
|
</span><span class="hl-number">4</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">1</span><span class="hl-code">,</span><span class="hl-number">12</span><span class="hl-code">,</span><span class="hl-number">22</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">,
|
|||
|
</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code">
|
|||
|
</span><span class="hl-number">4</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">12</span><span class="hl-code">,</span><span class="hl-number">8</span><span class="hl-code">,</span><span class="hl-number">2</span><span class="hl-code">,</span><span class="hl-number">3</span><span class="hl-brackets">)</span><span class="hl-code">,
|
|||
|
</span><span class="hl-number">2</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">5</span><span class="hl-code">,</span><span class="hl-number">4</span><span class="hl-code">,</span><span class="hl-number">4</span><span class="hl-code">,</span><span class="hl-number">5</span><span class="hl-code">,</span><span class="hl-number">2</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">,
|
|||
|
</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code">
|
|||
|
</span><span class="hl-number">1</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">12</span><span class="hl-code">,</span><span class="hl-number">8</span><span class="hl-code">,</span><span class="hl-number">2</span><span class="hl-code">,</span><span class="hl-number">3</span><span class="hl-brackets">)</span><span class="hl-code">,
|
|||
|
</span><span class="hl-number">3</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">5</span><span class="hl-code">,</span><span class="hl-number">4</span><span class="hl-code">,</span><span class="hl-number">4</span><span class="hl-code">,</span><span class="hl-number">5</span><span class="hl-code">,</span><span class="hl-number">2</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">,
|
|||
|
</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code">
|
|||
|
</span><span class="hl-number">2</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">12</span><span class="hl-code">,</span><span class="hl-number">8</span><span class="hl-code">,</span><span class="hl-number">2</span><span class="hl-code">,</span><span class="hl-number">3</span><span class="hl-brackets">)</span><span class="hl-code">,
|
|||
|
</span><span class="hl-number">3</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">5</span><span class="hl-code">,</span><span class="hl-number">4</span><span class="hl-code">,</span><span class="hl-number">4</span><span class="hl-code">,</span><span class="hl-number">5</span><span class="hl-code">,</span><span class="hl-number">2</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">,
|
|||
|
</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code">
|
|||
|
</span><span class="hl-number">4</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">12</span><span class="hl-code">,</span><span class="hl-number">8</span><span class="hl-code">,</span><span class="hl-number">2</span><span class="hl-code">,</span><span class="hl-number">3</span><span class="hl-brackets">)</span><span class="hl-code">,
|
|||
|
</span><span class="hl-number">6</span><span class="hl-code"> => </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">5</span><span class="hl-code">,</span><span class="hl-number">4</span><span class="hl-code">,</span><span class="hl-number">4</span><span class="hl-code">,</span><span class="hl-number">5</span><span class="hl-code">,</span><span class="hl-number">2</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-comment">//</span><span class="hl-comment"> Legend range colors</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$rangecolors</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">green</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">yellow</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">red</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">brown</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a windrose graph with titles</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$graph</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">WindroseGraph</span><span class="hl-brackets">(</span><span class="hl-number">750</span><span class="hl-code">,</span><span class="hl-number">700</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
</span><span class="hl-var">$graph</span><span class="hl-code">-></span><span class="hl-identifier">title</span><span class="hl-code">-></span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Multiple plots with automatic layout</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$graph</span><span class="hl-code">-></span><span class="hl-identifier">title</span><span class="hl-code">-></span><span class="hl-identifier">SetFont</span><span class="hl-brackets">(</span><span class="hl-identifier">FF_ARIAL</span><span class="hl-code">,</span><span class="hl-identifier">FS_BOLD</span><span class="hl-code">,</span><span class="hl-number">14</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> Setup the individual windrose plots</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$wp</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-reserved">for</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$i</span><span class="hl-code">=</span><span class="hl-number">0</span><span class="hl-code">; </span><span class="hl-var">$i</span><span class="hl-code"> < </span><span class="hl-number">5</span><span class="hl-code">; ++</span><span class="hl-var">$i</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-var">$wp</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">WindrosePlot</span><span class="hl-brackets">(</span><span class="hl-var">$data</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$wp</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code">-></span><span class="hl-identifier">SetType</span><span class="hl-brackets">(</span><span class="hl-identifier">WINDROSE_TYPE8</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-reserved">if</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$i</span><span class="hl-code"> < </span><span class="hl-number">2</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">$wp</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code">-></span><span class="hl-identifier">SetSize</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.28</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-brackets">}</span><span class="hl-code">
|
|||
|
</span><span class="hl-reserved">else</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$wp</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code">-></span><span class="hl-identifier">legend</span><span class="hl-code">-></span><span class="hl-identifier">Hide</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$wp</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code">-></span><span class="hl-identifier">SetSize</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.16</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$wp</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code">-></span><span class="hl-identifier">SetCenterSize</span><span class="hl-brackets">(</span><span class="hl-number">0</span><span class="hl-number">.25</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">$wp</span><span class="hl-brackets">[</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code">-></span><span class="hl-identifier">SetRangeColors</span><span class="hl-brackets">(</span><span class="hl-var">$rangecolors</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-brackets">}</span><span class="hl-code">
|
|||
|
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> Position with two rows. Two plots in top row and three plots in</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-comment">//</span><span class="hl-comment"> bottom row.</span><span class="hl-comment"></span><span class="hl-code">
|
|||
|
</span><span class="hl-var">$hl1</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LayoutHor</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$wp</span><span class="hl-brackets">[</span><span class="hl-number">0</span><span class="hl-brackets">]</span><span class="hl-code">, </span><span class="hl-var">$wp</span><span class="hl-brackets">[</span><span class="hl-number">1</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-var">$hl2</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LayoutHor</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$wp</span><span class="hl-brackets">[</span><span class="hl-number">2</span><span class="hl-brackets">]</span><span class="hl-code">, </span><span class="hl-var">$wp</span><span class="hl-brackets">[</span><span class="hl-number">3</span><span class="hl-brackets">]</span><span class="hl-code">, </span><span class="hl-var">$wp</span><span class="hl-brackets">[</span><span class="hl-number">4</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-var">$vl</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">LayoutVert</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$hl1</span><span class="hl-code">, </span><span class="hl-var">$hl2</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">$graph</span><span class="hl-code">-></span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$vl</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-var">$graph</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
|
|||
|
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div></div></div><p><br class="example-break"> </p><div class="figure"><a name="fig.windrose_layout_ex1"></a><p class="title"><b>Figure 21.18. Using layout classes to position 5 windrose plots <code class="uri"><a class="uri" href="example_src/windrose_layout_ex1.html" target="_top">(<code class="filename">windrose_layout_ex1.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/windrose_layout_ex1.png" alt="Using layout classes to position 5 windrose plots (windrose_layout_ex1.php)"></span> </div></div><p><br class="figure-break">
|
|||
|
</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="ch21.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>
|