1
|
|
|
<?php |
2
|
|
|
namespace Amenadiel\JpGraph\Plot; |
3
|
|
|
|
4
|
|
|
//=================================================== |
5
|
|
|
// CLASS AccBarPlot |
6
|
|
|
// Description: Produce accumulated bar plots |
7
|
|
|
//=================================================== |
8
|
|
|
class AccBarPlot extends BarPlot |
9
|
|
|
{ |
10
|
|
|
public $plots = null; |
11
|
|
|
private $nbrplots = 0; |
12
|
|
|
//--------------- |
13
|
|
|
// CONSTRUCTOR |
14
|
|
|
public function __construct($plots) |
15
|
|
|
{ |
16
|
|
|
$this->plots = $plots; |
17
|
|
|
$this->nbrplots = count($plots); |
18
|
|
|
if ($this->nbrplots < 1) { |
19
|
|
|
Util\JpGraphError::RaiseL(2010); //('Cannot create AccBarPlot from empty plot array.'); |
20
|
|
|
} |
21
|
|
View Code Duplication |
for ($i = 0; $i < $this->nbrplots; ++$i) { |
|
|
|
|
22
|
|
|
if (empty($this->plots[$i]) || !isset($this->plots[$i])) { |
23
|
|
|
Util\JpGraphError::RaiseL(2011, $i); //("Acc bar plot element nbr $i is undefined or empty."); |
24
|
|
|
} |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
// We can only allow individual plost which do not have specified X-positions |
28
|
|
View Code Duplication |
for ($i = 0; $i < $this->nbrplots; ++$i) { |
|
|
|
|
29
|
|
|
if (!empty($this->plots[$i]->coords[1])) { |
30
|
|
|
Util\JpGraphError::RaiseL(2015); |
31
|
|
|
//'Individual bar plots in an AccBarPlot or GroupBarPlot can not have specified X-positions.'); |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
// Use 0 weight by default which means that the individual bar |
36
|
|
|
// weights will be used per part n the accumulated bar |
37
|
|
|
$this->SetWeight(0); |
38
|
|
|
|
39
|
|
|
$this->numpoints = $plots[0]->numpoints; |
40
|
|
|
$this->value = new DisplayValue(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
//--------------- |
44
|
|
|
// PUBLIC METHODS |
45
|
|
View Code Duplication |
public function Legend($graph) |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
$n = count($this->plots); |
48
|
|
|
for ($i = $n - 1; $i >= 0; --$i) { |
49
|
|
|
$c = get_class($this->plots[$i]); |
50
|
|
|
if (!($this->plots[$i] instanceof BarPlot)) { |
51
|
|
|
Util\JpGraphError::RaiseL(2012, $c); |
52
|
|
|
//('One of the objects submitted to AccBar is not a BarPlot. Make sure that you create the AccBar plot from an array of BarPlot objects.(Class='.$c.')'); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
$this->plots[$i]->DoLegend($graph); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function Max() |
59
|
|
|
{ |
60
|
|
|
list($xmax) = $this->plots[0]->Max(); |
61
|
|
|
$nmax = 0; |
62
|
|
View Code Duplication |
for ($i = 0; $i < count($this->plots); ++$i) { |
|
|
|
|
63
|
|
|
$n = count($this->plots[$i]->coords[0]); |
64
|
|
|
$nmax = max($nmax, $n); |
65
|
|
|
list($x) = $this->plots[$i]->Max(); |
66
|
|
|
$xmax = max($xmax, $x); |
67
|
|
|
} |
68
|
|
|
for ($i = 0; $i < $nmax; $i++) { |
69
|
|
|
// Get y-value for bar $i by adding the |
70
|
|
|
// individual bars from all the plots added. |
71
|
|
|
// It would be wrong to just add the |
72
|
|
|
// individual plots max y-value since that |
73
|
|
|
// would in most cases give to large y-value. |
74
|
|
|
$y = 0; |
75
|
|
|
if (!isset($this->plots[0]->coords[0][$i])) { |
76
|
|
|
Util\JpGraphError::RaiseL(2014); |
77
|
|
|
} |
78
|
|
View Code Duplication |
if ($this->plots[0]->coords[0][$i] > 0) { |
|
|
|
|
79
|
|
|
$y = $this->plots[0]->coords[0][$i]; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
for ($j = 1; $j < $this->nbrplots; $j++) { |
83
|
|
|
if (!isset($this->plots[$j]->coords[0][$i])) { |
84
|
|
|
Util\JpGraphError::RaiseL(2014); |
85
|
|
|
} |
86
|
|
View Code Duplication |
if ($this->plots[$j]->coords[0][$i] > 0) { |
|
|
|
|
87
|
|
|
$y += $this->plots[$j]->coords[0][$i]; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
$ymax[$i] = $y; |
|
|
|
|
91
|
|
|
} |
92
|
|
|
$ymax = max($ymax); |
|
|
|
|
93
|
|
|
|
94
|
|
|
// Bar always start at baseline |
95
|
|
|
if ($ymax <= $this->ybase) { |
96
|
|
|
$ymax = $this->ybase; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
return [$xmax, $ymax]; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function Min() |
103
|
|
|
{ |
104
|
|
|
$nmax = 0; |
105
|
|
|
list($xmin, $ysetmin) = $this->plots[0]->Min(); |
106
|
|
View Code Duplication |
for ($i = 0; $i < count($this->plots); ++$i) { |
|
|
|
|
107
|
|
|
$n = count($this->plots[$i]->coords[0]); |
108
|
|
|
$nmax = max($nmax, $n); |
109
|
|
|
list($x, $y) = $this->plots[$i]->Min(); |
110
|
|
|
$xmin = Min($xmin, $x); |
111
|
|
|
$ysetmin = Min($y, $ysetmin); |
112
|
|
|
} |
113
|
|
|
for ($i = 0; $i < $nmax; $i++) { |
114
|
|
|
// Get y-value for bar $i by adding the |
115
|
|
|
// individual bars from all the plots added. |
116
|
|
|
// It would be wrong to just add the |
117
|
|
|
// individual plots max y-value since that |
118
|
|
|
// would in most cases give to large y-value. |
119
|
|
|
$y = 0; |
120
|
|
View Code Duplication |
if ($this->plots[0]->coords[0][$i] < 0) { |
|
|
|
|
121
|
|
|
$y = $this->plots[0]->coords[0][$i]; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
for ($j = 1; $j < $this->nbrplots; $j++) { |
125
|
|
View Code Duplication |
if ($this->plots[$j]->coords[0][$i] < 0) { |
|
|
|
|
126
|
|
|
$y += $this->plots[$j]->coords[0][$i]; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
$ymin[$i] = $y; |
|
|
|
|
130
|
|
|
} |
131
|
|
|
$ymin = Min($ysetmin, Min($ymin)); |
|
|
|
|
132
|
|
|
// Bar always start at baseline |
133
|
|
|
if ($ymin >= $this->ybase) { |
134
|
|
|
$ymin = $this->ybase; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
return [$xmin, $ymin]; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
// Stroke acc bar plot |
141
|
|
|
public function Stroke($img, $xscale, $yscale) |
142
|
|
|
{ |
143
|
|
|
$pattern = null; |
144
|
|
|
$img->SetLineWeight($this->weight); |
145
|
|
|
$grad = null; |
146
|
|
|
for ($i = 0; $i < $this->numpoints - 1; $i++) { |
147
|
|
|
$accy = 0; |
148
|
|
|
$accy_neg = 0; |
149
|
|
|
for ($j = 0; $j < $this->nbrplots; ++$j) { |
150
|
|
|
$img->SetColor($this->plots[$j]->color); |
151
|
|
|
|
152
|
|
|
if ($this->plots[$j]->coords[0][$i] >= 0) { |
153
|
|
|
$yt = $yscale->Translate($this->plots[$j]->coords[0][$i] + $accy); |
154
|
|
|
$accyt = $yscale->Translate($accy); |
155
|
|
|
$accy += $this->plots[$j]->coords[0][$i]; |
156
|
|
|
} else { |
157
|
|
|
//if ( $this->plots[$j]->coords[0][$i] < 0 || $accy_neg < 0 ) { |
|
|
|
|
158
|
|
|
$yt = $yscale->Translate($this->plots[$j]->coords[0][$i] + $accy_neg); |
159
|
|
|
$accyt = $yscale->Translate($accy_neg); |
160
|
|
|
$accy_neg += $this->plots[$j]->coords[0][$i]; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
$xt = $xscale->Translate($i); |
164
|
|
|
|
165
|
|
View Code Duplication |
if ($this->abswidth > -1) { |
|
|
|
|
166
|
|
|
$abswidth = $this->abswidth; |
167
|
|
|
} else { |
168
|
|
|
$abswidth = round($this->width * $xscale->scale_factor, 0); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
$pts = [$xt, $accyt, $xt, $yt, $xt + $abswidth, $yt, $xt + $abswidth, $accyt]; |
172
|
|
|
|
173
|
|
|
if ($this->bar_shadow) { |
174
|
|
|
$ssh = $this->bar_shadow_hsize; |
175
|
|
|
$ssv = $this->bar_shadow_vsize; |
176
|
|
|
|
177
|
|
|
// We must also differ if we are a positive or negative bar. |
178
|
|
|
if ($j === 0) { |
179
|
|
|
// This gets extra complicated since we have to |
180
|
|
|
// see all plots to see if we are negative. It could |
181
|
|
|
// for example be that all plots are 0 until the very |
182
|
|
|
// last one. We therefore need to save the initial setup |
183
|
|
|
// for both the negative and positive case |
184
|
|
|
|
185
|
|
|
// In case the final bar is positive |
186
|
|
|
$sp[0] = $pts[6] + 1; |
|
|
|
|
187
|
|
|
$sp[1] = $pts[7]; |
|
|
|
|
188
|
|
|
$sp[2] = $pts[6] + $ssh; |
189
|
|
|
$sp[3] = $pts[7] - $ssv; |
190
|
|
|
|
191
|
|
|
// In case the final bar is negative |
192
|
|
|
$nsp[0] = $pts[0]; |
|
|
|
|
193
|
|
|
$nsp[1] = $pts[1]; |
|
|
|
|
194
|
|
|
$nsp[2] = $pts[0] + $ssh; |
195
|
|
|
$nsp[3] = $pts[1] - $ssv; |
196
|
|
|
$nsp[4] = $pts[6] + $ssh; |
197
|
|
|
$nsp[5] = $pts[7] - $ssv; |
198
|
|
|
$nsp[10] = $pts[6] + 1; |
199
|
|
|
$nsp[11] = $pts[7]; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
if ($j === $this->nbrplots - 1) { |
203
|
|
|
// If this is the last plot of the bar and |
204
|
|
|
// the total value is larger than 0 then we |
205
|
|
|
// add the shadow. |
206
|
|
View Code Duplication |
if (is_array($this->bar_shadow_color)) { |
|
|
|
|
207
|
|
|
$numcolors = count($this->bar_shadow_color); |
208
|
|
|
if ($numcolors == 0) { |
209
|
|
|
Util\JpGraphError::RaiseL(2013); //('You have specified an empty array for shadow colors in the bar plot.'); |
210
|
|
|
} |
211
|
|
|
$img->PushColor($this->bar_shadow_color[$i % $numcolors]); |
212
|
|
|
} else { |
213
|
|
|
$img->PushColor($this->bar_shadow_color); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
if ($accy > 0) { |
217
|
|
|
$sp[4] = $pts[4] + $ssh; |
218
|
|
|
$sp[5] = $pts[5] - $ssv; |
219
|
|
|
$sp[6] = $pts[2] + $ssh; |
220
|
|
|
$sp[7] = $pts[3] - $ssv; |
221
|
|
|
$sp[8] = $pts[2]; |
222
|
|
|
$sp[9] = $pts[3] - 1; |
223
|
|
|
$sp[10] = $pts[4] + 1; |
224
|
|
|
$sp[11] = $pts[5]; |
225
|
|
|
$img->FilledPolygon($sp, 4); |
226
|
|
|
} elseif ($accy_neg < 0) { |
227
|
|
|
$nsp[6] = $pts[4] + $ssh; |
228
|
|
|
$nsp[7] = $pts[5] - $ssv; |
229
|
|
|
$nsp[8] = $pts[4] + 1; |
230
|
|
|
$nsp[9] = $pts[5]; |
231
|
|
|
$img->FilledPolygon($nsp, 4); |
232
|
|
|
} |
233
|
|
|
$img->PopColor(); |
234
|
|
|
} |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
// If value is NULL or 0, then don't draw a bar at all |
238
|
|
|
if ($this->plots[$j]->coords[0][$i] == 0) { |
239
|
|
|
continue; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
if ($this->plots[$j]->grad) { |
243
|
|
|
if ($grad === null) { |
244
|
|
|
$grad = new Gradient($img); |
245
|
|
|
} |
246
|
|
|
if (is_array($this->plots[$j]->grad_fromcolor)) { |
247
|
|
|
// The first argument (grad_fromcolor) can be either an array or a single color. If it is an array |
248
|
|
|
// then we have two choices. It can either a) be a single color specified as an RGB triple or it can be |
249
|
|
|
// an array to specify both (from, to style) for each individual bar. The way to know the difference is |
250
|
|
|
// to investgate the first element. If this element is an integer [0,255] then we assume it is an RGB |
251
|
|
|
// triple. |
252
|
|
|
$ng = count($this->plots[$j]->grad_fromcolor); |
253
|
|
|
if ($ng === 3) { |
254
|
|
|
if (is_numeric($this->plots[$j]->grad_fromcolor[0]) && $this->plots[$j]->grad_fromcolor[0] > 0 && |
255
|
|
|
$this->plots[$j]->grad_fromcolor[0] < 256) { |
256
|
|
|
// RGB Triple |
257
|
|
|
$fromcolor = $this->plots[$j]->grad_fromcolor; |
258
|
|
|
$tocolor = $this->plots[$j]->grad_tocolor; |
259
|
|
|
$style = $this->plots[$j]->grad_style; |
260
|
|
View Code Duplication |
} else { |
|
|
|
|
261
|
|
|
$fromcolor = $this->plots[$j]->grad_fromcolor[$i % $ng][0]; |
262
|
|
|
$tocolor = $this->plots[$j]->grad_fromcolor[$i % $ng][1]; |
263
|
|
|
$style = $this->plots[$j]->grad_fromcolor[$i % $ng][2]; |
264
|
|
|
} |
265
|
|
View Code Duplication |
} else { |
|
|
|
|
266
|
|
|
$fromcolor = $this->plots[$j]->grad_fromcolor[$i % $ng][0]; |
267
|
|
|
$tocolor = $this->plots[$j]->grad_fromcolor[$i % $ng][1]; |
268
|
|
|
$style = $this->plots[$j]->grad_fromcolor[$i % $ng][2]; |
269
|
|
|
} |
270
|
|
|
$grad->FilledRectangle($pts[2], $pts[3], |
271
|
|
|
$pts[6], $pts[7], |
272
|
|
|
$fromcolor, $tocolor, $style); |
273
|
|
|
} else { |
274
|
|
|
$grad->FilledRectangle($pts[2], $pts[3], |
275
|
|
|
$pts[6], $pts[7], |
276
|
|
|
$this->plots[$j]->grad_fromcolor, |
277
|
|
|
$this->plots[$j]->grad_tocolor, |
278
|
|
|
$this->plots[$j]->grad_style); |
279
|
|
|
} |
280
|
|
|
} else { |
281
|
|
|
if (is_array($this->plots[$j]->fill_color)) { |
282
|
|
|
$numcolors = count($this->plots[$j]->fill_color); |
283
|
|
|
$fillcolor = $this->plots[$j]->fill_color[$i % $numcolors]; |
284
|
|
|
// If the bar is specified to be non filled then the fill color is false |
285
|
|
View Code Duplication |
if ($fillcolor !== false) { |
|
|
|
|
286
|
|
|
$img->SetColor($this->plots[$j]->fill_color[$i % $numcolors]); |
287
|
|
|
} |
288
|
|
View Code Duplication |
} else { |
|
|
|
|
289
|
|
|
$fillcolor = $this->plots[$j]->fill_color; |
290
|
|
|
if ($fillcolor !== false) { |
291
|
|
|
$img->SetColor($this->plots[$j]->fill_color); |
292
|
|
|
} |
293
|
|
|
} |
294
|
|
|
if ($fillcolor !== false) { |
295
|
|
|
$img->FilledPolygon($pts); |
296
|
|
|
} |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
$img->SetColor($this->plots[$j]->color); |
300
|
|
|
|
301
|
|
|
// Stroke the pattern |
302
|
|
|
if ($this->plots[$j]->iPattern > -1) { |
303
|
|
|
if ($pattern === null) { |
304
|
|
|
$pattern = new RectPatternFactory(); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
$prect = $pattern->Create($this->plots[$j]->iPattern, $this->plots[$j]->iPatternColor, 1); |
308
|
|
|
$prect->SetDensity($this->plots[$j]->iPatternDensity); |
309
|
|
|
if ($this->plots[$j]->coords[0][$i] < 0) { |
310
|
|
|
$rx = $pts[0]; |
311
|
|
|
$ry = $pts[1]; |
312
|
|
|
} else { |
313
|
|
|
$rx = $pts[2]; |
314
|
|
|
$ry = $pts[3]; |
315
|
|
|
} |
316
|
|
|
$width = abs($pts[4] - $pts[0]) + 1; |
317
|
|
|
$height = abs($pts[1] - $pts[3]) + 1; |
318
|
|
|
$prect->SetPos(new Util\Rectangle($rx, $ry, $width, $height)); |
319
|
|
|
$prect->Stroke($img); |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
// CSIM array |
323
|
|
|
|
324
|
|
|
if ($i < count($this->plots[$j]->csimtargets)) { |
325
|
|
|
// Create the client side image map |
326
|
|
|
$rpts = $img->ArrRotate($pts); |
327
|
|
|
$csimcoord = round($rpts[0]) . ", " . round($rpts[1]); |
328
|
|
View Code Duplication |
for ($k = 1; $k < 4; ++$k) { |
|
|
|
|
329
|
|
|
$csimcoord .= ", " . round($rpts[2 * $k]) . ", " . round($rpts[2 * $k + 1]); |
330
|
|
|
} |
331
|
|
|
if (!empty($this->plots[$j]->csimtargets[$i])) { |
332
|
|
|
$this->csimareas .= '<area shape="poly" coords="' . $csimcoord . '" '; |
333
|
|
|
$this->csimareas .= " href=\"" . $this->plots[$j]->csimtargets[$i] . "\" "; |
334
|
|
|
|
335
|
|
|
if (!empty($this->plots[$j]->csimwintargets[$i])) { |
336
|
|
|
$this->csimareas .= " target=\"" . $this->plots[$j]->csimwintargets[$i] . "\" "; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
$sval = ''; |
340
|
|
|
if (!empty($this->plots[$j]->csimalts[$i])) { |
341
|
|
|
$sval = sprintf($this->plots[$j]->csimalts[$i], $this->plots[$j]->coords[0][$i]); |
342
|
|
|
$this->csimareas .= " title=\"$sval\" "; |
343
|
|
|
} |
344
|
|
|
$this->csimareas .= " alt=\"$sval\" />\n"; |
345
|
|
|
} |
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
$pts[] = $pts[0]; |
349
|
|
|
$pts[] = $pts[1]; |
350
|
|
|
$img->SetLineWeight($this->plots[$j]->weight); |
351
|
|
|
$img->Polygon($pts); |
352
|
|
|
$img->SetLineWeight(1); |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
// Daw potential bar around the entire accbar bar |
356
|
|
|
if ($this->weight > 0) { |
357
|
|
|
$y = $yscale->Translate(0); |
358
|
|
|
$img->SetColor($this->color); |
359
|
|
|
$img->SetLineWeight($this->weight); |
360
|
|
|
$img->Rectangle($pts[0], $y, $pts[6], $pts[5]); |
|
|
|
|
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
// Draw labels for each acc.bar |
364
|
|
|
|
365
|
|
|
$x = $pts[2] + ($pts[4] - $pts[2]) / 2; |
366
|
|
|
if ($this->bar_shadow) { |
367
|
|
|
$x += $ssh; |
|
|
|
|
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
// First stroke the accumulated value for the entire bar |
371
|
|
|
// This value is always placed at the top/bottom of the bars |
372
|
|
|
if ($accy_neg < 0) { |
373
|
|
|
$y = $yscale->Translate($accy_neg); |
374
|
|
|
$this->value->Stroke($img, $accy_neg, $x, $y); |
375
|
|
|
} else { |
376
|
|
|
$y = $yscale->Translate($accy); |
377
|
|
|
$this->value->Stroke($img, $accy, $x, $y); |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
$accy = 0; |
381
|
|
|
$accy_neg = 0; |
382
|
|
|
for ($j = 0; $j < $this->nbrplots; ++$j) { |
383
|
|
|
|
384
|
|
|
// We don't print 0 values in an accumulated bar plot |
385
|
|
|
if ($this->plots[$j]->coords[0][$i] == 0) { |
386
|
|
|
continue; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
if ($this->plots[$j]->coords[0][$i] > 0) { |
390
|
|
|
$yt = $yscale->Translate($this->plots[$j]->coords[0][$i] + $accy); |
391
|
|
|
$accyt = $yscale->Translate($accy); |
392
|
|
View Code Duplication |
if ($this->plots[$j]->valuepos == 'center') { |
|
|
|
|
393
|
|
|
$y = $accyt - ($accyt - $yt) / 2; |
394
|
|
|
} elseif ($this->plots[$j]->valuepos == 'bottom') { |
395
|
|
|
$y = $accyt; |
396
|
|
|
} else { |
397
|
|
|
// top or max |
398
|
|
|
$y = $accyt - ($accyt - $yt); |
399
|
|
|
} |
400
|
|
|
$accy += $this->plots[$j]->coords[0][$i]; |
401
|
|
|
if ($this->plots[$j]->valuepos == 'center') { |
402
|
|
|
$this->plots[$j]->value->SetAlign("center", "center"); |
403
|
|
|
$this->plots[$j]->value->SetMargin(0); |
404
|
|
View Code Duplication |
} elseif ($this->plots[$j]->valuepos == 'bottom') { |
|
|
|
|
405
|
|
|
$this->plots[$j]->value->SetAlign('center', 'bottom'); |
406
|
|
|
$this->plots[$j]->value->SetMargin(2); |
407
|
|
|
} else { |
408
|
|
|
$this->plots[$j]->value->SetAlign('center', 'top'); |
409
|
|
|
$this->plots[$j]->value->SetMargin(1); |
410
|
|
|
} |
411
|
|
|
} else { |
412
|
|
|
$yt = $yscale->Translate($this->plots[$j]->coords[0][$i] + $accy_neg); |
413
|
|
|
$accyt = $yscale->Translate($accy_neg); |
414
|
|
|
$accy_neg += $this->plots[$j]->coords[0][$i]; |
415
|
|
View Code Duplication |
if ($this->plots[$j]->valuepos == 'center') { |
|
|
|
|
416
|
|
|
$y = $accyt - ($accyt - $yt) / 2; |
417
|
|
|
} elseif ($this->plots[$j]->valuepos == 'bottom') { |
418
|
|
|
$y = $accyt; |
419
|
|
|
} else { |
420
|
|
|
$y = $accyt - ($accyt - $yt); |
421
|
|
|
} |
422
|
|
|
if ($this->plots[$j]->valuepos == 'center') { |
423
|
|
|
$this->plots[$j]->value->SetAlign("center", "center"); |
424
|
|
|
$this->plots[$j]->value->SetMargin(0); |
425
|
|
View Code Duplication |
} elseif ($this->plots[$j]->valuepos == 'bottom') { |
|
|
|
|
426
|
|
|
$this->plots[$j]->value->SetAlign('center', $j == 0 ? 'bottom' : 'top'); |
427
|
|
|
$this->plots[$j]->value->SetMargin(-2); |
428
|
|
|
} else { |
429
|
|
|
$this->plots[$j]->value->SetAlign('center', 'bottom'); |
430
|
|
|
$this->plots[$j]->value->SetMargin(-1); |
431
|
|
|
} |
432
|
|
|
} |
433
|
|
|
$this->plots[$j]->value->Stroke($img, $this->plots[$j]->coords[0][$i], $x, $y); |
434
|
|
|
} |
435
|
|
|
} |
436
|
|
|
return true; |
437
|
|
|
} |
438
|
|
|
} // Class |
439
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.