525 lines
66 KiB
HTML
525 lines
66 KiB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>The implementation of class CCBPGraph</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="ch35.html" title="Chapter 35. Creating Critical chain buffer penetration charts"></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">The implementation of <code class="code">class CCBPGraph</code></th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 35. Creating Critical chain buffer penetration charts</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="The implementation of class CCBPGraph"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2622295"></a>The implementation of <code class="code">class CCBPGraph</code></h2></div></div></div>
|
||
|
||
<p>The entire implementation is included below and is also available en the
|
||
"<code class="filename">Example/</code>" directory of the distribution as
|
||
"<code class="filename">ccbpgraph.class.php</code>". There are also two example scripts
|
||
using this utility class "<code class="filename">ccbp_ex1.php</code>" and
|
||
"<code class="filename">ccbp_ex2.php</code>"</p>
|
||
<p>
|
||
</p><div class="example"><a name="example.ccbpgraph.class"></a><p class="title"><b>Example 35.2. (<code class="filename">ccbpgraph.class.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
|
||
59
|
||
60
|
||
61
|
||
62
|
||
63
|
||
64
|
||
65
|
||
66
|
||
67
|
||
68
|
||
69
|
||
70
|
||
71
|
||
72
|
||
73
|
||
74
|
||
75
|
||
76
|
||
77
|
||
78
|
||
79
|
||
80
|
||
81
|
||
82
|
||
83
|
||
84
|
||
85
|
||
86
|
||
87
|
||
88
|
||
89
|
||
90
|
||
91
|
||
92
|
||
93
|
||
94
|
||
95
|
||
96
|
||
97
|
||
98
|
||
99
|
||
100
|
||
101
|
||
102
|
||
103
|
||
104
|
||
105
|
||
106
|
||
107
|
||
108
|
||
109
|
||
110
|
||
111
|
||
112
|
||
113
|
||
114
|
||
115
|
||
116
|
||
117
|
||
118
|
||
119
|
||
120
|
||
121
|
||
122
|
||
123
|
||
124
|
||
125
|
||
126
|
||
127
|
||
128
|
||
129
|
||
130
|
||
131
|
||
132
|
||
133
|
||
134
|
||
135
|
||
136
|
||
137
|
||
138
|
||
139
|
||
140
|
||
141
|
||
142
|
||
143
|
||
144
|
||
145
|
||
146
|
||
147
|
||
148
|
||
149
|
||
150
|
||
151
|
||
152
|
||
153
|
||
154
|
||
155
|
||
156
|
||
157
|
||
158
|
||
159
|
||
160
|
||
161
|
||
162
|
||
163
|
||
164
|
||
165
|
||
166
|
||
167
|
||
168
|
||
169
|
||
170
|
||
171
|
||
172
|
||
173
|
||
174
|
||
175
|
||
176
|
||
177
|
||
178
|
||
179
|
||
180
|
||
181
|
||
182
|
||
183
|
||
184
|
||
185
|
||
186
|
||
187
|
||
188
|
||
189
|
||
190
|
||
191
|
||
192
|
||
193
|
||
194
|
||
195
|
||
196
|
||
197
|
||
198
|
||
199
|
||
200
|
||
201
|
||
202
|
||
203
|
||
204
|
||
205
|
||
206
|
||
207
|
||
208
|
||
209
|
||
210
|
||
211
|
||
212
|
||
213
|
||
214
|
||
215
|
||
216
|
||
217
|
||
218
|
||
219
|
||
220
|
||
221
|
||
222
|
||
223
|
||
224
|
||
225
|
||
226
|
||
227
|
||
228
|
||
229
|
||
230
|
||
231
|
||
232
|
||
233
|
||
234
|
||
235
|
||
236
|
||
237
|
||
238
|
||
239
|
||
240
|
||
241
|
||
242
|
||
243
|
||
244
|
||
245
|
||
246
|
||
247
|
||
248
|
||
249
|
||
250
|
||
251
|
||
252
|
||
253
|
||
254
|
||
255
|
||
256
|
||
257
|
||
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code"> </span><span class="hl-comment">//</span><span class="hl-comment"> content="text/plain; charset=utf-8" </span><span class="hl-comment"></span><span class="hl-code">
|
||
</span><span class="hl-comment">/*</span><span class="hl-comment">*
|
||
* Class CCBPGraph
|
||
* Utility class to create Critical Chain Buffer penetration charts
|
||
</span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">class</span><span class="hl-code"> </span><span class="hl-identifier">CCBPGraph</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
|
||
</span><span class="hl-reserved">const</span><span class="hl-code"> </span><span class="hl-identifier">TickStep</span><span class="hl-code"> = </span><span class="hl-number">25</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">const</span><span class="hl-code"> </span><span class="hl-identifier">YTitle</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">% Buffer used</span><span class="hl-quotes">'</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">const</span><span class="hl-code"> </span><span class="hl-identifier">XTitle</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">% CC Completed</span><span class="hl-quotes">'</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">const</span><span class="hl-code"> </span><span class="hl-identifier">NColorMaps</span><span class="hl-code"> = </span><span class="hl-number">2</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">private</span><span class="hl-code"> </span><span class="hl-var">$graph</span><span class="hl-code">=</span><span class="hl-reserved">null</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">private</span><span class="hl-code"> </span><span class="hl-var">$iWidth</span><span class="hl-code">,</span><span class="hl-var">$iHeight</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">private</span><span class="hl-code"> </span><span class="hl-var">$iPlots</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">private</span><span class="hl-code"> </span><span class="hl-var">$iXMin</span><span class="hl-code">=-</span><span class="hl-number">50</span><span class="hl-code">, </span><span class="hl-var">$iXMax</span><span class="hl-code"> = </span><span class="hl-number">100</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">private</span><span class="hl-code"> </span><span class="hl-var">$iYMin</span><span class="hl-code">=-</span><span class="hl-number">50</span><span class="hl-code">, </span><span class="hl-var">$iYMax</span><span class="hl-code"> = </span><span class="hl-number">150</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">private</span><span class="hl-code"> </span><span class="hl-var">$iColorInd</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-number">5</span><span class="hl-code">,</span><span class="hl-number">75</span><span class="hl-brackets">)</span><span class="hl-code">, </span><span class="hl-comment">/*</span><span class="hl-comment"> Green </span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">25</span><span class="hl-code">,</span><span class="hl-number">85</span><span class="hl-brackets">)</span><span class="hl-code">, </span><span class="hl-comment">/*</span><span class="hl-comment"> Yellow </span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-number">50</span><span class="hl-code">,</span><span class="hl-number">100</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">;</span><span class="hl-comment">/*</span><span class="hl-comment"> Red </span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">private</span><span class="hl-code"> </span><span class="hl-var">$iColorMap</span><span class="hl-code"> = </span><span class="hl-number">0</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">private</span><span class="hl-code"> </span><span class="hl-var">$iColorSpec</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-quotes">'</span><span class="hl-string">darkgreen:1.0</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">yellow:1.4</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">red:0.8</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">darkred:0.85</span><span class="hl-quotes">'</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-quotes">'</span><span class="hl-string">#c6e9af</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">#ffeeaa</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">#ffaaaa</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">#de8787</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">private</span><span class="hl-code"> </span><span class="hl-var">$iMarginColor</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">darkgreen@0.7</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">darkgreen@0.9</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
|
||
</span><span class="hl-reserved">private</span><span class="hl-code"> </span><span class="hl-var">$iSubTitle</span><span class="hl-code">=</span><span class="hl-quotes">'</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-var">$iTitle</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">CC Buffer penetration</span><span class="hl-quotes">'</span><span class="hl-code">;
|
||
</span><span class="hl-comment">/*</span><span class="hl-comment">*
|
||
* Construct a new instance of CCBPGraph
|
||
*
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">int $aWidth
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">int $aHeight
|
||
*</span><span class="hl-inlinedoc"> @return </span><span class="hl-comment">CCBPGraph
|
||
</span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">public</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-var">$aWidth</span><span class="hl-code">, </span><span class="hl-var">$aHeight</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">-></span><span class="hl-identifier">iWidth</span><span class="hl-code"> = </span><span class="hl-var">$aWidth</span><span class="hl-code">;
|
||
</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iHeight</span><span class="hl-code"> = </span><span class="hl-var">$aHeight</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">*
|
||
* Set the title and subtitle for the graph
|
||
*
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">string $aTitle
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">string $aSubTitle
|
||
</span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">public</span><span class="hl-code"> </span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">SetTitle</span><span class="hl-brackets">(</span><span class="hl-var">$aTitle</span><span class="hl-code">, </span><span class="hl-var">$aSubTitle</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">-></span><span class="hl-identifier">iTitle</span><span class="hl-code"> = </span><span class="hl-var">$aTitle</span><span class="hl-code">;
|
||
</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iSubTitle</span><span class="hl-code"> = </span><span class="hl-var">$aSubTitle</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">*
|
||
* Set the x-axis min and max values
|
||
*
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">int $aMin
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">int $aMax
|
||
</span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">public</span><span class="hl-code"> </span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">SetXMinMax</span><span class="hl-brackets">(</span><span class="hl-var">$aMin</span><span class="hl-code">, </span><span class="hl-var">$aMax</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">-></span><span class="hl-identifier">iXMin</span><span class="hl-code"> = </span><span class="hl-identifier">floor</span><span class="hl-brackets">(</span><span class="hl-var">$aMin</span><span class="hl-code">/</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</span><span class="hl-brackets">)</span><span class="hl-code">*</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</span><span class="hl-code">;
|
||
</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iXMax</span><span class="hl-code"> = </span><span class="hl-identifier">ceil</span><span class="hl-brackets">(</span><span class="hl-var">$aMax</span><span class="hl-code">/</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</span><span class="hl-brackets">)</span><span class="hl-code">*</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</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">*
|
||
* Specify what color map to use
|
||
*
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">int $aMap
|
||
</span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">public</span><span class="hl-code"> </span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">SetColorMap</span><span class="hl-brackets">(</span><span class="hl-var">$aMap</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">-></span><span class="hl-identifier">iColorMap</span><span class="hl-code"> = </span><span class="hl-var">$aMap</span><span class="hl-code"> % </span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">NColorMaps</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">*
|
||
* Set the y-axis min and max values
|
||
*
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">int $aMin
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">int $aMax
|
||
</span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">public</span><span class="hl-code"> </span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">SetYMinMax</span><span class="hl-brackets">(</span><span class="hl-var">$aMin</span><span class="hl-code">,</span><span class="hl-var">$aMax</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">-></span><span class="hl-identifier">iYMin</span><span class="hl-code"> = </span><span class="hl-identifier">floor</span><span class="hl-brackets">(</span><span class="hl-var">$aMin</span><span class="hl-code">/</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</span><span class="hl-brackets">)</span><span class="hl-code">*</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</span><span class="hl-code">;
|
||
</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iYMax</span><span class="hl-code"> = </span><span class="hl-identifier">ceil</span><span class="hl-brackets">(</span><span class="hl-var">$aMax</span><span class="hl-code">/</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</span><span class="hl-brackets">)</span><span class="hl-code">*</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</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">*
|
||
* Set the specification of the color backgrounds and also the
|
||
* optional exact colors to be used
|
||
*
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">mixed $aSpec An array of 3 1x2 arrays. Each array specify the
|
||
* color indication value at x=0 and x=max x in order to determine the slope
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">mixed $aColors An array with four elements specifying the colors
|
||
* of each color indicator
|
||
</span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">public</span><span class="hl-code"> </span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">SetColorIndication</span><span class="hl-brackets">(</span><span class="hl-reserved">array</span><span class="hl-code"> </span><span class="hl-var">$aSpec</span><span class="hl-code">,</span><span class="hl-reserved">array</span><span class="hl-code"> </span><span class="hl-var">$aColors</span><span class="hl-code">=</span><span class="hl-reserved">null</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">if</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">count</span><span class="hl-brackets">(</span><span class="hl-var">$aSpec</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-brackets">)</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
|
||
</span><span class="hl-identifier">JpgraphError</span><span class="hl-code">::</span><span class="hl-identifier">Raise</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Specification of scale values for background indicators must be an array with three elements.</span><span class="hl-quotes">'</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">-></span><span class="hl-identifier">iColorInd</span><span class="hl-code"> = </span><span class="hl-var">$aSpec</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">$aColors</span><span class="hl-code"> !== </span><span class="hl-reserved">null</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-reserved">if</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">is_array</span><span class="hl-brackets">(</span><span class="hl-var">$aColors</span><span class="hl-brackets">)</span><span class="hl-code"> && </span><span class="hl-identifier">count</span><span class="hl-brackets">(</span><span class="hl-var">$aColors</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-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">-></span><span class="hl-identifier">iColorSpec</span><span class="hl-code"> = </span><span class="hl-var">$aColors</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-identifier">JpGraphError</span><span class="hl-code">::</span><span class="hl-identifier">Raise</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">Color specification for background indication must have four colors.</span><span class="hl-quotes">'</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-brackets">}</span><span class="hl-code">
|
||
</span><span class="hl-comment">/*</span><span class="hl-comment">*
|
||
* Construct the graph
|
||
*
|
||
</span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">private</span><span class="hl-code"> </span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">Init</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"> Setup limits for color indications</span><span class="hl-comment"></span><span class="hl-code">
|
||
</span><span class="hl-var">$lowx</span><span class="hl-code"> = </span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iXMin</span><span class="hl-code">; </span><span class="hl-var">$highx</span><span class="hl-code">= </span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iXMax</span><span class="hl-code">;
|
||
</span><span class="hl-var">$lowy</span><span class="hl-code"> = </span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iYMin</span><span class="hl-code">; </span><span class="hl-var">$highy</span><span class="hl-code"> = </span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iYMax</span><span class="hl-code">;
|
||
</span><span class="hl-var">$width</span><span class="hl-code">=</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iWidth</span><span class="hl-code">; </span><span class="hl-var">$height</span><span class="hl-code">=</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iHeight</span><span class="hl-code">;
|
||
|
||
</span><span class="hl-comment">//</span><span class="hl-comment"> Margins</span><span class="hl-comment"></span><span class="hl-code">
|
||
</span><span class="hl-var">$lm</span><span class="hl-code">=</span><span class="hl-number">50</span><span class="hl-code">; </span><span class="hl-var">$rm</span><span class="hl-code">=</span><span class="hl-number">40</span><span class="hl-code">;
|
||
</span><span class="hl-var">$tm</span><span class="hl-code">=</span><span class="hl-number">60</span><span class="hl-code">; </span><span class="hl-var">$bm</span><span class="hl-code">=</span><span class="hl-number">40</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">$width</span><span class="hl-code"> <= </span><span class="hl-number">300</span><span class="hl-code"> || </span><span class="hl-var">$height</span><span class="hl-code"> <= </span><span class="hl-number">250</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">$labelsize</span><span class="hl-code"> = </span><span class="hl-number">8</span><span class="hl-code">;
|
||
</span><span class="hl-var">$lm</span><span class="hl-code">=</span><span class="hl-number">25</span><span class="hl-code">; </span><span class="hl-var">$rm</span><span class="hl-code">=</span><span class="hl-number">25</span><span class="hl-code">;
|
||
</span><span class="hl-var">$tm</span><span class="hl-code">=</span><span class="hl-number">45</span><span class="hl-code">; </span><span class="hl-var">$bm</span><span class="hl-code">=</span><span class="hl-number">25</span><span class="hl-code">;
|
||
</span><span class="hl-brackets">}</span><span class="hl-code">
|
||
</span><span class="hl-reserved">elseif</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$width</span><span class="hl-code"> <= </span><span class="hl-number">450</span><span class="hl-code"> || </span><span class="hl-var">$height</span><span class="hl-code"> <= </span><span class="hl-number">300</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">$labelsize</span><span class="hl-code"> = </span><span class="hl-number">8</span><span class="hl-code">;
|
||
</span><span class="hl-var">$lm</span><span class="hl-code">=</span><span class="hl-number">30</span><span class="hl-code">; </span><span class="hl-var">$rm</span><span class="hl-code">=</span><span class="hl-number">30</span><span class="hl-code">;
|
||
</span><span class="hl-var">$tm</span><span class="hl-code">=</span><span class="hl-number">50</span><span class="hl-code">; </span><span class="hl-var">$bm</span><span class="hl-code">=</span><span class="hl-number">30</span><span class="hl-code">;
|
||
</span><span class="hl-brackets">}</span><span class="hl-code">
|
||
</span><span class="hl-reserved">elseif</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-var">$width</span><span class="hl-code"> <= </span><span class="hl-number">600</span><span class="hl-code"> || </span><span class="hl-var">$height</span><span class="hl-code"> <= </span><span class="hl-number">400</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">$labelsize</span><span class="hl-code"> = </span><span class="hl-number">9</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">$labelsize</span><span class="hl-code"> = </span><span class="hl-number">11</span><span class="hl-code">;
|
||
</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">$this</span><span class="hl-code">-></span><span class="hl-identifier">iSubTitle</span><span class="hl-code"> == </span><span class="hl-quotes">'</span><span class="hl-quotes">'</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">$tm</span><span class="hl-code"> -= </span><span class="hl-var">$labelsize</span><span class="hl-code">+</span><span class="hl-number">4</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-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Graph</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-var">$graph</span><span class="hl-code">-></span><span class="hl-identifier">SetScale</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">intint</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-var">$lowy</span><span class="hl-code">,</span><span class="hl-var">$highy</span><span class="hl-code">,</span><span class="hl-var">$lowx</span><span class="hl-code">,</span><span class="hl-var">$highx</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">SetMargin</span><span class="hl-brackets">(</span><span class="hl-var">$lm</span><span class="hl-code">,</span><span class="hl-var">$rm</span><span class="hl-code">,</span><span class="hl-var">$tm</span><span class="hl-code">,</span><span class="hl-var">$bm</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">SetMarginColor</span><span class="hl-brackets">(</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iMarginColor</span><span class="hl-brackets">[</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iColorMap</span><span class="hl-brackets">]</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">SetClipping</span><span class="hl-brackets">(</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-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iTitle</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">subtitle</span><span class="hl-code">-></span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iSubTitle</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-var">$labelsize</span><span class="hl-code">+</span><span class="hl-number">4</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">subtitle</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-var">$labelsize</span><span class="hl-code">+</span><span class="hl-number">1</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">SetBox</span><span class="hl-brackets">(</span><span class="hl-reserved">true</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">black@0.3</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">xaxis</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-var">$labelsize</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">yaxis</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-var">$labelsize</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">xaxis</span><span class="hl-code">-></span><span class="hl-identifier">scale</span><span class="hl-code">-></span><span class="hl-identifier">ticks</span><span class="hl-code">-></span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</span><span class="hl-code">,</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</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">yaxis</span><span class="hl-code">-></span><span class="hl-identifier">scale</span><span class="hl-code">-></span><span class="hl-identifier">ticks</span><span class="hl-code">-></span><span class="hl-identifier">Set</span><span class="hl-brackets">(</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</span><span class="hl-code">,</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">TickStep</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">xaxis</span><span class="hl-code">-></span><span class="hl-identifier">HideZeroLabel</span><span class="hl-brackets">(</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">yaxis</span><span class="hl-code">-></span><span class="hl-identifier">HideZeroLabel</span><span class="hl-brackets">(</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">xaxis</span><span class="hl-code">-></span><span class="hl-identifier">SetLabelFormatString</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">%d%%</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">yaxis</span><span class="hl-code">-></span><span class="hl-identifier">SetLabelFormatString</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">%d%%</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"> For the x-axis we adjust the color so labels on the left of the Y-axis are in black</span><span class="hl-comment"></span><span class="hl-code">
|
||
</span><span class="hl-var">$n1</span><span class="hl-code"> = </span><span class="hl-identifier">floor</span><span class="hl-brackets">(</span><span class="hl-identifier">abs</span><span class="hl-brackets">(</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iXMin</span><span class="hl-code">/</span><span class="hl-number">25</span><span class="hl-brackets">)</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-var">$n2</span><span class="hl-code"> = </span><span class="hl-identifier">floor</span><span class="hl-brackets">(</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iXMax</span><span class="hl-code">/</span><span class="hl-number">25</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">$this</span><span class="hl-code">-></span><span class="hl-identifier">iColorMap</span><span class="hl-code"> == </span><span class="hl-number">0</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">$xlcolors</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-var">$n1</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">$xlcolors</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-quotes">'</span><span class="hl-string">black</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">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-var">$n2</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">$xlcolors</span><span class="hl-brackets">[</span><span class="hl-var">$n1</span><span class="hl-code">+</span><span class="hl-var">$i</span><span class="hl-brackets">]</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">lightgray:1.5</span><span class="hl-quotes">'</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">xaxis</span><span class="hl-code">-></span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">gray</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-var">$xlcolors</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">yaxis</span><span class="hl-code">-></span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">gray</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">lightgray:1.5</span><span class="hl-quotes">'</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">$graph</span><span class="hl-code">-></span><span class="hl-identifier">xaxis</span><span class="hl-code">-></span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">darkgray</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">darkgray:0.8</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">yaxis</span><span class="hl-code">-></span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">darkgray</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">darkgray:0.8</span><span class="hl-quotes">'</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">SetGridDepth</span><span class="hl-brackets">(</span><span class="hl-identifier">DEPTH_FRONT</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">ygrid</span><span class="hl-code">-></span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">gray@0.6</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">ygrid</span><span class="hl-code">-></span><span class="hl-identifier">SetLineStyle</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">dotted</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">ygrid</span><span class="hl-code">-></span><span class="hl-identifier">Show</span><span class="hl-brackets">(</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">xaxis</span><span class="hl-code">-></span><span class="hl-identifier">SetWeight</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-var">$graph</span><span class="hl-code">-></span><span class="hl-identifier">yaxis</span><span class="hl-code">-></span><span class="hl-identifier">SetWeight</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-var">$ytitle</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Text</span><span class="hl-brackets">(</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">YTitle</span><span class="hl-code">,</span><span class="hl-identifier">floor</span><span class="hl-brackets">(</span><span class="hl-var">$lm</span><span class="hl-code">*</span><span class="hl-number">.75</span><span class="hl-brackets">)</span><span class="hl-code">,</span><span class="hl-brackets">(</span><span class="hl-var">$height</span><span class="hl-code">-</span><span class="hl-var">$tm</span><span class="hl-code">-</span><span class="hl-var">$bm</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-var">$tm</span><span class="hl-brackets">)</span><span class="hl-code">;
|
||
</span><span class="hl-comment">#</span><span class="hl-comment">$ytitle->SetFont(FF_VERA,FS_BOLD,$labelsize+1);</span><span class="hl-comment"></span><span class="hl-code">
|
||
</span><span class="hl-var">$ytitle</span><span class="hl-code">-></span><span class="hl-identifier">SetAlign</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">right</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">center</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
|
||
</span><span class="hl-var">$ytitle</span><span class="hl-code">-></span><span class="hl-identifier">SetAngle</span><span class="hl-brackets">(</span><span class="hl-number">90</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">$ytitle</span><span class="hl-brackets">)</span><span class="hl-code">;
|
||
|
||
</span><span class="hl-var">$xtitle</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Text</span><span class="hl-brackets">(</span><span class="hl-identifier">CCBPGraph</span><span class="hl-code">::</span><span class="hl-identifier">XTitle</span><span class="hl-code">,</span><span class="hl-brackets">(</span><span class="hl-var">$width</span><span class="hl-code">-</span><span class="hl-var">$lm</span><span class="hl-code">-</span><span class="hl-var">$rm</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-var">$lm</span><span class="hl-code">,</span><span class="hl-var">$height</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-comment">#</span><span class="hl-comment">$xtitle->SetFont(FF_VERA,FS_BOLD,$labelsize);</span><span class="hl-comment"></span><span class="hl-code">
|
||
</span><span class="hl-var">$xtitle</span><span class="hl-code">-></span><span class="hl-identifier">SetAlign</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">center</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">bottom</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">Add</span><span class="hl-brackets">(</span><span class="hl-var">$xtitle</span><span class="hl-brackets">)</span><span class="hl-code">;
|
||
|
||
</span><span class="hl-var">$df</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">D j:S M, Y</span><span class="hl-quotes">'</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">$width</span><span class="hl-code"> < </span><span class="hl-number">400</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">$df</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">D j:S M</span><span class="hl-quotes">'</span><span class="hl-code">;
|
||
</span><span class="hl-brackets">}</span><span class="hl-code">
|
||
|
||
</span><span class="hl-var">$time</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">Text</span><span class="hl-brackets">(</span><span class="hl-identifier">date</span><span class="hl-brackets">(</span><span class="hl-var">$df</span><span class="hl-brackets">)</span><span class="hl-code">,</span><span class="hl-var">$width</span><span class="hl-code">-</span><span class="hl-number">10</span><span class="hl-code">,</span><span class="hl-var">$height</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-var">$time</span><span class="hl-code">-></span><span class="hl-identifier">SetAlign</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">right</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">bottom</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">$time->SetFont(FF_VERA,FS_NORMAL,$labelsize-1);</span><span class="hl-comment"></span><span class="hl-code">
|
||
</span><span class="hl-var">$time</span><span class="hl-code">-></span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">darkgray</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">Add</span><span class="hl-brackets">(</span><span class="hl-var">$time</span><span class="hl-brackets">)</span><span class="hl-code">;
|
||
|
||
</span><span class="hl-comment">//</span><span class="hl-comment"> Use an accumulated fille line graph to create the colored bands</span><span class="hl-comment"></span><span class="hl-code">
|
||
|
||
</span><span class="hl-var">$n</span><span class="hl-code"> = </span><span class="hl-number">3</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-var">$n</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">$b</span><span class="hl-code"> = </span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iColorInd</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-number">0</span><span class="hl-brackets">]</span><span class="hl-code">;
|
||
</span><span class="hl-var">$k</span><span class="hl-code"> = </span><span class="hl-brackets">(</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iColorInd</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-number">1</span><span class="hl-brackets">]</span><span class="hl-code"> - </span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iColorInd</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-number">0</span><span class="hl-brackets">]</span><span class="hl-brackets">)</span><span class="hl-code">/</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iXMax</span><span class="hl-code">;
|
||
</span><span class="hl-var">$colarea</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">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-var">$lowx</span><span class="hl-code">,</span><span class="hl-var">$lowx</span><span class="hl-code">*</span><span class="hl-var">$k</span><span class="hl-code">+</span><span class="hl-var">$b</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">$highx</span><span class="hl-code">,</span><span class="hl-var">$highx</span><span class="hl-code">*</span><span class="hl-var">$k</span><span class="hl-code">+</span><span class="hl-var">$b</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">$colarea</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-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-var">$lowx</span><span class="hl-code">,</span><span class="hl-var">$highy</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">$highx</span><span class="hl-code">,</span><span class="hl-var">$highy</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">$cb</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">4</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">$cb</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">LinePlot</span><span class="hl-brackets">(</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-var">$colarea</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-number">0</span><span class="hl-brackets">]</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-var">$colarea</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-number">1</span><span class="hl-brackets">]</span><span class="hl-brackets">[</span><span class="hl-number">1</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-var">$colarea</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-number">0</span><span class="hl-brackets">]</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">$colarea</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-number">1</span><span class="hl-brackets">]</span><span class="hl-brackets">[</span><span class="hl-number">0</span><span class="hl-brackets">]</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">;
|
||
</span><span class="hl-var">$cb</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">SetFillColor</span><span class="hl-brackets">(</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iColorSpec</span><span class="hl-brackets">[</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iColorMap</span><span class="hl-brackets">]</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">$cb</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">SetFillFromYMin</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">$graph</span><span class="hl-code">-></span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-identifier">array_slice</span><span class="hl-brackets">(</span><span class="hl-identifier">array_reverse</span><span class="hl-brackets">(</span><span class="hl-var">$cb</span><span class="hl-brackets">)</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-code">,</span><span class="hl-number">4</span><span class="hl-brackets">)</span><span class="hl-brackets">)</span><span class="hl-code">;
|
||
</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">graph</span><span class="hl-code"> = </span><span class="hl-var">$graph</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 a line or scatter plot to the graph
|
||
*
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">mixed $aPlots
|
||
</span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">public</span><span class="hl-code"> </span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$aPlots</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">if</span><span class="hl-brackets">(</span><span class="hl-code"> </span><span class="hl-identifier">is_array</span><span class="hl-brackets">(</span><span class="hl-var">$aPlots</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">$this</span><span class="hl-code">-></span><span class="hl-identifier">iPlots</span><span class="hl-code"> = </span><span class="hl-identifier">array_merge</span><span class="hl-brackets">(</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iPlots</span><span class="hl-code">,</span><span class="hl-var">$aPlots</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">$this</span><span class="hl-code">-></span><span class="hl-identifier">iPlots</span><span class="hl-brackets">[</span><span class="hl-brackets">]</span><span class="hl-code"> = </span><span class="hl-var">$aPlots</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-comment">/*</span><span class="hl-comment">*
|
||
* Stroke the graph back to the client or to a file
|
||
*
|
||
*</span><span class="hl-inlinedoc"> @param </span><span class="hl-comment">mixed $aFile
|
||
</span><span class="hl-comment">*/</span><span class="hl-code">
|
||
</span><span class="hl-reserved">public</span><span class="hl-code"> </span><span class="hl-reserved">function</span><span class="hl-code"> </span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$aFile</span><span class="hl-code">=</span><span class="hl-quotes">'</span><span class="hl-quotes">'</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">-></span><span class="hl-identifier">Init</span><span class="hl-brackets">(</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-identifier">count</span><span class="hl-brackets">(</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iPlots</span><span class="hl-brackets">)</span><span class="hl-code"> > </span><span class="hl-number">0</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">$this</span><span class="hl-code">-></span><span class="hl-identifier">graph</span><span class="hl-code">-></span><span class="hl-identifier">Add</span><span class="hl-brackets">(</span><span class="hl-var">$this</span><span class="hl-code">-></span><span class="hl-identifier">iPlots</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">-></span><span class="hl-identifier">graph</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$aFile</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">?></span></pre></td></tr></table></div></div></div><p><br class="example-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="ch35.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>
|