@@ -29,8 +29,7 @@ discard block |
||
29 | 29 | define("LABEL_LIGHT" , 690032); |
30 | 30 | |
31 | 31 | /* pSpring class definition */ |
32 | - class pSpring |
|
33 | - { |
|
32 | + class pSpring { |
|
34 | 33 | var $History; |
35 | 34 | var $pChartObject; |
36 | 35 | var $Data; |
@@ -43,8 +42,7 @@ discard block |
||
43 | 42 | var $Labels; |
44 | 43 | |
45 | 44 | /* Class creator */ |
46 | - function pSpring() |
|
47 | - { |
|
45 | + function pSpring() { |
|
48 | 46 | /* Initialise data arrays */ |
49 | 47 | $this->Data = ""; |
50 | 48 | $this->Links = ""; |
@@ -83,8 +81,7 @@ discard block |
||
83 | 81 | } |
84 | 82 | |
85 | 83 | /* Set default links options */ |
86 | - function setLinkDefaults($Settings="") |
|
87 | - { |
|
84 | + function setLinkDefaults($Settings="") { |
|
88 | 85 | if ( isset($Settings["R"]) ) { $this->Default["LinkR"] = $Settings["R"]; } |
89 | 86 | if ( isset($Settings["G"]) ) { $this->Default["LinkG"] = $Settings["G"]; } |
90 | 87 | if ( isset($Settings["B"]) ) { $this->Default["LinkB"] = $Settings["B"]; } |
@@ -92,8 +89,7 @@ discard block |
||
92 | 89 | } |
93 | 90 | |
94 | 91 | /* Set default links options */ |
95 | - function setLabelsSettings($Settings="") |
|
96 | - { |
|
92 | + function setLabelsSettings($Settings="") { |
|
97 | 93 | if ( isset($Settings["Type"]) ) { $this->Labels["Type"] = $Settings["Type"]; } |
98 | 94 | if ( isset($Settings["R"]) ) { $this->Labels["R"] = $Settings["R"]; } |
99 | 95 | if ( isset($Settings["G"]) ) { $this->Labels["G"] = $Settings["G"]; } |
@@ -102,22 +98,18 @@ discard block |
||
102 | 98 | } |
103 | 99 | |
104 | 100 | /* Auto compute the FreeZone size based on the number of connections */ |
105 | - function autoFreeZone() |
|
106 | - { |
|
101 | + function autoFreeZone() { |
|
107 | 102 | /* Check connections reciprocity */ |
108 | - foreach($this->Data as $Key => $Settings) |
|
109 | - { |
|
103 | + foreach($this->Data as $Key => $Settings) { |
|
110 | 104 | if ( isset($Settings["Connections"]) ) |
111 | - { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; } |
|
112 | - else |
|
105 | + { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; } else |
|
113 | 106 | { $this->Data[$Key]["FreeZone"] = 20; } |
114 | 107 | } |
115 | 108 | |
116 | 109 | } |
117 | 110 | |
118 | 111 | /* Set link properties */ |
119 | - function linkProperties($FromNode,$ToNode,$Settings) |
|
120 | - { |
|
112 | + function linkProperties($FromNode,$ToNode,$Settings) { |
|
121 | 113 | if ( !isset($this->Data[$FromNode]) ) { return(0); } |
122 | 114 | if ( !isset($this->Data[$ToNode]) ) { return(0); } |
123 | 115 | |
@@ -136,8 +128,7 @@ discard block |
||
136 | 128 | $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks; |
137 | 129 | } |
138 | 130 | |
139 | - function setNodeDefaults($Settings="") |
|
140 | - { |
|
131 | + function setNodeDefaults($Settings="") { |
|
141 | 132 | if ( isset($Settings["R"]) ) { $this->Default["R"] = $Settings["R"]; } |
142 | 133 | if ( isset($Settings["G"]) ) { $this->Default["G"] = $Settings["G"]; } |
143 | 134 | if ( isset($Settings["B"]) ) { $this->Default["B"] = $Settings["B"]; } |
@@ -158,8 +149,7 @@ discard block |
||
158 | 149 | } |
159 | 150 | |
160 | 151 | /* Add a node */ |
161 | - function addNode($NodeID,$Settings="") |
|
162 | - { |
|
152 | + function addNode($NodeID,$Settings="") { |
|
163 | 153 | /* if the node already exists, ignore */ |
164 | 154 | if (isset($this->Data[$NodeID])) { return(0); } |
165 | 155 | |
@@ -196,27 +186,21 @@ discard block |
||
196 | 186 | $this->Data[$NodeID]["Size"] = $Size; |
197 | 187 | $this->Data[$NodeID]["Shape"] = $Shape; |
198 | 188 | $this->Data[$NodeID]["FreeZone"] = $FreeZone; |
199 | - if ( $Connections != NULL ) |
|
200 | - { |
|
201 | - if ( is_array($Connections ) ) |
|
202 | - { |
|
203 | - foreach($Connections as $Key => $Value) |
|
204 | - $this->Data[$NodeID]["Connections"][] = $Value; |
|
205 | - } |
|
206 | - else |
|
189 | + if ( $Connections != NULL ) { |
|
190 | + if ( is_array($Connections ) ) { |
|
191 | + foreach($Connections as $Key => $Value) { |
|
192 | + $this->Data[$NodeID]["Connections"][] = $Value; |
|
193 | + } |
|
194 | + } else |
|
207 | 195 | $this->Data[$NodeID]["Connections"][] = $Connections; |
208 | 196 | } |
209 | 197 | } |
210 | 198 | |
211 | 199 | /* Set color attribute for a list of nodes */ |
212 | - function setNodesColor($Nodes,$Settings="") |
|
213 | - { |
|
214 | - if ( is_array($Nodes) ) |
|
215 | - { |
|
216 | - foreach ($Nodes as $Key => $NodeID) |
|
217 | - { |
|
218 | - if (isset($this->Data[$NodeID]) ) |
|
219 | - { |
|
200 | + function setNodesColor($Nodes,$Settings="") { |
|
201 | + if ( is_array($Nodes) ) { |
|
202 | + foreach ($Nodes as $Key => $NodeID) { |
|
203 | + if (isset($this->Data[$NodeID]) ) { |
|
220 | 204 | if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; } |
221 | 205 | if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; } |
222 | 206 | if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; } |
@@ -228,9 +212,7 @@ discard block |
||
228 | 212 | if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; } |
229 | 213 | } |
230 | 214 | } |
231 | - } |
|
232 | - else |
|
233 | - { |
|
215 | + } else { |
|
234 | 216 | if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; } |
235 | 217 | if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; } |
236 | 218 | if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; } |
@@ -248,25 +230,19 @@ discard block |
||
248 | 230 | { return($this->Data); } |
249 | 231 | |
250 | 232 | /* Check if a connection exists and create it if required */ |
251 | - function checkConnection($SourceID, $TargetID) |
|
252 | - { |
|
253 | - if ( isset($this->Data[$SourceID]["Connections"]) ) |
|
254 | - { |
|
233 | + function checkConnection($SourceID, $TargetID) { |
|
234 | + if ( isset($this->Data[$SourceID]["Connections"]) ) { |
|
255 | 235 | foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID) |
256 | 236 | { if ( $TargetID == $ConnectionID ) { return(TRUE); } } |
257 | 237 | } |
258 | 238 | $this->Data[$SourceID]["Connections"][] = $TargetID; |
259 | 239 | } |
260 | 240 | /* Get the median linked nodes position */ |
261 | - function getMedianOffset($Key,$X,$Y) |
|
262 | - { |
|
241 | + function getMedianOffset($Key,$X,$Y) { |
|
263 | 242 | $Cpt = 1; |
264 | - if ( isset($this->Data[$Key]["Connections"]) ) |
|
265 | - { |
|
266 | - foreach($this->Data[$Key]["Connections"] as $ID => $NodeID) |
|
267 | - { |
|
268 | - if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) ) |
|
269 | - { |
|
243 | + if ( isset($this->Data[$Key]["Connections"]) ) { |
|
244 | + foreach($this->Data[$Key]["Connections"] as $ID => $NodeID) { |
|
245 | + if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) ) { |
|
270 | 246 | $X = $X + $this->Data[$NodeID]["X"]; |
271 | 247 | $Y = $Y + $this->Data[$NodeID]["Y"]; |
272 | 248 | $Cpt++; |
@@ -277,13 +253,11 @@ discard block |
||
277 | 253 | } |
278 | 254 | |
279 | 255 | /* Return the ID of the attached partner with the biggest weight */ |
280 | - function getBiggestPartner($Key) |
|
281 | - { |
|
256 | + function getBiggestPartner($Key) { |
|
282 | 257 | if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); } |
283 | 258 | |
284 | 259 | $MaxWeight = 0; $Result = ""; |
285 | - foreach($this->Data[$Key]["Connections"] as $Key => $PeerID) |
|
286 | - { |
|
260 | + foreach($this->Data[$Key]["Connections"] as $Key => $PeerID) { |
|
287 | 261 | if ( $this->Data[$PeerID]["Weight"] > $MaxWeight ) |
288 | 262 | { $MaxWeight = $this->Data[$PeerID]["Weight"]; $Result = $PeerID; } |
289 | 263 | } |
@@ -291,18 +265,16 @@ discard block |
||
291 | 265 | } |
292 | 266 | |
293 | 267 | /* Do the initial node positions computing pass */ |
294 | - function firstPass($Algorithm) |
|
295 | - { |
|
268 | + function firstPass($Algorithm) { |
|
296 | 269 | $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1; |
297 | 270 | $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1; |
298 | 271 | |
299 | 272 | /* Check connections reciprocity */ |
300 | - foreach($this->Data as $Key => $Settings) |
|
301 | - { |
|
302 | - if ( isset($Settings["Connections"]) ) |
|
303 | - { |
|
304 | - foreach($Settings["Connections"] as $ID => $ConnectionID) |
|
305 | - $this->checkConnection($ConnectionID,$Key); |
|
273 | + foreach($this->Data as $Key => $Settings) { |
|
274 | + if ( isset($Settings["Connections"]) ) { |
|
275 | + foreach($Settings["Connections"] as $ID => $ConnectionID) { |
|
276 | + $this->checkConnection($ConnectionID,$Key); |
|
277 | + } |
|
306 | 278 | } |
307 | 279 | } |
308 | 280 | |
@@ -313,16 +285,12 @@ discard block |
||
313 | 285 | foreach($this->Data as $Key => $Settings) |
314 | 286 | { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } } |
315 | 287 | |
316 | - if ( $Algorithm == ALGORITHM_WEIGHTED ) |
|
317 | - { |
|
318 | - foreach($this->Data as $Key => $Settings) |
|
319 | - { |
|
288 | + if ( $Algorithm == ALGORITHM_WEIGHTED ) { |
|
289 | + foreach($this->Data as $Key => $Settings) { |
|
320 | 290 | if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
321 | - if ( $Settings["Type"] == NODE_TYPE_FREE ) |
|
322 | - { |
|
291 | + if ( $Settings["Type"] == NODE_TYPE_FREE ) { |
|
323 | 292 | if ( isset($Settings["Connections"]) ) |
324 | - { $Connections = count($Settings["Connections"]); } |
|
325 | - else |
|
293 | + { $Connections = count($Settings["Connections"]); } else |
|
326 | 294 | { $Connections = 0; } |
327 | 295 | |
328 | 296 | $Ring = $MaxConnections - $Connections; |
@@ -332,12 +300,9 @@ discard block |
||
332 | 300 | $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY; |
333 | 301 | } |
334 | 302 | } |
335 | - } |
|
336 | - elseif ( $Algorithm == ALGORITHM_CENTRAL ) |
|
337 | - { |
|
303 | + } elseif ( $Algorithm == ALGORITHM_CENTRAL ) { |
|
338 | 304 | /* Put a weight on each nodes */ |
339 | - foreach($this->Data as $Key => $Settings) |
|
340 | - { |
|
305 | + foreach($this->Data as $Key => $Settings) { |
|
341 | 306 | if ( isset($Settings["Connections"]) ) |
342 | 307 | $this->Data[$Key]["Weight"] = count($Settings["Connections"]); |
343 | 308 | else |
@@ -345,33 +310,25 @@ discard block |
||
345 | 310 | } |
346 | 311 | |
347 | 312 | $MaxConnections = $MaxConnections + 1; |
348 | - for($i=$MaxConnections;$i>=0;$i--) |
|
349 | - { |
|
350 | - foreach($this->Data as $Key => $Settings) |
|
351 | - { |
|
313 | + for($i=$MaxConnections;$i>=0;$i--) { |
|
314 | + foreach($this->Data as $Key => $Settings) { |
|
352 | 315 | if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
353 | - if ( $Settings["Type"] == NODE_TYPE_FREE ) |
|
354 | - { |
|
316 | + if ( $Settings["Type"] == NODE_TYPE_FREE ) { |
|
355 | 317 | if ( isset($Settings["Connections"]) ) |
356 | - { $Connections = count($Settings["Connections"]); } |
|
357 | - else |
|
318 | + { $Connections = count($Settings["Connections"]); } else |
|
358 | 319 | { $Connections = 0; } |
359 | 320 | |
360 | - if ( $Connections == $i ) |
|
361 | - { |
|
321 | + if ( $Connections == $i ) { |
|
362 | 322 | $BiggestPartner = $this->getBiggestPartner($Key); |
363 | - if ( $BiggestPartner != "" ) |
|
364 | - { |
|
323 | + if ( $BiggestPartner != "" ) { |
|
365 | 324 | $Ring = $this->Data[$BiggestPartner]["FreeZone"]; |
366 | 325 | $Weight = $this->Data[$BiggestPartner]["Weight"]; |
367 | 326 | $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"]; |
368 | 327 | $Done = FALSE; $Tries = 0; |
369 | - while (!$Done && $Tries <= $Weight*2) |
|
370 | - { |
|
328 | + while (!$Done && $Tries <= $Weight*2) { |
|
371 | 329 | $Tries++; |
372 | 330 | $Angle = floor(rand(0,$Weight)*$AngleDivision); |
373 | - if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) ) |
|
374 | - { |
|
331 | + if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) ) { |
|
375 | 332 | $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; |
376 | 333 | $Done = TRUE; |
377 | 334 | } |
@@ -389,24 +346,17 @@ discard block |
||
389 | 346 | } |
390 | 347 | } |
391 | 348 | } |
392 | - } |
|
393 | - elseif ( $Algorithm == ALGORITHM_CIRCULAR ) |
|
394 | - { |
|
349 | + } elseif ( $Algorithm == ALGORITHM_CIRCULAR ) { |
|
395 | 350 | $MaxConnections = $MaxConnections + 1; |
396 | - for($i=$MaxConnections;$i>=0;$i--) |
|
397 | - { |
|
398 | - foreach($this->Data as $Key => $Settings) |
|
399 | - { |
|
351 | + for($i=$MaxConnections;$i>=0;$i--) { |
|
352 | + foreach($this->Data as $Key => $Settings) { |
|
400 | 353 | if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; } |
401 | - if ( $Settings["Type"] == NODE_TYPE_FREE ) |
|
402 | - { |
|
354 | + if ( $Settings["Type"] == NODE_TYPE_FREE ) { |
|
403 | 355 | if ( isset($Settings["Connections"]) ) |
404 | - { $Connections = count($Settings["Connections"]); } |
|
405 | - else |
|
356 | + { $Connections = count($Settings["Connections"]); } else |
|
406 | 357 | { $Connections = 0; } |
407 | 358 | |
408 | - if ( $Connections == $i ) |
|
409 | - { |
|
359 | + if ( $Connections == $i ) { |
|
410 | 360 | $Ring = $MaxConnections - $Connections; |
411 | 361 | $Angle = rand(0,360); |
412 | 362 | |
@@ -421,13 +371,9 @@ discard block |
||
421 | 371 | } |
422 | 372 | } |
423 | 373 | } |
424 | - } |
|
425 | - elseif ( $Algorithm == ALGORITHM_RANDOM ) |
|
426 | - { |
|
427 | - foreach($this->Data as $Key => $Settings) |
|
428 | - { |
|
429 | - if ( $Settings["Type"] == NODE_TYPE_FREE ) |
|
430 | - { |
|
374 | + } elseif ( $Algorithm == ALGORITHM_RANDOM ) { |
|
375 | + foreach($this->Data as $Key => $Settings) { |
|
376 | + if ( $Settings["Type"] == NODE_TYPE_FREE ) { |
|
431 | 377 | $this->Data[$Key]["X"] = $CenterX + rand(-20,20); |
432 | 378 | $this->Data[$Key]["Y"] = $CenterY + rand(-20,20); |
433 | 379 | } |
@@ -437,23 +383,18 @@ discard block |
||
437 | 383 | } |
438 | 384 | |
439 | 385 | /* Compute one pass */ |
440 | - function doPass() |
|
441 | - { |
|
386 | + function doPass() { |
|
442 | 387 | /* Compute vectors */ |
443 | - foreach($this->Data as $Key => $Settings) |
|
444 | - { |
|
445 | - if ( $Settings["Type"] != NODE_TYPE_CENTRAL ) |
|
446 | - { |
|
388 | + foreach($this->Data as $Key => $Settings) { |
|
389 | + if ( $Settings["Type"] != NODE_TYPE_CENTRAL ) { |
|
447 | 390 | unset($this->Data[$Key]["Vectors"]); |
448 | 391 | |
449 | 392 | $X1 = $Settings["X"]; |
450 | 393 | $Y1 = $Settings["Y"]; |
451 | 394 | |
452 | 395 | /* Repulsion vectors */ |
453 | - foreach($this->Data as $Key2 => $Settings2) |
|
454 | - { |
|
455 | - if ( $Key != $Key2 ) |
|
456 | - { |
|
396 | + foreach($this->Data as $Key2 => $Settings2) { |
|
397 | + if ( $Key != $Key2 ) { |
|
457 | 398 | $X2 = $this->Data[$Key2]["X"]; |
458 | 399 | $Y2 = $this->Data[$Key2]["Y"]; |
459 | 400 | $FreeZone = $this->Data[$Key2]["FreeZone"]; |
@@ -462,8 +403,7 @@ discard block |
||
462 | 403 | $Angle = $this->getAngle($X1,$Y1,$X2,$Y2) + 180; |
463 | 404 | |
464 | 405 | /* Nodes too close, repulsion occurs */ |
465 | - if ( $Distance < $FreeZone ) |
|
466 | - { |
|
406 | + if ( $Distance < $FreeZone ) { |
|
467 | 407 | $Force = log(pow(2,$FreeZone-$Distance)); |
468 | 408 | if ( $Force > 1 ) |
469 | 409 | { $this->Data[$Key]["Vectors"][] = array("Type"=>"R","Angle"=>$Angle % 360,"Force"=>$Force); } |
@@ -472,12 +412,9 @@ discard block |
||
472 | 412 | } |
473 | 413 | |
474 | 414 | /* Attraction vectors */ |
475 | - if ( isset($Settings["Connections"]) ) |
|
476 | - { |
|
477 | - foreach($Settings["Connections"] as $ID => $NodeID) |
|
478 | - { |
|
479 | - if ( isset($this->Data[$NodeID]) ) |
|
480 | - { |
|
415 | + if ( isset($Settings["Connections"]) ) { |
|
416 | + foreach($Settings["Connections"] as $ID => $NodeID) { |
|
417 | + if ( isset($this->Data[$NodeID]) ) { |
|
481 | 418 | $X2 = $this->Data[$NodeID]["X"]; |
482 | 419 | $Y2 = $this->Data[$NodeID]["Y"]; |
483 | 420 | $FreeZone = $this->Data[$Key2]["FreeZone"]; |
@@ -499,15 +436,12 @@ discard block |
||
499 | 436 | } |
500 | 437 | |
501 | 438 | /* Move the nodes accoding to the vectors */ |
502 | - foreach($this->Data as $Key => $Settings) |
|
503 | - { |
|
439 | + foreach($this->Data as $Key => $Settings) { |
|
504 | 440 | $X = $Settings["X"]; |
505 | 441 | $Y = $Settings["Y"]; |
506 | 442 | |
507 | - if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL ) |
|
508 | - { |
|
509 | - foreach($Settings["Vectors"] as $ID => $Vector) |
|
510 | - { |
|
443 | + if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL ) { |
|
444 | + foreach($Settings["Vectors"] as $ID => $Vector) { |
|
511 | 445 | $Type = $Vector["Type"]; |
512 | 446 | $Force = $Vector["Force"]; |
513 | 447 | $Angle = $Vector["Angle"]; |
@@ -523,11 +457,9 @@ discard block |
||
523 | 457 | } |
524 | 458 | } |
525 | 459 | |
526 | - function lastPass() |
|
527 | - { |
|
460 | + function lastPass() { |
|
528 | 461 | /* Put everything inside the graph area */ |
529 | - foreach($this->Data as $Key => $Settings) |
|
530 | - { |
|
462 | + foreach($this->Data as $Key => $Settings) { |
|
531 | 463 | $X = $Settings["X"]; |
532 | 464 | $Y = $Settings["Y"]; |
533 | 465 | |
@@ -542,17 +474,13 @@ discard block |
||
542 | 474 | |
543 | 475 | /* Dump all links */ |
544 | 476 | $Links = ""; |
545 | - foreach($this->Data as $Key => $Settings) |
|
546 | - { |
|
477 | + foreach($this->Data as $Key => $Settings) { |
|
547 | 478 | $X1 = $Settings["X"]; |
548 | 479 | $Y1 = $Settings["Y"]; |
549 | 480 | |
550 | - if ( isset($Settings["Connections"]) ) |
|
551 | - { |
|
552 | - foreach ($Settings["Connections"] as $ID => $NodeID) |
|
553 | - { |
|
554 | - if ( isset($this->Data[$NodeID]) ) |
|
555 | - { |
|
481 | + if ( isset($Settings["Connections"]) ) { |
|
482 | + foreach ($Settings["Connections"] as $ID => $NodeID) { |
|
483 | + if ( isset($this->Data[$NodeID]) ) { |
|
556 | 484 | $X2 = $this->Data[$NodeID]["X"]; |
557 | 485 | $Y2 = $this->Data[$NodeID]["Y"]; |
558 | 486 | |
@@ -564,28 +492,21 @@ discard block |
||
564 | 492 | |
565 | 493 | /* Check collisions */ |
566 | 494 | $Conflicts = 0; |
567 | - foreach($this->Data as $Key => $Settings) |
|
568 | - { |
|
495 | + foreach($this->Data as $Key => $Settings) { |
|
569 | 496 | $X1 = $Settings["X"]; |
570 | 497 | $Y1 = $Settings["Y"]; |
571 | 498 | |
572 | - if ( isset($Settings["Connections"]) ) |
|
573 | - { |
|
574 | - foreach ($Settings["Connections"] as $ID => $NodeID) |
|
575 | - { |
|
576 | - if ( isset($this->Data[$NodeID]) ) |
|
577 | - { |
|
499 | + if ( isset($Settings["Connections"]) ) { |
|
500 | + foreach ($Settings["Connections"] as $ID => $NodeID) { |
|
501 | + if ( isset($this->Data[$NodeID]) ) { |
|
578 | 502 | $X2 = $this->Data[$NodeID]["X"]; |
579 | 503 | $Y2 = $this->Data[$NodeID]["Y"]; |
580 | 504 | |
581 | - foreach($Links as $IDLinks => $Link) |
|
582 | - { |
|
505 | + foreach($Links as $IDLinks => $Link) { |
|
583 | 506 | $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"]; |
584 | 507 | |
585 | - if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) ) |
|
586 | - { |
|
587 | - if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) ) |
|
588 | - { |
|
508 | + if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) ) { |
|
509 | + if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) ) { |
|
589 | 510 | if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] ) |
590 | 511 | { $Conflicts++; } |
591 | 512 | } |
@@ -599,8 +520,7 @@ discard block |
||
599 | 520 | } |
600 | 521 | |
601 | 522 | /* Center the graph */ |
602 | - function center() |
|
603 | - { |
|
523 | + function center() { |
|
604 | 524 | /* Determine the real center */ |
605 | 525 | $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1; |
606 | 526 | $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1; |
@@ -608,8 +528,7 @@ discard block |
||
608 | 528 | /* Get current boundaries */ |
609 | 529 | $XMin = $this->X2; $XMax = $this->X1; |
610 | 530 | $YMin = $this->Y2; $YMax = $this->Y1; |
611 | - foreach($this->Data as $Key => $Settings) |
|
612 | - { |
|
531 | + foreach($this->Data as $Key => $Settings) { |
|
613 | 532 | $X = $Settings["X"]; |
614 | 533 | $Y = $Settings["Y"]; |
615 | 534 | |
@@ -626,16 +545,14 @@ discard block |
||
626 | 545 | $YOffset = $TargetCenterY - $CurrentCenterY; |
627 | 546 | |
628 | 547 | /* Correct the points position */ |
629 | - foreach($this->Data as $Key => $Settings) |
|
630 | - { |
|
548 | + foreach($this->Data as $Key => $Settings) { |
|
631 | 549 | $this->Data[$Key]["X"] = $Settings["X"] + $XOffset; |
632 | 550 | $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset; |
633 | 551 | } |
634 | 552 | } |
635 | 553 | |
636 | 554 | /* Create the encoded string */ |
637 | - function drawSpring($Object,$Settings="") |
|
638 | - { |
|
555 | + function drawSpring($Object,$Settings="") { |
|
639 | 556 | $this->pChartObject = $Object; |
640 | 557 | |
641 | 558 | $Pass = isset($Settings["Pass"]) ? $Settings["Pass"] : 50; |
@@ -656,16 +573,14 @@ discard block |
||
656 | 573 | $this->Y2 = $Object->GraphAreaY2; |
657 | 574 | |
658 | 575 | $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1; |
659 | - while ($Conflicts != 0 && $Jobs < $Retries ) |
|
660 | - { |
|
576 | + while ($Conflicts != 0 && $Jobs < $Retries ) { |
|
661 | 577 | $Jobs++; |
662 | 578 | |
663 | 579 | /* Compute the initial settings */ |
664 | 580 | $this->firstPass($Algorithm); |
665 | 581 | |
666 | 582 | /* Apply the vectors */ |
667 | - if ( $Pass > 0 ) |
|
668 | - { |
|
583 | + if ( $Pass > 0 ) { |
|
669 | 584 | for ($i=0; $i<=$Pass; $i++) { $this->doPass(); } |
670 | 585 | } |
671 | 586 | |
@@ -681,24 +596,19 @@ discard block |
||
681 | 596 | |
682 | 597 | /* Draw the connections */ |
683 | 598 | $Drawn = ""; |
684 | - foreach($this->Data as $Key => $Settings) |
|
685 | - { |
|
599 | + foreach($this->Data as $Key => $Settings) { |
|
686 | 600 | $X = $Settings["X"]; |
687 | 601 | $Y = $Settings["Y"]; |
688 | 602 | |
689 | - if ( isset($Settings["Connections"]) ) |
|
690 | - { |
|
691 | - foreach ($Settings["Connections"] as $ID => $NodeID) |
|
692 | - { |
|
603 | + if ( isset($Settings["Connections"]) ) { |
|
604 | + foreach ($Settings["Connections"] as $ID => $NodeID) { |
|
693 | 605 | if ( !isset($Drawn[$Key]) ) { $Drawn[$Key] = ""; } |
694 | 606 | if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; } |
695 | 607 | |
696 | - if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) ) |
|
697 | - { |
|
608 | + if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) ) { |
|
698 | 609 | $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]); |
699 | 610 | |
700 | - if ( $this->Links != "" ) |
|
701 | - { |
|
611 | + if ( $this->Links != "" ) { |
|
702 | 612 | if ( isset($this->Links[$Key][$NodeID]["R"]) ) |
703 | 613 | { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"],"G"=>$this->Links[$Key][$NodeID]["G"],"B"=>$this->Links[$Key][$NodeID]["B"],"Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); } |
704 | 614 | |
@@ -711,10 +621,8 @@ discard block |
||
711 | 621 | $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color); |
712 | 622 | $Drawn[$Key][$NodeID] = TRUE; |
713 | 623 | |
714 | - if ( isset($this->Links) && $this->Links != "" ) |
|
715 | - { |
|
716 | - if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) ) |
|
717 | - { |
|
624 | + if ( isset($this->Links) && $this->Links != "" ) { |
|
625 | + if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) ) { |
|
718 | 626 | $Name = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"]; |
719 | 627 | $TxtX = ($X2 - $X)/2 + $X; |
720 | 628 | $TxtY = ($Y2 - $Y)/2 + $Y; |
@@ -736,10 +644,8 @@ discard block |
||
736 | 644 | } |
737 | 645 | |
738 | 646 | /* Draw the quiet zones */ |
739 | - if ( $DrawQuietZone ) |
|
740 | - { |
|
741 | - foreach($this->Data as $Key => $Settings) |
|
742 | - { |
|
647 | + if ( $DrawQuietZone ) { |
|
648 | + foreach($this->Data as $Key => $Settings) { |
|
743 | 649 | $X = $Settings["X"]; |
744 | 650 | $Y = $Settings["Y"]; |
745 | 651 | $FreeZone = $Settings["FreeZone"]; |
@@ -750,8 +656,7 @@ discard block |
||
750 | 656 | |
751 | 657 | |
752 | 658 | /* Draw the nodes */ |
753 | - foreach($this->Data as $Key => $Settings) |
|
754 | - { |
|
659 | + foreach($this->Data as $Key => $Settings) { |
|
755 | 660 | $X = $Settings["X"]; |
756 | 661 | $Y = $Settings["Y"]; |
757 | 662 | $Name = $Settings["Name"]; |
@@ -761,35 +666,26 @@ discard block |
||
761 | 666 | |
762 | 667 | $Color = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]); |
763 | 668 | |
764 | - if ( $Shape == NODE_SHAPE_CIRCLE ) |
|
765 | - { |
|
669 | + if ( $Shape == NODE_SHAPE_CIRCLE ) { |
|
766 | 670 | $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color); |
767 | - } |
|
768 | - elseif ( $Shape == NODE_SHAPE_TRIANGLE ) |
|
769 | - { |
|
671 | + } elseif ( $Shape == NODE_SHAPE_TRIANGLE ) { |
|
770 | 672 | $Points = ""; |
771 | 673 | $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y; |
772 | 674 | $Points[] = cos(deg2rad(45)) * $Size + $X; $Points[] = sin(deg2rad(45)) * $Size + $Y; |
773 | 675 | $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y; |
774 | 676 | $this->pChartObject->drawPolygon($Points,$Color); |
775 | - } |
|
776 | - elseif ( $Shape == NODE_SHAPE_SQUARE ) |
|
777 | - { |
|
677 | + } elseif ( $Shape == NODE_SHAPE_SQUARE ) { |
|
778 | 678 | $Offset = $Size/2; $Size = $Size / 2; |
779 | 679 | $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color); |
780 | 680 | } |
781 | 681 | |
782 | - if ( $Name != "" ) |
|
783 | - { |
|
682 | + if ( $Name != "" ) { |
|
784 | 683 | $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]); |
785 | 684 | |
786 | - if ( $this->Labels["Type"] == LABEL_LIGHT ) |
|
787 | - { |
|
685 | + if ( $this->Labels["Type"] == LABEL_LIGHT ) { |
|
788 | 686 | $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT; |
789 | 687 | $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions); |
790 | - } |
|
791 | - elseif ( $this->Labels["Type"] == LABEL_CLASSIC ) |
|
792 | - { |
|
688 | + } elseif ( $this->Labels["Type"] == LABEL_CLASSIC ) { |
|
793 | 689 | $LabelOptions["Align"] = TEXT_ALIGN_TOPMIDDLE; |
794 | 690 | $LabelOptions["DrawBox"] = TRUE; |
795 | 691 | $LabelOptions["BoxAlpha"] = 50; |
@@ -804,17 +700,13 @@ discard block |
||
804 | 700 | } |
805 | 701 | |
806 | 702 | /* Draw the vectors */ |
807 | - if ( $DrawVectors ) |
|
808 | - { |
|
809 | - foreach($this->Data as $Key => $Settings) |
|
810 | - { |
|
703 | + if ( $DrawVectors ) { |
|
704 | + foreach($this->Data as $Key => $Settings) { |
|
811 | 705 | $X1 = $Settings["X"]; |
812 | 706 | $Y1 = $Settings["Y"]; |
813 | 707 | |
814 | - if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL ) |
|
815 | - { |
|
816 | - foreach($Settings["Vectors"] as $ID => $Vector) |
|
817 | - { |
|
708 | + if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL ) { |
|
709 | + foreach($Settings["Vectors"] as $ID => $Vector) { |
|
818 | 710 | $Type = $Vector["Type"]; |
819 | 711 | $Force = $Vector["Force"]; |
820 | 712 | $Angle = $Vector["Angle"]; |
@@ -838,14 +730,12 @@ discard block |
||
838 | 730 | { return (sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1))); } |
839 | 731 | |
840 | 732 | /* Return the angle made by a line and the X axis */ |
841 | - function getAngle($X1,$Y1,$X2,$Y2) |
|
842 | - { |
|
733 | + function getAngle($X1,$Y1,$X2,$Y2) { |
|
843 | 734 | $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent)); |
844 | 735 | if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); } |
845 | 736 | } |
846 | 737 | |
847 | - function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) |
|
848 | - { |
|
738 | + function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) { |
|
849 | 739 | $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4)); |
850 | 740 | $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2)); |
851 | 741 | |
@@ -856,8 +746,7 @@ discard block |
||
856 | 746 | if ( $C == 0 ) { return(FALSE); } |
857 | 747 | $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C); |
858 | 748 | |
859 | - if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4)) |
|
860 | - { |
|
749 | + if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4)) { |
|
861 | 750 | if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4)) |
862 | 751 | { return(TRUE); } |
863 | 752 | } |
@@ -29,15 +29,13 @@ discard block |
||
29 | 29 | define("PIE_VALUE_OUTSIDE" , 140031); |
30 | 30 | |
31 | 31 | /* pPie class definition */ |
32 | - class pPie |
|
33 | - { |
|
32 | + class pPie { |
|
34 | 33 | var $pChartObject; |
35 | 34 | var $pDataObject; |
36 | 35 | var $LabelPos = "" ; |
37 | 36 | |
38 | 37 | /* Class creator */ |
39 | - function pPie($Object,$pDataObject) |
|
40 | - { |
|
38 | + function pPie($Object,$pDataObject) { |
|
41 | 39 | /* Cache the pChart object reference */ |
42 | 40 | $this->pChartObject = $Object; |
43 | 41 | |
@@ -46,8 +44,7 @@ discard block |
||
46 | 44 | } |
47 | 45 | |
48 | 46 | /* Draw a pie chart */ |
49 | - function draw2DPie($X,$Y,$Format="") |
|
50 | - { |
|
47 | + function draw2DPie($X,$Y,$Format="") { |
|
51 | 48 | $Radius = isset($Format["Radius"]) ? $Format["Radius"] : 60; |
52 | 49 | $Precision = isset($Format["Precision"]) ? $Format["Precision"] : 0; |
53 | 50 | $DataGapAngle = isset($Format["DataGapAngle"]) ? $Format["DataGapAngle"] : 0; |
@@ -111,8 +108,7 @@ discard block |
||
111 | 108 | $ScaleFactor = (360 - $WastedAngular) / $SerieSum; |
112 | 109 | |
113 | 110 | $RestoreShadow = $this->pChartObject->Shadow; |
114 | - if ( $this->pChartObject->Shadow ) |
|
115 | - { |
|
111 | + if ( $this->pChartObject->Shadow ) { |
|
116 | 112 | $this->pChartObject->Shadow = FALSE; |
117 | 113 | |
118 | 114 | $ShadowFormat = $Format; $ShadowFormat["Shadow"] = TRUE; |
@@ -122,18 +118,15 @@ discard block |
||
122 | 118 | /* Draw the polygon pie elements */ |
123 | 119 | $Step = 360 / (2 * PI * $Radius); |
124 | 120 | $Offset = 0; $ID = 0; |
125 | - foreach($Values as $Key => $Value) |
|
126 | - { |
|
121 | + foreach($Values as $Key => $Value) { |
|
127 | 122 | if ( $Shadow ) |
128 | 123 | $Settings = array("R"=>$this->pChartObject->ShadowR,"G"=>$this->pChartObject->ShadowG,"B"=>$this->pChartObject->ShadowB,"Alpha"=>$this->pChartObject->Shadowa); |
129 | - else |
|
130 | - { |
|
124 | + else { |
|
131 | 125 | if ( !isset($Palette[$ID]["R"]) ) { $Color = $this->pChartObject->getRandomColor(); $Palette[$ID] = $Color; $this->pDataObject->savePalette($ID,$Color); } |
132 | 126 | $Settings = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]); |
133 | 127 | } |
134 | 128 | |
135 | - if ( !$SecondPass && !$Shadow ) |
|
136 | - { |
|
129 | + if ( !$SecondPass && !$Shadow ) { |
|
137 | 130 | if ( !$Border ) |
138 | 131 | $Settings["Surrounding"] = 10; |
139 | 132 | else |
@@ -145,9 +138,7 @@ discard block |
||
145 | 138 | |
146 | 139 | $Angle = ($EndAngle - $Offset)/2 + $Offset; |
147 | 140 | if ($DataGapAngle == 0) |
148 | - { $X0 = $X; $Y0 = $Y; } |
|
149 | - else |
|
150 | - { |
|
141 | + { $X0 = $X; $Y0 = $Y; } else { |
|
151 | 142 | $X0 = cos(($Angle-90)*PI/180) * $DataGapRadius + $X; |
152 | 143 | $Y0 = sin(($Angle-90)*PI/180) * $DataGapRadius + $Y; |
153 | 144 | } |
@@ -155,8 +146,7 @@ discard block |
||
155 | 146 | $Plots[] = $X0; $Plots[] = $Y0; |
156 | 147 | |
157 | 148 | |
158 | - for($i=$Offset;$i<=$EndAngle;$i=$i+$Step) |
|
159 | - { |
|
149 | + for($i=$Offset;$i<=$EndAngle;$i=$i+$Step) { |
|
160 | 150 | $Xc = cos(($i-90)*PI/180) * $Radius + $X; |
161 | 151 | $Yc = sin(($i-90)*PI/180) * $Radius + $Y; |
162 | 152 | |
@@ -170,11 +160,9 @@ discard block |
||
170 | 160 | $this->pChartObject->drawPolygon($Plots,$Settings); |
171 | 161 | if ( $RecordImageMap && !$Shadow ) { $this->pChartObject->addToImageMap("POLY",$this->arraySerialize($Plots),$this->pChartObject->toHTMLColor($Palette[$ID]["R"],$Palette[$ID]["G"],$Palette[$ID]["B"]),$Data["Series"][$Data["Abscissa"]]["Data"][$Key],$Value); } |
172 | 162 | |
173 | - if ( $DrawLabels && !$Shadow && !$SecondPass ) |
|
174 | - { |
|
163 | + if ( $DrawLabels && !$Shadow && !$SecondPass ) { |
|
175 | 164 | if ( $LabelColor == PIE_LABEL_COLOR_AUTO ) |
176 | - { $Settings = array("FillR"=>$Palette[$ID]["R"],"FillG"=>$Palette[$ID]["G"],"FillB"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);} |
|
177 | - else |
|
165 | + { $Settings = array("FillR"=>$Palette[$ID]["R"],"FillG"=>$Palette[$ID]["G"],"FillB"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);} else |
|
178 | 166 | { $Settings = array("FillR"=>$LabelR,"FillG"=>$LabelG,"FillB"=>$LabelB,"Alpha"=>$LabelAlpha); } |
179 | 167 | |
180 | 168 | $Angle = ($EndAngle - $Offset)/2 + $Offset; |
@@ -193,17 +181,14 @@ discard block |
||
193 | 181 | } |
194 | 182 | |
195 | 183 | /* Second pass to smooth the angles */ |
196 | - if ( $SecondPass ) |
|
197 | - { |
|
184 | + if ( $SecondPass ) { |
|
198 | 185 | $Step = 360 / (2 * PI * $Radius); |
199 | 186 | $Offset = 0; $ID = 0; |
200 | - foreach($Values as $Key => $Value) |
|
201 | - { |
|
187 | + foreach($Values as $Key => $Value) { |
|
202 | 188 | $FirstPoint = TRUE; |
203 | 189 | if ( $Shadow ) |
204 | 190 | $Settings = array("R"=>$this->pChartObject->ShadowR,"G"=>$this->pChartObject->ShadowG,"B"=>$this->pChartObject->ShadowB,"Alpha"=>$this->pChartObject->Shadowa); |
205 | - else |
|
206 | - { |
|
191 | + else { |
|
207 | 192 | if ( $Border ) |
208 | 193 | $Settings = array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB); |
209 | 194 | else |
@@ -213,17 +198,14 @@ discard block |
||
213 | 198 | $EndAngle = $Offset+($Value*$ScaleFactor); if ( $EndAngle > 360 ) { $EndAngle = 360; } |
214 | 199 | |
215 | 200 | if ($DataGapAngle == 0) |
216 | - { $X0 = $X; $Y0 = $Y; } |
|
217 | - else |
|
218 | - { |
|
201 | + { $X0 = $X; $Y0 = $Y; } else { |
|
219 | 202 | $Angle = ($EndAngle - $Offset)/2 + $Offset; |
220 | 203 | $X0 = cos(($Angle-90)*PI/180) * $DataGapRadius + $X; |
221 | 204 | $Y0 = sin(($Angle-90)*PI/180) * $DataGapRadius + $Y; |
222 | 205 | } |
223 | 206 | $Plots[] = $X0; $Plots[] = $Y0; |
224 | 207 | |
225 | - for($i=$Offset;$i<=$EndAngle;$i=$i+$Step) |
|
226 | - { |
|
208 | + for($i=$Offset;$i<=$EndAngle;$i=$i+$Step) { |
|
227 | 209 | $Xc = cos(($i-90)*PI/180) * $Radius + $X; |
228 | 210 | $Yc = sin(($i-90)*PI/180) * $Radius + $Y; |
229 | 211 | |
@@ -233,11 +215,9 @@ discard block |
||
233 | 215 | } |
234 | 216 | $this->pChartObject->drawLine($Xc,$Yc,$X0,$Y0,$Settings); |
235 | 217 | |
236 | - if ( $DrawLabels && !$Shadow ) |
|
237 | - { |
|
218 | + if ( $DrawLabels && !$Shadow ) { |
|
238 | 219 | if ( $LabelColor == PIE_LABEL_COLOR_AUTO ) |
239 | - { $Settings = array("FillR"=>$Palette[$ID]["R"],"FillG"=>$Palette[$ID]["G"],"FillB"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);} |
|
240 | - else |
|
220 | + { $Settings = array("FillR"=>$Palette[$ID]["R"],"FillG"=>$Palette[$ID]["G"],"FillB"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);} else |
|
241 | 221 | { $Settings = array("FillR"=>$LabelR,"FillG"=>$LabelG,"FillB"=>$LabelB,"Alpha"=>$LabelAlpha); } |
242 | 222 | |
243 | 223 | $Angle = ($EndAngle - $Offset)/2 + $Offset; |
@@ -256,23 +236,18 @@ discard block |
||
256 | 236 | } |
257 | 237 | } |
258 | 238 | |
259 | - if ( $WriteValues != NULL && !$Shadow ) |
|
260 | - { |
|
239 | + if ( $WriteValues != NULL && !$Shadow ) { |
|
261 | 240 | $Step = 360 / (2 * PI * $Radius); |
262 | 241 | $Offset = 0; $ID = count($Values)-1; |
263 | 242 | $Settings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"R"=>$ValueR,"G"=>$ValueG,"B"=>$ValueB,"Alpha"=>$ValueAlpha); |
264 | - foreach($Values as $Key => $Value) |
|
265 | - { |
|
243 | + foreach($Values as $Key => $Value) { |
|
266 | 244 | $EndAngle = ($Value*$ScaleFactor) + $Offset; if ( $EndAngle > 360 ) { $EndAngle = 0; } |
267 | 245 | $Angle = ($EndAngle - $Offset)/2 + $Offset; |
268 | 246 | |
269 | - if ( $ValuePosition == PIE_VALUE_OUTSIDE ) |
|
270 | - { |
|
247 | + if ( $ValuePosition == PIE_VALUE_OUTSIDE ) { |
|
271 | 248 | $Xc = cos(($Angle-90)*PI/180) * ($Radius+$ValuePadding) + $X; |
272 | 249 | $Yc = sin(($Angle-90)*PI/180) * ($Radius+$ValuePadding) + $Y; |
273 | - } |
|
274 | - else |
|
275 | - { |
|
250 | + } else { |
|
276 | 251 | $Xc = cos(($Angle-90)*PI/180) * ($Radius)/2 + $X; |
277 | 252 | $Yc = sin(($Angle-90)*PI/180) * ($Radius)/2 + $Y; |
278 | 253 | } |
@@ -296,8 +271,7 @@ discard block |
||
296 | 271 | } |
297 | 272 | |
298 | 273 | /* Draw a 3D pie chart */ |
299 | - function draw3DPie($X,$Y,$Format="") |
|
300 | - { |
|
274 | + function draw3DPie($X,$Y,$Format="") { |
|
301 | 275 | /* Rendering layout */ |
302 | 276 | $Radius = isset($Format["Radius"]) ? $Format["Radius"] : 80; |
303 | 277 | $Precision = isset($Format["Precision"]) ? $Format["Precision"] : 0; |
@@ -371,8 +345,7 @@ discard block |
||
371 | 345 | $Offset = 360; $ID = count($Values)-1; |
372 | 346 | $Values = array_reverse($Values); |
373 | 347 | $Slice = 0; $Slices = ""; $SliceColors = ""; $Visible = ""; $SliceAngle = ""; |
374 | - foreach($Values as $Key => $Value) |
|
375 | - { |
|
348 | + foreach($Values as $Key => $Value) { |
|
376 | 349 | if ( !isset($Palette[$ID]["R"]) ) { $Color = $this->pChartObject->getRandomColor(); $Palette[$ID] = $Color; $this->pDataObject->savePalette($ID,$Color); } |
377 | 350 | $Settings = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]); |
378 | 351 | |
@@ -385,17 +358,14 @@ discard block |
||
385 | 358 | if ( $EndAngle < 180 ) { $Visible[$Slice]["End"] = FALSE; } else { $Visible[$Slice]["End"] = TRUE; } |
386 | 359 | |
387 | 360 | if ($DataGapAngle == 0) |
388 | - { $X0 = $X; $Y0 = $Y; } |
|
389 | - else |
|
390 | - { |
|
361 | + { $X0 = $X; $Y0 = $Y; } else { |
|
391 | 362 | $Angle = ($EndAngle - $Offset)/2 + $Offset; |
392 | 363 | $X0 = cos(($Angle-90)*PI/180) * $DataGapRadius + $X; |
393 | 364 | $Y0 = sin(($Angle-90)*PI/180) * $DataGapRadius*$SkewFactor + $Y; |
394 | 365 | } |
395 | 366 | $Slices[$Slice][] = $X0; $Slices[$Slice][] = $Y0; $SliceAngle[$Slice][] = 0; |
396 | 367 | |
397 | - for($i=$Offset;$i>=$EndAngle;$i=$i-$Step) |
|
398 | - { |
|
368 | + for($i=$Offset;$i>=$EndAngle;$i=$i-$Step) { |
|
399 | 369 | $Xc = cos(($i-90)*PI/180) * $Radius + $X; |
400 | 370 | $Yc = sin(($i-90)*PI/180) * $Radius*$SkewFactor + $Y; |
401 | 371 | |
@@ -411,10 +381,8 @@ discard block |
||
411 | 381 | } |
412 | 382 | |
413 | 383 | /* Draw the bottom shadow if needed */ |
414 | - if ( $RestoreShadow && ($this->pChartObject->ShadowX != 0 || $this->pChartObject->ShadowY !=0 )) |
|
415 | - { |
|
416 | - foreach($Slices as $SliceID => $Plots) |
|
417 | - { |
|
384 | + if ( $RestoreShadow && ($this->pChartObject->ShadowX != 0 || $this->pChartObject->ShadowY !=0 )) { |
|
385 | + foreach($Slices as $SliceID => $Plots) { |
|
418 | 386 | $ShadowPie = ""; |
419 | 387 | for($i=0;$i<count($Plots);$i=$i+2) |
420 | 388 | { $ShadowPie[] = $Plots[$i]+$this->pChartObject->ShadowX; $ShadowPie[] = $Plots[$i+1]+$this->pChartObject->ShadowY; } |
@@ -425,12 +393,10 @@ discard block |
||
425 | 393 | |
426 | 394 | $Step = 360 / (2 * PI * $Radius); |
427 | 395 | $Offset = 360; |
428 | - foreach($Values as $Key => $Value) |
|
429 | - { |
|
396 | + foreach($Values as $Key => $Value) { |
|
430 | 397 | $EndAngle = $Offset-($Value*$ScaleFactor); if ( $EndAngle < 0 ) { $EndAngle = 0; } |
431 | 398 | |
432 | - for($i=$Offset;$i>=$EndAngle;$i=$i-$Step) |
|
433 | - { |
|
399 | + for($i=$Offset;$i>=$EndAngle;$i=$i-$Step) { |
|
434 | 400 | $Xc = cos(($i-90)*PI/180) * $Radius + $X + $this->pChartObject->ShadowX; |
435 | 401 | $Yc = sin(($i-90)*PI/180) * $Radius*$SkewFactor + $Y + $this->pChartObject->ShadowY; |
436 | 402 | |
@@ -442,13 +408,11 @@ discard block |
||
442 | 408 | } |
443 | 409 | |
444 | 410 | /* Draw the bottom pie splice */ |
445 | - foreach($Slices as $SliceID => $Plots) |
|
446 | - { |
|
411 | + foreach($Slices as $SliceID => $Plots) { |
|
447 | 412 | $Settings = $SliceColors[$SliceID]; $Settings["NoBorder"] = TRUE; |
448 | 413 | $this->pChartObject->drawPolygon($Plots,$Settings); |
449 | 414 | |
450 | - if ( $SecondPass ) |
|
451 | - { |
|
415 | + if ( $SecondPass ) { |
|
452 | 416 | $Settings = $SliceColors[$SliceID]; |
453 | 417 | if ( $Border ) |
454 | 418 | { $Settings["R"]+= 30; $Settings["G"]+= 30; $Settings["B"]+= 30;; } |
@@ -471,8 +435,7 @@ discard block |
||
471 | 435 | /* Draw the two vertical edges */ |
472 | 436 | $Slices = array_reverse($Slices); |
473 | 437 | $SliceColors = array_reverse($SliceColors); |
474 | - foreach($Slices as $SliceID => $Plots) |
|
475 | - { |
|
438 | + foreach($Slices as $SliceID => $Plots) { |
|
476 | 439 | $Settings = $SliceColors[$SliceID]; |
477 | 440 | $Settings["R"]+= 10; $Settings["G"]+= 10; $Settings["B"]+= 10; $Settings["NoBorder"] = TRUE; |
478 | 441 | |
@@ -488,12 +451,10 @@ discard block |
||
488 | 451 | |
489 | 452 | $Slices = array_reverse($Slices); |
490 | 453 | $SliceColors = array_reverse($SliceColors); |
491 | - foreach($Slices as $SliceID => $Plots) |
|
492 | - { |
|
454 | + foreach($Slices as $SliceID => $Plots) { |
|
493 | 455 | $Settings = $SliceColors[$SliceID]; |
494 | 456 | $Settings["R"]+= 10; $Settings["G"]+= 10; $Settings["B"]+= 10; $Settings["NoBorder"] = TRUE; |
495 | - if ( $Visible[$SliceID]["End"] ) |
|
496 | - { |
|
457 | + if ( $Visible[$SliceID]["End"] ) { |
|
497 | 458 | $this->pChartObject->drawLine($Plots[count($Plots)-2],$Plots[count($Plots)-1],$Plots[count($Plots)-2],$Plots[count($Plots)-1]- $SliceHeight,array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"])); |
498 | 459 | |
499 | 460 | $Border = ""; |
@@ -504,16 +465,13 @@ discard block |
||
504 | 465 | } |
505 | 466 | |
506 | 467 | /* Draw the rounded edges */ |
507 | - foreach($Slices as $SliceID => $Plots) |
|
508 | - { |
|
468 | + foreach($Slices as $SliceID => $Plots) { |
|
509 | 469 | $Settings = $SliceColors[$SliceID]; |
510 | 470 | $Settings["R"]+= 10; $Settings["G"]+= 10; $Settings["B"]+= 10; $Settings["NoBorder"] = TRUE; |
511 | 471 | |
512 | - for ($j=2;$j<count($Plots)-2;$j=$j+2) |
|
513 | - { |
|
472 | + for ($j=2;$j<count($Plots)-2;$j=$j+2) { |
|
514 | 473 | $Angle = $SliceAngle[$SliceID][$j/2]; |
515 | - if ( $Angle < 270 && $Angle > 90 ) |
|
516 | - { |
|
474 | + if ( $Angle < 270 && $Angle > 90 ) { |
|
517 | 475 | $Border = ""; |
518 | 476 | $Border[] = $Plots[$j]; $Border[] = $Plots[$j+1]; |
519 | 477 | $Border[] = $Plots[$j+2]; $Border[] = $Plots[$j+3]; |
@@ -523,8 +481,7 @@ discard block |
||
523 | 481 | } |
524 | 482 | } |
525 | 483 | |
526 | - if ( $SecondPass ) |
|
527 | - { |
|
484 | + if ( $SecondPass ) { |
|
528 | 485 | $Settings = $SliceColors[$SliceID]; |
529 | 486 | if ( $Border ) |
530 | 487 | { $Settings["R"]+= 30; $Settings["G"]+= 30; $Settings["B"]+= 30; } |
@@ -532,8 +489,7 @@ discard block |
||
532 | 489 | if ( isset($SliceAngle[$SliceID][1]) ) /* Empty error handling */ |
533 | 490 | { |
534 | 491 | $Angle = $SliceAngle[$SliceID][1]; |
535 | - if ( $Angle < 270 && $Angle > 90 ) |
|
536 | - { |
|
492 | + if ( $Angle < 270 && $Angle > 90 ) { |
|
537 | 493 | $Xc = cos(($Angle-90)*PI/180) * $Radius + $X; |
538 | 494 | $Yc = sin(($Angle-90)*PI/180) * $Radius*$SkewFactor + $Y; |
539 | 495 | $this->pChartObject->drawLine($Xc,$Yc,$Xc,$Yc-$SliceHeight,$Settings); |
@@ -541,22 +497,19 @@ discard block |
||
541 | 497 | } |
542 | 498 | |
543 | 499 | $Angle = $SliceAngle[$SliceID][count($SliceAngle[$SliceID])-1]; |
544 | - if ( $Angle < 270 && $Angle > 90 ) |
|
545 | - { |
|
500 | + if ( $Angle < 270 && $Angle > 90 ) { |
|
546 | 501 | $Xc = cos(($Angle-90)*PI/180) * $Radius + $X; |
547 | 502 | $Yc = sin(($Angle-90)*PI/180) * $Radius*$SkewFactor + $Y; |
548 | 503 | $this->pChartObject->drawLine($Xc,$Yc,$Xc,$Yc-$SliceHeight,$Settings); |
549 | 504 | } |
550 | 505 | |
551 | - if ( isset($SliceAngle[$SliceID][1]) && $SliceAngle[$SliceID][1] > 270 && $SliceAngle[$SliceID][count($SliceAngle[$SliceID])-1] < 270 ) |
|
552 | - { |
|
506 | + if ( isset($SliceAngle[$SliceID][1]) && $SliceAngle[$SliceID][1] > 270 && $SliceAngle[$SliceID][count($SliceAngle[$SliceID])-1] < 270 ) { |
|
553 | 507 | $Xc = cos((270-90)*PI/180) * $Radius + $X; |
554 | 508 | $Yc = sin((270-90)*PI/180) * $Radius*$SkewFactor + $Y; |
555 | 509 | $this->pChartObject->drawLine($Xc,$Yc,$Xc,$Yc-$SliceHeight,$Settings); |
556 | 510 | } |
557 | 511 | |
558 | - if ( isset($SliceAngle[$SliceID][1]) && $SliceAngle[$SliceID][1] > 90 && $SliceAngle[$SliceID][count($SliceAngle[$SliceID])-1] < 90 ) |
|
559 | - { |
|
512 | + if ( isset($SliceAngle[$SliceID][1]) && $SliceAngle[$SliceID][1] > 90 && $SliceAngle[$SliceID][count($SliceAngle[$SliceID])-1] < 90 ) { |
|
560 | 513 | $Xc = cos((0)*PI/180) * $Radius + $X; |
561 | 514 | $Yc = sin((0)*PI/180) * $Radius*$SkewFactor + $Y; |
562 | 515 | $this->pChartObject->drawLine($Xc,$Yc,$Xc,$Yc-$SliceHeight,$Settings); |
@@ -566,8 +519,7 @@ discard block |
||
566 | 519 | } |
567 | 520 | |
568 | 521 | /* Draw the top splice */ |
569 | - foreach($Slices as $SliceID => $Plots) |
|
570 | - { |
|
522 | + foreach($Slices as $SliceID => $Plots) { |
|
571 | 523 | $Settings = $SliceColors[$SliceID]; |
572 | 524 | $Settings["R"]+= 20; $Settings["G"]+= 20; $Settings["B"]+= 20; |
573 | 525 | |
@@ -580,37 +532,30 @@ discard block |
||
580 | 532 | |
581 | 533 | |
582 | 534 | /* Second pass to smooth the angles */ |
583 | - if ( $SecondPass ) |
|
584 | - { |
|
535 | + if ( $SecondPass ) { |
|
585 | 536 | $Step = 360 / (2 * PI * $Radius); |
586 | 537 | $Offset = 360; $ID = count($Values)-1; |
587 | - foreach($Values as $Key => $Value) |
|
588 | - { |
|
538 | + foreach($Values as $Key => $Value) { |
|
589 | 539 | $FirstPoint = TRUE; |
590 | 540 | if ( $Shadow ) |
591 | 541 | $Settings = array("R"=>$this->pChartObject->ShadowR,"G"=>$this->pChartObject->ShadowG,"B"=>$this->pChartObject->ShadowB,"Alpha"=>$this->pChartObject->Shadowa); |
592 | - else |
|
593 | - { |
|
542 | + else { |
|
594 | 543 | if ( $Border ) |
595 | - { $Settings = array("R"=>$Palette[$ID]["R"]+30,"G"=>$Palette[$ID]["G"]+30,"B"=>$Palette[$ID]["B"]+30,"Alpha"=>$Palette[$ID]["Alpha"]); } |
|
596 | - else |
|
544 | + { $Settings = array("R"=>$Palette[$ID]["R"]+30,"G"=>$Palette[$ID]["G"]+30,"B"=>$Palette[$ID]["B"]+30,"Alpha"=>$Palette[$ID]["Alpha"]); } else |
|
597 | 545 | $Settings = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]); |
598 | 546 | } |
599 | 547 | |
600 | 548 | $EndAngle = $Offset-($Value*$ScaleFactor); if ( $EndAngle < 0 ) { $EndAngle = 0; } |
601 | 549 | |
602 | 550 | if ($DataGapAngle == 0) |
603 | - { $X0 = $X; $Y0 = $Y- $SliceHeight; } |
|
604 | - else |
|
605 | - { |
|
551 | + { $X0 = $X; $Y0 = $Y- $SliceHeight; } else { |
|
606 | 552 | $Angle = ($EndAngle - $Offset)/2 + $Offset; |
607 | 553 | $X0 = cos(($Angle-90)*PI/180) * $DataGapRadius + $X; |
608 | 554 | $Y0 = sin(($Angle-90)*PI/180) * $DataGapRadius*$SkewFactor + $Y - $SliceHeight; |
609 | 555 | } |
610 | 556 | $Plots[] = $X0; $Plots[] = $Y0; |
611 | 557 | |
612 | - for($i=$Offset;$i>=$EndAngle;$i=$i-$Step) |
|
613 | - { |
|
558 | + for($i=$Offset;$i>=$EndAngle;$i=$i-$Step) { |
|
614 | 559 | $Xc = cos(($i-90)*PI/180) * $Radius + $X; |
615 | 560 | $Yc = sin(($i-90)*PI/180) * $Radius*$SkewFactor + $Y - $SliceHeight; |
616 | 561 | |
@@ -625,24 +570,19 @@ discard block |
||
625 | 570 | } |
626 | 571 | } |
627 | 572 | |
628 | - if ( $WriteValues != NULL ) |
|
629 | - { |
|
573 | + if ( $WriteValues != NULL ) { |
|
630 | 574 | $Step = 360 / (2 * PI * $Radius); |
631 | 575 | $Offset = 360; $ID = count($Values)-1; |
632 | 576 | $Settings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"R"=>$ValueR,"G"=>$ValueG,"B"=>$ValueB,"Alpha"=>$ValueAlpha); |
633 | - foreach($Values as $Key => $Value) |
|
634 | - { |
|
577 | + foreach($Values as $Key => $Value) { |
|
635 | 578 | $EndAngle = $Offset-($Value*$ScaleFactor); if ( $EndAngle < 0 ) { $EndAngle = 0; } |
636 | 579 | |
637 | 580 | $Angle = ($EndAngle - $Offset)/2 + $Offset; |
638 | 581 | |
639 | - if ( $ValuePosition == PIE_VALUE_OUTSIDE ) |
|
640 | - { |
|
582 | + if ( $ValuePosition == PIE_VALUE_OUTSIDE ) { |
|
641 | 583 | $Xc = cos(($Angle-90)*PI/180) * ($Radius+$ValuePadding) + $X; |
642 | 584 | $Yc = sin(($Angle-90)*PI/180) * (($Radius*$SkewFactor)+$ValuePadding) + $Y - $SliceHeight; |
643 | - } |
|
644 | - else |
|
645 | - { |
|
585 | + } else { |
|
646 | 586 | $Xc = cos(($Angle-90)*PI/180) * ($Radius)/2 + $X; |
647 | 587 | $Yc = sin(($Angle-90)*PI/180) * ($Radius*$SkewFactor)/2 + $Y - $SliceHeight; |
648 | 588 | } |
@@ -658,15 +598,12 @@ discard block |
||
658 | 598 | } |
659 | 599 | } |
660 | 600 | |
661 | - if ( $DrawLabels ) |
|
662 | - { |
|
601 | + if ( $DrawLabels ) { |
|
663 | 602 | $Step = 360 / (2 * PI * $Radius); |
664 | 603 | $Offset = 360; $ID = count($Values)-1; |
665 | - foreach($Values as $Key => $Value) |
|
666 | - { |
|
604 | + foreach($Values as $Key => $Value) { |
|
667 | 605 | if ( $LabelColor == PIE_LABEL_COLOR_AUTO ) |
668 | - { $Settings = array("FillR"=>$Palette[$ID]["R"],"FillG"=>$Palette[$ID]["G"],"FillB"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);} |
|
669 | - else |
|
606 | + { $Settings = array("FillR"=>$Palette[$ID]["R"],"FillG"=>$Palette[$ID]["G"],"FillB"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);} else |
|
670 | 607 | { $Settings = array("FillR"=>$LabelR,"FillG"=>$LabelG,"FillB"=>$LabelB,"Alpha"=>$LabelAlpha); } |
671 | 608 | |
672 | 609 | $EndAngle = $Offset-($Value*$ScaleFactor); if ( $EndAngle < 0 ) { $EndAngle = 0; } |
@@ -675,8 +612,7 @@ discard block |
||
675 | 612 | $Xc = cos(($Angle-90)*PI/180) * $Radius + $X; |
676 | 613 | $Yc = sin(($Angle-90)*PI/180) * $Radius*$SkewFactor + $Y - $SliceHeight; |
677 | 614 | |
678 | - if ( isset($Data["Series"][$Data["Abscissa"]]["Data"][$ID]) ) |
|
679 | - { |
|
615 | + if ( isset($Data["Series"][$Data["Abscissa"]]["Data"][$ID]) ) { |
|
680 | 616 | $Label = $Data["Series"][$Data["Abscissa"]]["Data"][$ID]; |
681 | 617 | |
682 | 618 | if ( $LabelStacked ) |
@@ -697,8 +633,7 @@ discard block |
||
697 | 633 | } |
698 | 634 | |
699 | 635 | /* Draw the legend of pie chart */ |
700 | - function drawPieLegend($X,$Y,$Format="") |
|
701 | - { |
|
636 | + function drawPieLegend($X,$Y,$Format="") { |
|
702 | 637 | $FontName = isset($Format["FontName"]) ? $Format["FontName"] : $this->pChartObject->FontName; |
703 | 638 | $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->pChartObject->FontSize; |
704 | 639 | $FontR = isset($Format["FontR"]) ? $Format["FontR"] : $this->pChartObject->FontColorR; |
@@ -730,19 +665,15 @@ discard block |
||
730 | 665 | if ( $Data["Abscissa"] == "" ) { return(PIE_NO_ABSCISSA); } |
731 | 666 | |
732 | 667 | $Boundaries = ""; $Boundaries["L"] = $X; $Boundaries["T"] = $Y; $Boundaries["R"] = 0; $Boundaries["B"] = 0; $vY = $Y; $vX = $X; |
733 | - foreach($Data["Series"][$Data["Abscissa"]]["Data"] as $Key => $Value) |
|
734 | - { |
|
668 | + foreach($Data["Series"][$Data["Abscissa"]]["Data"] as $Key => $Value) { |
|
735 | 669 | $BoxArray = $this->pChartObject->getTextBox($vX+$BoxSize+4,$vY+$BoxSize/2,$FontName,$FontSize,0,$Value); |
736 | 670 | |
737 | - if ( $Mode == LEGEND_VERTICAL ) |
|
738 | - { |
|
671 | + if ( $Mode == LEGEND_VERTICAL ) { |
|
739 | 672 | if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$BoxSize/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$BoxSize/2; } |
740 | 673 | if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; } |
741 | 674 | if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$BoxSize/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$BoxSize/2; } |
742 | 675 | $vY=$vY+$YStep; |
743 | - } |
|
744 | - elseif ( $Mode == LEGEND_HORIZONTAL ) |
|
745 | - { |
|
676 | + } elseif ( $Mode == LEGEND_HORIZONTAL ) { |
|
746 | 677 | if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$BoxSize/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$BoxSize/2; } |
747 | 678 | if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; } |
748 | 679 | if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$BoxSize/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$BoxSize/2; } |
@@ -760,19 +691,15 @@ discard block |
||
760 | 691 | $this->pChartObject->drawFilledRectangle($Boundaries["L"]-$Margin,$Boundaries["T"]-$Margin,$Boundaries["R"]+$Margin,$Boundaries["B"]+$Margin,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB)); |
761 | 692 | |
762 | 693 | $RestoreShadow = $this->pChartObject->Shadow; $this->pChartObject->Shadow = FALSE; |
763 | - foreach($Data["Series"][$Data["Abscissa"]]["Data"] as $Key => $Value) |
|
764 | - { |
|
694 | + foreach($Data["Series"][$Data["Abscissa"]]["Data"] as $Key => $Value) { |
|
765 | 695 | $R = $Palette[$Key]["R"]; $G = $Palette[$Key]["G"]; $B = $Palette[$Key]["B"]; |
766 | 696 | |
767 | 697 | $this->pChartObject->drawFilledRectangle($X+1,$Y+1,$X+$BoxSize+1,$Y+$BoxSize+1,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20)); |
768 | 698 | $this->pChartObject->drawFilledRectangle($X,$Y,$X+$BoxSize,$Y+$BoxSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Surrounding"=>20)); |
769 | - if ( $Mode == LEGEND_VERTICAL ) |
|
770 | - { |
|
699 | + if ( $Mode == LEGEND_VERTICAL ) { |
|
771 | 700 | $this->pChartObject->drawText($X+$BoxSize+4,$Y+$BoxSize/2,$Value,array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_MIDDLELEFT,"FontName"=>$FontName,"FontSize"=>$FontSize)); |
772 | 701 | $Y=$Y+$YStep; |
773 | - } |
|
774 | - elseif ( $Mode == LEGEND_HORIZONTAL ) |
|
775 | - { |
|
702 | + } elseif ( $Mode == LEGEND_HORIZONTAL ) { |
|
776 | 703 | $BoxArray = $this->pChartObject->drawText($X+$BoxSize+4,$Y+$BoxSize/2,$Value,array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_MIDDLELEFT,"FontName"=>$FontName,"FontSize"=>$FontSize)); |
777 | 704 | $X=$BoxArray[1]["X"]+2+$XStep; |
778 | 705 | } |
@@ -782,8 +709,7 @@ discard block |
||
782 | 709 | } |
783 | 710 | |
784 | 711 | /* Set the color of the specified slice */ |
785 | - function setSliceColor($SliceID,$Format="") |
|
786 | - { |
|
712 | + function setSliceColor($SliceID,$Format="") { |
|
787 | 713 | $R = isset($Format["R"]) ? $Format["R"] : 0; |
788 | 714 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
789 | 715 | $B = isset($Format["B"]) ? $Format["B"] : 0; |
@@ -796,22 +722,18 @@ discard block |
||
796 | 722 | } |
797 | 723 | |
798 | 724 | /* Internally used compute the label positions */ |
799 | - function writePieLabel($X,$Y,$Label,$Angle,$Settings,$Stacked,$Xc=0,$Yc=0,$Radius=0,$Reversed=FALSE) |
|
800 | - { |
|
725 | + function writePieLabel($X,$Y,$Label,$Angle,$Settings,$Stacked,$Xc=0,$Yc=0,$Radius=0,$Reversed=FALSE) { |
|
801 | 726 | $LabelOffset = 30; |
802 | 727 | $FontName = $this->pChartObject->FontName; |
803 | 728 | $FontSize = $this->pChartObject->FontSize; |
804 | 729 | |
805 | - if ( !$Stacked ) |
|
806 | - { |
|
730 | + if ( !$Stacked ) { |
|
807 | 731 | $Settings["Angle"] = 360-$Angle; |
808 | 732 | $Settings["Length"] = 25; |
809 | 733 | $Settings["Size"] = 8; |
810 | 734 | |
811 | 735 | $this->pChartObject->drawArrowLabel($X,$Y," ".$Label." ",$Settings); |
812 | - } |
|
813 | - else |
|
814 | - { |
|
736 | + } else { |
|
815 | 737 | $X2 = cos(deg2rad($Angle-90))*20+$X; |
816 | 738 | $Y2 = sin(deg2rad($Angle-90))*20+$Y; |
817 | 739 | |
@@ -820,13 +742,10 @@ discard block |
||
820 | 742 | $YTop = $Y2 - $Height/2 - 2; |
821 | 743 | $YBottom = $Y2 + $Height/2 + 2; |
822 | 744 | |
823 | - if ( $this->LabelPos != "" ) |
|
824 | - { |
|
745 | + if ( $this->LabelPos != "" ) { |
|
825 | 746 | $Done = FALSE; |
826 | - foreach($this->LabelPos as $Key => $Settings) |
|
827 | - { |
|
828 | - if ( !$Done ) |
|
829 | - { |
|
747 | + foreach($this->LabelPos as $Key => $Settings) { |
|
748 | + if ( !$Done ) { |
|
830 | 749 | if ( $Angle <= 90 && (($YTop >= $Settings["YTop"] && $YTop <= $Settings["YBottom"]) || ($YBottom >= $Settings["YTop"] && $YBottom <= $Settings["YBottom"]))) |
831 | 750 | { $this->shift(0,180,-($Height+2),$Reversed); $Done = TRUE; } |
832 | 751 | if ( $Angle > 90 && $Angle <= 180 && (($YTop >= $Settings["YTop"] && $YTop <= $Settings["YBottom"]) || ($YBottom >= $Settings["YTop"] && $YBottom <= $Settings["YBottom"]))) |
@@ -847,21 +766,17 @@ discard block |
||
847 | 766 | } |
848 | 767 | |
849 | 768 | /* Internally used to shift label positions */ |
850 | - function shift($StartAngle,$EndAngle,$Offset,$Reversed) |
|
851 | - { |
|
769 | + function shift($StartAngle,$EndAngle,$Offset,$Reversed) { |
|
852 | 770 | if ( $Reversed ) { $Offset = -$Offset; } |
853 | - foreach($this->LabelPos as $Key => $Settings) |
|
854 | - { |
|
771 | + foreach($this->LabelPos as $Key => $Settings) { |
|
855 | 772 | if ( $Settings["Angle"] > $StartAngle && $Settings["Angle"] <= $EndAngle ) { $this->LabelPos[$Key]["YTop"] = $Settings["YTop"] + $Offset; $this->LabelPos[$Key]["YBottom"] = $Settings["YBottom"] + $Offset; $this->LabelPos[$Key]["Y2"] = $Settings["Y2"] + $Offset; } |
856 | 773 | } |
857 | 774 | } |
858 | 775 | |
859 | 776 | /* Internally used to write the re-computed labels */ |
860 | - function writeShiftedLabels() |
|
861 | - { |
|
777 | + function writeShiftedLabels() { |
|
862 | 778 | if ( $this->LabelPos == "" ) { return(0); } |
863 | - foreach($this->LabelPos as $Key => $Settings) |
|
864 | - { |
|
779 | + foreach($this->LabelPos as $Key => $Settings) { |
|
865 | 780 | $X1 = $Settings["X1"]; $Y1 = $Settings["Y1"]; |
866 | 781 | $X2 = $Settings["X2"]; $Y2 = $Settings["Y2"]; |
867 | 782 | $X3 = $Settings["X3"]; |
@@ -869,13 +784,10 @@ discard block |
||
869 | 784 | $Label = $Settings["Label"]; |
870 | 785 | |
871 | 786 | $this->pChartObject->drawArrow($X2,$Y2,$X1,$Y1,array("Size"=>8)); |
872 | - if ( $Angle <= 180 ) |
|
873 | - { |
|
787 | + if ( $Angle <= 180 ) { |
|
874 | 788 | $this->pChartObject->drawLine($X2,$Y2,$X3,$Y2); |
875 | 789 | $this->pChartObject->drawText($X3+2,$Y2,$Label,array("Align"=>TEXT_ALIGN_MIDDLELEFT)); |
876 | - } |
|
877 | - else |
|
878 | - { |
|
790 | + } else { |
|
879 | 791 | $this->pChartObject->drawLine($X2,$Y2,$X3,$Y2); |
880 | 792 | $this->pChartObject->drawText($X3-2,$Y2,$Label,array("Align"=>TEXT_ALIGN_MIDDLERIGHT)); |
881 | 793 | } |
@@ -883,8 +795,7 @@ discard block |
||
883 | 795 | } |
884 | 796 | |
885 | 797 | /* Draw a ring chart */ |
886 | - function draw2DRing($X,$Y,$Format="") |
|
887 | - { |
|
798 | + function draw2DRing($X,$Y,$Format="") { |
|
888 | 799 | $OuterRadius = isset($Format["Radius"]) ? $Format["Radius"] : 60; |
889 | 800 | $Precision = isset($Format["Precision"]) ? $Format["Precision"] : 0; |
890 | 801 | $InnerRadius = isset($Format["Radius"]) ? $Format["Radius"] : 30; |
@@ -947,8 +858,7 @@ discard block |
||
947 | 858 | $ScaleFactor = (360 - $WastedAngular) / $SerieSum; |
948 | 859 | |
949 | 860 | $RestoreShadow = $this->pChartObject->Shadow; |
950 | - if ( $this->pChartObject->Shadow ) |
|
951 | - { |
|
861 | + if ( $this->pChartObject->Shadow ) { |
|
952 | 862 | $this->pChartObject->Shadow = FALSE; |
953 | 863 | |
954 | 864 | $ShadowFormat = $Format; $ShadowFormat["Shadow"] = TRUE; |
@@ -958,15 +868,11 @@ discard block |
||
958 | 868 | /* Draw the polygon pie elements */ |
959 | 869 | $Step = 360 / (2 * PI * $OuterRadius); |
960 | 870 | $Offset = 0; $ID = 0; |
961 | - foreach($Values as $Key => $Value) |
|
962 | - { |
|
963 | - if ( $Shadow ) |
|
964 | - { |
|
871 | + foreach($Values as $Key => $Value) { |
|
872 | + if ( $Shadow ) { |
|
965 | 873 | $Settings = array("R"=>$this->pChartObject->ShadowR,"G"=>$this->pChartObject->ShadowG,"B"=>$this->pChartObject->ShadowB,"Alpha"=>$this->pChartObject->Shadowa); |
966 | 874 | $BorderColor = $Settings; |
967 | - } |
|
968 | - else |
|
969 | - { |
|
875 | + } else { |
|
970 | 876 | if ( !isset($Palette[$ID]["R"]) ) { $Color = $this->pChartObject->getRandomColor(); $Palette[$ID] = $Color; $this->pDataObject->savePalette($ID,$Color); } |
971 | 877 | $Settings = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]); |
972 | 878 | |
@@ -978,8 +884,7 @@ discard block |
||
978 | 884 | |
979 | 885 | $Plots = ""; $Boundaries = ""; $AAPixels = ""; |
980 | 886 | $EndAngle = $Offset+($Value*$ScaleFactor); if ( $EndAngle > 360 ) { $EndAngle = 360; } |
981 | - for($i=$Offset;$i<=$EndAngle;$i=$i+$Step) |
|
982 | - { |
|
887 | + for($i=$Offset;$i<=$EndAngle;$i=$i+$Step) { |
|
983 | 888 | $Xc = cos(($i-90)*PI/180) * $OuterRadius + $X; |
984 | 889 | $Yc = sin(($i-90)*PI/180) * $OuterRadius + $Y; |
985 | 890 | |
@@ -995,8 +900,7 @@ discard block |
||
995 | 900 | $Boundaries[1]["X1"] = $Xc; $Boundaries[1]["Y1"] = $Yc; |
996 | 901 | $Lasti = $EndAngle; |
997 | 902 | |
998 | - for($i=$EndAngle;$i>=$Offset;$i=$i-$Step) |
|
999 | - { |
|
903 | + for($i=$EndAngle;$i>=$Offset;$i=$i-$Step) { |
|
1000 | 904 | $Xc = cos(($i-90)*PI/180) * ($InnerRadius-1) + $X; |
1001 | 905 | $Yc = sin(($i-90)*PI/180) * ($InnerRadius-1) + $Y; |
1002 | 906 | |
@@ -1023,11 +927,9 @@ discard block |
||
1023 | 927 | $this->pChartObject->drawLine($Boundaries[0]["X1"],$Boundaries[0]["Y1"],$Boundaries[0]["X2"],$Boundaries[0]["Y2"],$BorderColor); |
1024 | 928 | $this->pChartObject->drawLine($Boundaries[1]["X1"],$Boundaries[1]["Y1"],$Boundaries[1]["X2"],$Boundaries[1]["Y2"],$BorderColor); |
1025 | 929 | |
1026 | - if ( $DrawLabels && !$Shadow ) |
|
1027 | - { |
|
930 | + if ( $DrawLabels && !$Shadow ) { |
|
1028 | 931 | if ( $LabelColor == PIE_LABEL_COLOR_AUTO ) |
1029 | - { $Settings = array("FillR"=>$Palette[$ID]["R"],"FillG"=>$Palette[$ID]["G"],"FillB"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);} |
|
1030 | - else |
|
932 | + { $Settings = array("FillR"=>$Palette[$ID]["R"],"FillG"=>$Palette[$ID]["G"],"FillB"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);} else |
|
1031 | 933 | { $Settings = array("FillR"=>$LabelR,"FillG"=>$LabelG,"FillB"=>$LabelB,"Alpha"=>$LabelAlpha); } |
1032 | 934 | |
1033 | 935 | $Angle = ($EndAngle - $Offset)/2 + $Offset; |
@@ -1047,27 +949,22 @@ discard block |
||
1047 | 949 | |
1048 | 950 | if ( $DrawLabels && $LabelStacked ) { $this->writeShiftedLabels(); } |
1049 | 951 | |
1050 | - if ( $WriteValues && !$Shadow ) |
|
1051 | - { |
|
952 | + if ( $WriteValues && !$Shadow ) { |
|
1052 | 953 | $Step = 360 / (2 * PI * $OuterRadius); |
1053 | 954 | $Offset = 0; |
1054 | - foreach($Values as $Key => $Value) |
|
1055 | - { |
|
955 | + foreach($Values as $Key => $Value) { |
|
1056 | 956 | $EndAngle = $Offset+($Value*$ScaleFactor); |
1057 | 957 | if ( $EndAngle > 360 ) { $EndAngle = 360; } |
1058 | 958 | |
1059 | 959 | $Angle = $Offset+($Value*$ScaleFactor)/2; |
1060 | - if ( $ValuePosition == PIE_VALUE_OUTSIDE ) |
|
1061 | - { |
|
960 | + if ( $ValuePosition == PIE_VALUE_OUTSIDE ) { |
|
1062 | 961 | $Xc = cos(($Angle-90)*PI/180) * ($OuterRadius+$ValuePadding) + $X; |
1063 | 962 | $Yc = sin(($Angle-90)*PI/180) * ($OuterRadius+$ValuePadding) + $Y; |
1064 | 963 | if ( $Angle >=0 && $Angle <= 90 ) { $Align = TEXT_ALIGN_BOTTOMLEFT; } |
1065 | 964 | if ( $Angle > 90 && $Angle <= 180 ) { $Align = TEXT_ALIGN_TOPLEFT; } |
1066 | 965 | if ( $Angle > 180 && $Angle <= 270 ) { $Align = TEXT_ALIGN_TOPRIGHT; } |
1067 | 966 | if ( $Angle > 270 ) { $Align = TEXT_ALIGN_BOTTOMRIGHT; } |
1068 | - } |
|
1069 | - else |
|
1070 | - { |
|
967 | + } else { |
|
1071 | 968 | $Xc = cos(($Angle-90)*PI/180) * (($OuterRadius-$InnerRadius)/2+$InnerRadius) + $X; |
1072 | 969 | $Yc = sin(($Angle-90)*PI/180) * (($OuterRadius-$InnerRadius)/2+$InnerRadius) + $Y; |
1073 | 970 | $Align = TEXT_ALIGN_MIDDLEMIDDLE; |
@@ -1091,8 +988,7 @@ discard block |
||
1091 | 988 | } |
1092 | 989 | |
1093 | 990 | /* Draw a 3D ring chart */ |
1094 | - function draw3DRing($X,$Y,$Format="") |
|
1095 | - { |
|
991 | + function draw3DRing($X,$Y,$Format="") { |
|
1096 | 992 | $OuterRadius = isset($Format["OuterRadius"]) ? $Format["OuterRadius"] : 100; |
1097 | 993 | $Precision = isset($Format["Precision"]) ? $Format["Precision"] : 0; |
1098 | 994 | $InnerRadius = isset($Format["InnerRadius"]) ? $Format["InnerRadius"] : 30; |
@@ -1165,8 +1061,7 @@ discard block |
||
1165 | 1061 | $Offset = 360; $ID = count($Values)-1; |
1166 | 1062 | $Values = array_reverse($Values); |
1167 | 1063 | $Slice = 0; $Slices = ""; $SliceColors = ""; $Visible = ""; $SliceAngle = ""; |
1168 | - foreach($Values as $Key => $Value) |
|
1169 | - { |
|
1064 | + foreach($Values as $Key => $Value) { |
|
1170 | 1065 | if ( !isset($Palette[$ID]["R"]) ) { $Color = $this->pChartObject->getRandomColor(); $Palette[$ID] = $Color; $this->pDataObject->savePalette($ID,$Color); } |
1171 | 1066 | $Settings = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]); |
1172 | 1067 | |
@@ -1180,8 +1075,7 @@ discard block |
||
1180 | 1075 | |
1181 | 1076 | $Step = (360 / (2 * PI * $OuterRadius))/2; |
1182 | 1077 | $OutX1 = VOID; $OutY1 = VOID; |
1183 | - for($i=$Offset;$i>=$EndAngle;$i=$i-$Step) |
|
1184 | - { |
|
1078 | + for($i=$Offset;$i>=$EndAngle;$i=$i-$Step) { |
|
1185 | 1079 | $Xc = cos(($i-90)*PI/180) * ($OuterRadius+$DataGapRadius-2) + $X; |
1186 | 1080 | $Yc = sin(($i-90)*PI/180) * ($OuterRadius+$DataGapRadius-2)*$SkewFactor + $Y; |
1187 | 1081 | $Slices[$Slice]["AA"][] = array($Xc,$Yc); |
@@ -1212,8 +1106,7 @@ discard block |
||
1212 | 1106 | |
1213 | 1107 | $Step = (360 / (2 * PI * $InnerRadius))/2; |
1214 | 1108 | $InX1 = VOID; $InY1 = VOID; |
1215 | - for($i=$EndAngle;$i<=$Offset;$i=$i+$Step) |
|
1216 | - { |
|
1109 | + for($i=$EndAngle;$i<=$Offset;$i=$i+$Step) { |
|
1217 | 1110 | $Xc = cos(($i-90)*PI/180) * ($InnerRadius+$DataGapRadius-1) + $X; |
1218 | 1111 | $Yc = sin(($i-90)*PI/180) * ($InnerRadius+$DataGapRadius-1)*$SkewFactor + $Y; |
1219 | 1112 | $Slices[$Slice]["AA"][] = array($Xc,$Yc); |
@@ -1244,13 +1137,13 @@ discard block |
||
1244 | 1137 | } |
1245 | 1138 | |
1246 | 1139 | /* Draw the bottom pie splice */ |
1247 | - foreach($Slices as $SliceID => $Plots) |
|
1248 | - { |
|
1140 | + foreach($Slices as $SliceID => $Plots) { |
|
1249 | 1141 | $Settings = $SliceColors[$SliceID]; $Settings["NoBorder"] = TRUE; |
1250 | 1142 | $this->pChartObject->drawPolygon($Plots["BottomPoly"],$Settings); |
1251 | 1143 | |
1252 | - foreach($Plots["AA"] as $Key => $Pos) |
|
1253 | - $this->pChartObject->drawAntialiasPixel($Pos[0],$Pos[1],$Settings); |
|
1144 | + foreach($Plots["AA"] as $Key => $Pos) { |
|
1145 | + $this->pChartObject->drawAntialiasPixel($Pos[0],$Pos[1],$Settings); |
|
1146 | + } |
|
1254 | 1147 | |
1255 | 1148 | $this->pChartObject->drawLine($Plots["InX1"],$Plots["InY1"],$Plots["OutX2"],$Plots["OutY2"],$Settings); |
1256 | 1149 | $this->pChartObject->drawLine($Plots["InX2"],$Plots["InY2"],$Plots["OutX1"],$Plots["OutY1"],$Settings); |
@@ -1260,8 +1153,7 @@ discard block |
||
1260 | 1153 | $SliceColors = array_reverse($SliceColors); |
1261 | 1154 | |
1262 | 1155 | /* Draw the vertical edges (semi-visible) */ |
1263 | - foreach($Slices as $SliceID => $Plots) |
|
1264 | - { |
|
1156 | + foreach($Slices as $SliceID => $Plots) { |
|
1265 | 1157 | $Settings = $SliceColors[$SliceID]; $Settings["NoBorder"] = TRUE; |
1266 | 1158 | $Settings["R"] = $Settings["R"]+$Cf; $Settings["G"] = $Settings["G"]+$Cf; $Settings["B"] = $Settings["B"]+$Cf; |
1267 | 1159 | |
@@ -1278,21 +1170,16 @@ discard block |
||
1278 | 1170 | } |
1279 | 1171 | |
1280 | 1172 | /* Draw the inner vertical slices */ |
1281 | - foreach($Slices as $SliceID => $Plots) |
|
1282 | - { |
|
1173 | + foreach($Slices as $SliceID => $Plots) { |
|
1283 | 1174 | $Settings = $SliceColors[$SliceID]; $Settings["NoBorder"] = TRUE; |
1284 | 1175 | $Settings["R"] = $Settings["R"]+$Cf; $Settings["G"] = $Settings["G"]+$Cf; $Settings["B"] = $Settings["B"]+$Cf; |
1285 | 1176 | |
1286 | 1177 | $Outer = TRUE; $Inner = FALSE; |
1287 | 1178 | $InnerPlotsA = ""; $InnerPlotsB = ""; |
1288 | - foreach($Plots["Angle"] as $ID => $Angle) |
|
1289 | - { |
|
1179 | + foreach($Plots["Angle"] as $ID => $Angle) { |
|
1290 | 1180 | if ( $Angle == VOID ) |
1291 | - { $Outer = FALSE; $Inner = TRUE; } |
|
1292 | - elseif( $Inner ) |
|
1293 | - { |
|
1294 | - if (( $Angle < 90 || $Angle > 270 ) && isset($Plots["BottomPoly"][$ID*2]) ) |
|
1295 | - { |
|
1181 | + { $Outer = FALSE; $Inner = TRUE; } elseif( $Inner ) { |
|
1182 | + if (( $Angle < 90 || $Angle > 270 ) && isset($Plots["BottomPoly"][$ID*2]) ) { |
|
1296 | 1183 | $Xo = $Plots["BottomPoly"][$ID*2]; |
1297 | 1184 | $Yo = $Plots["BottomPoly"][$ID*2+1]; |
1298 | 1185 | |
@@ -1307,16 +1194,14 @@ discard block |
||
1307 | 1194 | } |
1308 | 1195 | |
1309 | 1196 | /* Draw the splice top and left poly */ |
1310 | - foreach($Slices as $SliceID => $Plots) |
|
1311 | - { |
|
1197 | + foreach($Slices as $SliceID => $Plots) { |
|
1312 | 1198 | $Settings = $SliceColors[$SliceID]; $Settings["NoBorder"] = TRUE; |
1313 | 1199 | $Settings["R"] = $Settings["R"]+$Cf*1.5; $Settings["G"] = $Settings["G"]+$Cf*1.5; $Settings["B"] = $Settings["B"]+$Cf*1.5; |
1314 | 1200 | |
1315 | 1201 | $StartAngle = $Plots["Angle"][0]; |
1316 | 1202 | foreach($Plots["Angle"] as $Key =>$Angle) { if ($Angle == VOID) { $EndAngle = $Plots["Angle"][$Key-1]; } } |
1317 | 1203 | |
1318 | - if ( $StartAngle < 180 ) |
|
1319 | - { |
|
1204 | + if ( $StartAngle < 180 ) { |
|
1320 | 1205 | $Points = ""; |
1321 | 1206 | $Points[] = $Plots["InX2"]; |
1322 | 1207 | $Points[] = $Plots["InY2"]; |
@@ -1330,8 +1215,7 @@ discard block |
||
1330 | 1215 | $this->pChartObject->drawPolygon($Points,$Settings); |
1331 | 1216 | } |
1332 | 1217 | |
1333 | - if ( $EndAngle > 180 ) |
|
1334 | - { |
|
1218 | + if ( $EndAngle > 180 ) { |
|
1335 | 1219 | $Points = ""; |
1336 | 1220 | $Points[] = $Plots["InX1"]; |
1337 | 1221 | $Points[] = $Plots["InY1"]; |
@@ -1348,8 +1232,7 @@ discard block |
||
1348 | 1232 | |
1349 | 1233 | |
1350 | 1234 | /* Draw the vertical edges (visible) */ |
1351 | - foreach($Slices as $SliceID => $Plots) |
|
1352 | - { |
|
1235 | + foreach($Slices as $SliceID => $Plots) { |
|
1353 | 1236 | $Settings = $SliceColors[$SliceID]; $Settings["NoBorder"] = TRUE; |
1354 | 1237 | $Settings["R"] = $Settings["R"]+$Cf; $Settings["G"] = $Settings["G"]+$Cf; $Settings["B"] = $Settings["B"]+$Cf; |
1355 | 1238 | |
@@ -1364,21 +1247,16 @@ discard block |
||
1364 | 1247 | |
1365 | 1248 | |
1366 | 1249 | /* Draw the outer vertical slices */ |
1367 | - foreach($Slices as $SliceID => $Plots) |
|
1368 | - { |
|
1250 | + foreach($Slices as $SliceID => $Plots) { |
|
1369 | 1251 | $Settings = $SliceColors[$SliceID]; $Settings["NoBorder"] = TRUE; |
1370 | 1252 | $Settings["R"] = $Settings["R"]+$Cf; $Settings["G"] = $Settings["G"]+$Cf; $Settings["B"] = $Settings["B"]+$Cf; |
1371 | 1253 | |
1372 | 1254 | $Outer = TRUE; $Inner = FALSE; |
1373 | 1255 | $OuterPlotsA = ""; $OuterPlotsB = ""; $InnerPlotsA = ""; $InnerPlotsB = ""; |
1374 | - foreach($Plots["Angle"] as $ID => $Angle) |
|
1375 | - { |
|
1256 | + foreach($Plots["Angle"] as $ID => $Angle) { |
|
1376 | 1257 | if ( $Angle == VOID ) |
1377 | - { $Outer = FALSE; $Inner = TRUE; } |
|
1378 | - elseif( $Outer ) |
|
1379 | - { |
|
1380 | - if ( ( $Angle > 90 && $Angle < 270 ) && isset($Plots["BottomPoly"][$ID*2]) ) |
|
1381 | - { |
|
1258 | + { $Outer = FALSE; $Inner = TRUE; } elseif( $Outer ) { |
|
1259 | + if ( ( $Angle > 90 && $Angle < 270 ) && isset($Plots["BottomPoly"][$ID*2]) ) { |
|
1382 | 1260 | $Xo = $Plots["BottomPoly"][$ID*2]; |
1383 | 1261 | $Yo = $Plots["BottomPoly"][$ID*2+1]; |
1384 | 1262 | |
@@ -1396,8 +1274,7 @@ discard block |
||
1396 | 1274 | |
1397 | 1275 | |
1398 | 1276 | /* Draw the top pie splice */ |
1399 | - foreach($Slices as $SliceID => $Plots) |
|
1400 | - { |
|
1277 | + foreach($Slices as $SliceID => $Plots) { |
|
1401 | 1278 | $Settings = $SliceColors[$SliceID]; $Settings["NoBorder"] = TRUE; |
1402 | 1279 | $Settings["R"] = $Settings["R"]+$Cf*2; $Settings["G"] = $Settings["G"]+$Cf*2; $Settings["B"] = $Settings["B"]+$Cf*2; |
1403 | 1280 | |
@@ -1405,24 +1282,22 @@ discard block |
||
1405 | 1282 | |
1406 | 1283 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("POLY",$this->arraySerialize($Plots["TopPoly"]),$this->pChartObject->toHTMLColor($Settings["R"],$Settings["G"],$Settings["B"]),$Data["Series"][$Data["Abscissa"]]["Data"][$SliceID],$Data["Series"][$DataSerie]["Data"][count($Slices)-$SliceID-1]); } |
1407 | 1284 | |
1408 | - foreach($Plots["AA"] as $Key => $Pos) |
|
1409 | - $this->pChartObject->drawAntialiasPixel($Pos[0],$Pos[1]-$SliceHeight,$Settings); |
|
1285 | + foreach($Plots["AA"] as $Key => $Pos) { |
|
1286 | + $this->pChartObject->drawAntialiasPixel($Pos[0],$Pos[1]-$SliceHeight,$Settings); |
|
1287 | + } |
|
1410 | 1288 | |
1411 | 1289 | $this->pChartObject->drawLine($Plots["InX1"],$Plots["InY1"]-$SliceHeight,$Plots["OutX2"],$Plots["OutY2"]-$SliceHeight,$Settings); |
1412 | 1290 | $this->pChartObject->drawLine($Plots["InX2"],$Plots["InY2"]-$SliceHeight,$Plots["OutX1"],$Plots["OutY1"]-$SliceHeight,$Settings); |
1413 | 1291 | } |
1414 | 1292 | |
1415 | - if ( $DrawLabels ) |
|
1416 | - { |
|
1293 | + if ( $DrawLabels ) { |
|
1417 | 1294 | $Offset = 360; |
1418 | - foreach($Values as $Key => $Value) |
|
1419 | - { |
|
1295 | + foreach($Values as $Key => $Value) { |
|
1420 | 1296 | $StartAngle = $Offset; |
1421 | 1297 | $EndAngle = $Offset-($Value*$ScaleFactor); if ( $EndAngle < 0 ) { $EndAngle = 0; } |
1422 | 1298 | |
1423 | 1299 | if ( $LabelColor == PIE_LABEL_COLOR_AUTO ) |
1424 | - { $Settings = array("FillR"=>$Palette[$ID]["R"],"FillG"=>$Palette[$ID]["G"],"FillB"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);} |
|
1425 | - else |
|
1300 | + { $Settings = array("FillR"=>$Palette[$ID]["R"],"FillG"=>$Palette[$ID]["G"],"FillB"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]);} else |
|
1426 | 1301 | { $Settings = array("FillR"=>$LabelR,"FillG"=>$LabelG,"FillB"=>$LabelB,"Alpha"=>$LabelAlpha); } |
1427 | 1302 | |
1428 | 1303 | $Angle = ($EndAngle - $Offset)/2 + $Offset; |
@@ -1452,8 +1327,7 @@ discard block |
||
1452 | 1327 | } |
1453 | 1328 | |
1454 | 1329 | /* Serialize an array */ |
1455 | - function arraySerialize($Data) |
|
1456 | - { |
|
1330 | + function arraySerialize($Data) { |
|
1457 | 1331 | $Result = ""; |
1458 | 1332 | foreach($Data as $Key => $Value) |
1459 | 1333 | { if ($Result == "") { $Result = floor($Value); } else { $Result = $Result.",".floor($Value); } } |
@@ -1462,8 +1336,7 @@ discard block |
||
1462 | 1336 | } |
1463 | 1337 | |
1464 | 1338 | /* Reverse an array */ |
1465 | - function arrayReverse($Plots) |
|
1466 | - { |
|
1339 | + function arrayReverse($Plots) { |
|
1467 | 1340 | $Result = ""; |
1468 | 1341 | |
1469 | 1342 | for($i=count($Plots)-1;$i>=0;$i=$i-2) |
@@ -1473,8 +1346,7 @@ discard block |
||
1473 | 1346 | } |
1474 | 1347 | |
1475 | 1348 | /* Remove unused series & values */ |
1476 | - function clean0Values($Data,$Palette,$DataSerie,$AbscissaSerie) |
|
1477 | - { |
|
1349 | + function clean0Values($Data,$Palette,$DataSerie,$AbscissaSerie) { |
|
1478 | 1350 | $NewPalette = ""; $NewData = ""; $NewAbscissa = ""; |
1479 | 1351 | |
1480 | 1352 | /* Remove unused series */ |
@@ -1482,10 +1354,8 @@ discard block |
||
1482 | 1354 | { if ( $SerieName != $DataSerie && $SerieName != $AbscissaSerie ) { unset($Data["Series"][$SerieName]); } } |
1483 | 1355 | |
1484 | 1356 | /* Remove NULL values */ |
1485 | - foreach($Data["Series"][$DataSerie]["Data"] as $Key => $Value) |
|
1486 | - { |
|
1487 | - if ($Value != 0 ) |
|
1488 | - { |
|
1357 | + foreach($Data["Series"][$DataSerie]["Data"] as $Key => $Value) { |
|
1358 | + if ($Value != 0 ) { |
|
1489 | 1359 | $NewData[] = $Value; |
1490 | 1360 | $NewAbscissa[] = $Data["Series"][$AbscissaSerie]["Data"][$Key]; |
1491 | 1361 | if ( isset($Palette[$Key]) ) { $NewPalette[] = $Palette[$Key]; } |
@@ -17,54 +17,44 @@ discard block |
||
17 | 17 | define("BUBBLE_SHAPE_SQUARE" , 700002); |
18 | 18 | |
19 | 19 | /* pBubble class definition */ |
20 | - class pBubble |
|
21 | - { |
|
20 | + class pBubble { |
|
22 | 21 | var $pChartObject; |
23 | 22 | var $pDataObject; |
24 | 23 | |
25 | 24 | /* Class creator */ |
26 | - function pBubble($pChartObject,$pDataObject) |
|
27 | - { |
|
25 | + function pBubble($pChartObject,$pDataObject) { |
|
28 | 26 | $this->pChartObject = $pChartObject; |
29 | 27 | $this->pDataObject = $pDataObject; |
30 | 28 | } |
31 | 29 | |
32 | 30 | /* Prepare the scale */ |
33 | - function bubbleScale($DataSeries,$WeightSeries) |
|
34 | - { |
|
31 | + function bubbleScale($DataSeries,$WeightSeries) { |
|
35 | 32 | if ( !is_array($DataSeries) ) { $DataSeries = array($DataSeries); } |
36 | 33 | if ( !is_array($WeightSeries) ) { $WeightSeries = array($WeightSeries); } |
37 | 34 | |
38 | 35 | /* Parse each data series to find the new min & max boundaries to scale */ |
39 | 36 | $NewPositiveSerie = ""; $NewNegativeSerie = ""; $MaxValues = 0; $LastPositive = 0; $LastNegative = 0; |
40 | - foreach($DataSeries as $Key => $SerieName) |
|
41 | - { |
|
37 | + foreach($DataSeries as $Key => $SerieName) { |
|
42 | 38 | $SerieWeightName = $WeightSeries[$Key]; |
43 | 39 | |
44 | 40 | $this->pDataObject->setSerieDrawable($SerieWeightName,FALSE); |
45 | 41 | |
46 | 42 | if ( count($this->pDataObject->Data["Series"][$SerieName]["Data"]) > $MaxValues ) { $MaxValues = count($this->pDataObject->Data["Series"][$SerieName]["Data"]); } |
47 | 43 | |
48 | - foreach($this->pDataObject->Data["Series"][$SerieName]["Data"] as $Key => $Value) |
|
49 | - { |
|
50 | - if ( $Value >= 0 ) |
|
51 | - { |
|
44 | + foreach($this->pDataObject->Data["Series"][$SerieName]["Data"] as $Key => $Value) { |
|
45 | + if ( $Value >= 0 ) { |
|
52 | 46 | $BubbleBounds = $Value + $this->pDataObject->Data["Series"][$SerieWeightName]["Data"][$Key]; |
53 | 47 | |
54 | 48 | if ( !isset($NewPositiveSerie[$Key]) ) |
55 | - { $NewPositiveSerie[$Key] = $BubbleBounds; } |
|
56 | - elseif ( $NewPositiveSerie[$Key] < $BubbleBounds ) |
|
49 | + { $NewPositiveSerie[$Key] = $BubbleBounds; } elseif ( $NewPositiveSerie[$Key] < $BubbleBounds ) |
|
57 | 50 | { $NewPositiveSerie[$Key] = $BubbleBounds; } |
58 | 51 | |
59 | 52 | $LastPositive = $BubbleBounds; |
60 | - } |
|
61 | - else |
|
62 | - { |
|
53 | + } else { |
|
63 | 54 | $BubbleBounds = $Value - $this->pDataObject->Data["Series"][$SerieWeightName]["Data"][$Key]; |
64 | 55 | |
65 | 56 | if ( !isset($NewNegativeSerie[$Key]) ) |
66 | - { $NewNegativeSerie[$Key] = $BubbleBounds; } |
|
67 | - elseif ( $NewNegativeSerie[$Key] > $BubbleBounds ) |
|
57 | + { $NewNegativeSerie[$Key] = $BubbleBounds; } elseif ( $NewNegativeSerie[$Key] > $BubbleBounds ) |
|
68 | 58 | { $NewNegativeSerie[$Key] = $BubbleBounds; } |
69 | 59 | |
70 | 60 | $LastNegative = $BubbleBounds; |
@@ -73,32 +63,27 @@ discard block |
||
73 | 63 | } |
74 | 64 | |
75 | 65 | /* Check for missing values and all the fake positive serie */ |
76 | - if ( $NewPositiveSerie != "" ) |
|
77 | - { |
|
66 | + if ( $NewPositiveSerie != "" ) { |
|
78 | 67 | for ($i=0; $i<$MaxValues; $i++) { if (!isset($NewPositiveSerie[$i])) { $NewPositiveSerie[$i] = $LastPositive; } } |
79 | 68 | |
80 | 69 | $this->pDataObject->addPoints($NewPositiveSerie,"BubbleFakePositiveSerie"); |
81 | 70 | } |
82 | 71 | |
83 | 72 | /* Check for missing values and all the fake negative serie */ |
84 | - if ( $NewNegativeSerie != "" ) |
|
85 | - { |
|
73 | + if ( $NewNegativeSerie != "" ) { |
|
86 | 74 | for ($i=0; $i<$MaxValues; $i++) { if (!isset($NewNegativeSerie[$i])) { $NewNegativeSerie[$i] = $LastNegative; } } |
87 | 75 | |
88 | 76 | $this->pDataObject->addPoints($NewNegativeSerie,"BubbleFakeNegativeSerie"); |
89 | 77 | } |
90 | 78 | } |
91 | 79 | |
92 | - function resetSeriesColors() |
|
93 | - { |
|
80 | + function resetSeriesColors() { |
|
94 | 81 | $Data = $this->pDataObject->getData(); |
95 | 82 | $Palette = $this->pDataObject->getPalette(); |
96 | 83 | |
97 | 84 | $ID = 0; |
98 | - foreach($Data["Series"] as $SerieName => $SeriesParameters) |
|
99 | - { |
|
100 | - if ( $SeriesParameters["isDrawable"] ) |
|
101 | - { |
|
85 | + foreach($Data["Series"] as $SerieName => $SeriesParameters) { |
|
86 | + if ( $SeriesParameters["isDrawable"] ) { |
|
102 | 87 | $this->pDataObject->Data["Series"][$SerieName]["Color"]["R"] = $Palette[$ID]["R"]; |
103 | 88 | $this->pDataObject->Data["Series"][$SerieName]["Color"]["G"] = $Palette[$ID]["G"]; |
104 | 89 | $this->pDataObject->Data["Series"][$SerieName]["Color"]["B"] = $Palette[$ID]["B"]; |
@@ -109,8 +94,7 @@ discard block |
||
109 | 94 | } |
110 | 95 | |
111 | 96 | /* Prepare the scale */ |
112 | - function drawBubbleChart($DataSeries,$WeightSeries,$Format="") |
|
113 | - { |
|
97 | + function drawBubbleChart($DataSeries,$WeightSeries,$Format="") { |
|
114 | 98 | $ForceAlpha = isset($Format["ForceAlpha"]) ? $Format["ForceAlpha"] : VOID; |
115 | 99 | $DrawBorder = isset($Format["DrawBorder"]) ? $Format["DrawBorder"] : TRUE; |
116 | 100 | $BorderWidth = isset($Format["BorderWidth"]) ? $Format["BorderWidth"] : 1; |
@@ -135,8 +119,7 @@ discard block |
||
135 | 119 | |
136 | 120 | list($XMargin,$XDivs) = $this->pChartObject->scaleGetXSettings(); |
137 | 121 | |
138 | - foreach($DataSeries as $Key => $SerieName) |
|
139 | - { |
|
122 | + foreach($DataSeries as $Key => $SerieName) { |
|
140 | 123 | $AxisID = $Data["Series"][$SerieName]["Axis"]; |
141 | 124 | $Mode = $Data["Axis"][$AxisID]["Display"]; |
142 | 125 | $Format = $Data["Axis"][$AxisID]["Format"]; |
@@ -153,95 +136,71 @@ discard block |
||
153 | 136 | |
154 | 137 | if ( $ForceAlpha != VOID ) { $Color["Alpha"]=$ForceAlpha; } |
155 | 138 | |
156 | - if ( $DrawBorder ) |
|
157 | - { |
|
158 | - if ( $BorderWidth != 1 ) |
|
159 | - { |
|
139 | + if ( $DrawBorder ) { |
|
140 | + if ( $BorderWidth != 1 ) { |
|
160 | 141 | if ( $Surrounding != NULL ) |
161 | - { $BorderR = $Palette[$Key]["R"]+$Surrounding; $BorderG = $Palette[$Key]["G"]+$Surrounding; $BorderB = $Palette[$Key]["B"]+$Surrounding; } |
|
162 | - else |
|
142 | + { $BorderR = $Palette[$Key]["R"]+$Surrounding; $BorderG = $Palette[$Key]["G"]+$Surrounding; $BorderB = $Palette[$Key]["B"]+$Surrounding; } else |
|
163 | 143 | { $BorderR = $BorderR; $BorderG = $BorderG; $BorderB = $BorderB; } |
164 | 144 | if ( $ForceAlpha != VOID ) { $BorderAlpha = $ForceAlpha/2; } |
165 | 145 | $BorderColor = array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha); |
166 | - } |
|
167 | - else |
|
168 | - { |
|
146 | + } else { |
|
169 | 147 | $Color["BorderAlpha"] = $BorderAlpha; |
170 | 148 | |
171 | 149 | if ( $Surrounding != NULL ) |
172 | - { $Color["BorderR"] = $Palette[$Key]["R"]+$Surrounding; $Color["BorderG"] = $Palette[$Key]["G"]+$Surrounding; $Color["BorderB"] = $Palette[$Key]["B"]+$Surrounding; } |
|
173 | - else |
|
150 | + { $Color["BorderR"] = $Palette[$Key]["R"]+$Surrounding; $Color["BorderG"] = $Palette[$Key]["G"]+$Surrounding; $Color["BorderB"] = $Palette[$Key]["B"]+$Surrounding; } else |
|
174 | 151 | { $Color["BorderR"] = $BorderR; $Color["BorderG"] = $BorderG; $Color["BorderB"] = $BorderB; } |
175 | 152 | if ( $ForceAlpha != VOID ) { $Color["BorderAlpha"] = $ForceAlpha/2; } |
176 | 153 | } |
177 | 154 | } |
178 | 155 | |
179 | - foreach($Data["Series"][$SerieName]["Data"] as $iKey => $Point) |
|
180 | - { |
|
156 | + foreach($Data["Series"][$SerieName]["Data"] as $iKey => $Point) { |
|
181 | 157 | $Weight = $Point + $Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]; |
182 | 158 | |
183 | 159 | $PosArray = $this->pChartObject->scaleComputeY($Point,array("AxisID"=>$AxisID)); |
184 | 160 | $WeightArray = $this->pChartObject->scaleComputeY($Weight,array("AxisID"=>$AxisID)); |
185 | 161 | |
186 | - if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT ) |
|
187 | - { |
|
162 | + if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT ) { |
|
188 | 163 | if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1-$XMargin*2)/$XDivs; } |
189 | 164 | $Y = floor($PosArray); $CircleRadius = floor(abs($PosArray - $WeightArray)/2); |
190 | 165 | |
191 | - if ( $Shape == BUBBLE_SHAPE_SQUARE ) |
|
192 | - { |
|
166 | + if ( $Shape == BUBBLE_SHAPE_SQUARE ) { |
|
193 | 167 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($X-$CircleRadius).",".floor($Y-$CircleRadius).",".floor($X+$CircleRadius).",".floor($Y+$CircleRadius),$this->pChartObject->toHTMLColor($Palette[$Key]["R"],$Palette[$Key]["G"],$Palette[$Key]["B"]),$SerieDescription,$Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]); } |
194 | 168 | |
195 | - if ( $BorderWidth != 1 ) |
|
196 | - { |
|
169 | + if ( $BorderWidth != 1 ) { |
|
197 | 170 | $this->pChartObject->drawFilledRectangle($X-$CircleRadius-$BorderWidth,$Y-$CircleRadius-$BorderWidth,$X+$CircleRadius+$BorderWidth,$Y+$CircleRadius+$BorderWidth,$BorderColor); |
198 | 171 | $this->pChartObject->drawFilledRectangle($X-$CircleRadius,$Y-$CircleRadius,$X+$CircleRadius,$Y+$CircleRadius,$Color); |
199 | - } |
|
200 | - else |
|
172 | + } else |
|
201 | 173 | $this->pChartObject->drawFilledRectangle($X-$CircleRadius,$Y-$CircleRadius,$X+$CircleRadius,$Y+$CircleRadius,$Color); |
202 | - } |
|
203 | - elseif ( $Shape == BUBBLE_SHAPE_ROUND ) |
|
204 | - { |
|
174 | + } elseif ( $Shape == BUBBLE_SHAPE_ROUND ) { |
|
205 | 175 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".floor($CircleRadius),$this->pChartObject->toHTMLColor($Palette[$Key]["R"],$Palette[$Key]["G"],$Palette[$Key]["B"]),$SerieDescription,$Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]); } |
206 | 176 | |
207 | - if ( $BorderWidth != 1 ) |
|
208 | - { |
|
177 | + if ( $BorderWidth != 1 ) { |
|
209 | 178 | $this->pChartObject->drawFilledCircle($X,$Y,$CircleRadius+$BorderWidth,$BorderColor); |
210 | 179 | $this->pChartObject->drawFilledCircle($X,$Y,$CircleRadius,$Color); |
211 | - } |
|
212 | - else |
|
180 | + } else |
|
213 | 181 | $this->pChartObject->drawFilledCircle($X,$Y,$CircleRadius,$Color); |
214 | 182 | } |
215 | 183 | |
216 | 184 | $X = $X + $XStep; |
217 | - } |
|
218 | - elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM ) |
|
219 | - { |
|
185 | + } elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM ) { |
|
220 | 186 | if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaY2-$this->pChartObject->GraphAreaY1-$XMargin*2)/$XDivs; } |
221 | 187 | $X = floor($PosArray); $CircleRadius = floor(abs($PosArray - $WeightArray)/2); |
222 | 188 | |
223 | - if ( $Shape == BUBBLE_SHAPE_SQUARE ) |
|
224 | - { |
|
189 | + if ( $Shape == BUBBLE_SHAPE_SQUARE ) { |
|
225 | 190 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("RECT",floor($X-$CircleRadius).",".floor($Y-$CircleRadius).",".floor($X+$CircleRadius).",".floor($Y+$CircleRadius),$this->pChartObject->toHTMLColor($Palette[$Key]["R"],$Palette[$Key]["G"],$Palette[$Key]["B"]),$SerieDescription,$Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]); } |
226 | 191 | |
227 | - if ( $BorderWidth != 1 ) |
|
228 | - { |
|
192 | + if ( $BorderWidth != 1 ) { |
|
229 | 193 | $this->pChartObject->drawFilledRectangle($X-$CircleRadius-$BorderWidth,$Y-$CircleRadius-$BorderWidth,$X+$CircleRadius+$BorderWidth,$Y+$CircleRadius+$BorderWidth,$BorderColor); |
230 | 194 | $this->pChartObject->drawFilledRectangle($X-$CircleRadius,$Y-$CircleRadius,$X+$CircleRadius,$Y+$CircleRadius,$Color); |
231 | - } |
|
232 | - else |
|
195 | + } else |
|
233 | 196 | $this->pChartObject->drawFilledRectangle($X-$CircleRadius,$Y-$CircleRadius,$X+$CircleRadius,$Y+$CircleRadius,$Color); |
234 | - } |
|
235 | - elseif ( $Shape == BUBBLE_SHAPE_ROUND ) |
|
236 | - { |
|
197 | + } elseif ( $Shape == BUBBLE_SHAPE_ROUND ) { |
|
237 | 198 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".floor($CircleRadius),$this->pChartObject->toHTMLColor($Palette[$Key]["R"],$Palette[$Key]["G"],$Palette[$Key]["B"]),$SerieDescription,$Data["Series"][$WeightSeries[$Key]]["Data"][$iKey]); } |
238 | 199 | |
239 | - if ( $BorderWidth != 1 ) |
|
240 | - { |
|
200 | + if ( $BorderWidth != 1 ) { |
|
241 | 201 | $this->pChartObject->drawFilledCircle($X,$Y,$CircleRadius+$BorderWidth,$BorderColor); |
242 | 202 | $this->pChartObject->drawFilledCircle($X,$Y,$CircleRadius,$Color); |
243 | - } |
|
244 | - else |
|
203 | + } else |
|
245 | 204 | $this->pChartObject->drawFilledCircle($X,$Y,$CircleRadius,$Color); |
246 | 205 | } |
247 | 206 | |
@@ -251,8 +210,7 @@ discard block |
||
251 | 210 | } |
252 | 211 | } |
253 | 212 | |
254 | - function writeBubbleLabel($SerieName,$SerieWeightName,$Points,$Format="") |
|
255 | - { |
|
213 | + function writeBubbleLabel($SerieName,$SerieWeightName,$Points,$Format="") { |
|
256 | 214 | $OverrideTitle = isset($Format["OverrideTitle"]) ? $Format["OverrideTitle"] : NULL; |
257 | 215 | $DrawPoint = isset($Format["DrawPoint"]) ? $Format["DrawPoint"] : LABEL_POINT_BOX; |
258 | 216 | |
@@ -277,8 +235,7 @@ discard block |
||
277 | 235 | |
278 | 236 | $Color = array("R"=>$Data["Series"][$SerieName]["Color"]["R"],"G"=>$Data["Series"][$SerieName]["Color"]["G"],"B"=>$Data["Series"][$SerieName]["Color"]["B"],"Alpha"=>$Data["Series"][$SerieName]["Color"]["Alpha"]); |
279 | 237 | |
280 | - foreach($Points as $Key => $Point) |
|
281 | - { |
|
238 | + foreach($Points as $Key => $Point) { |
|
282 | 239 | $Value = $Data["Series"][$SerieName]["Data"][$Point]; |
283 | 240 | $PosArray = $this->pChartObject->scaleComputeY($Value,array("AxisID"=>$AxisID)); |
284 | 241 | |
@@ -299,15 +256,12 @@ discard block |
||
299 | 256 | $Series = ""; |
300 | 257 | $Series[] = array("Format"=>$Color,"Caption"=>$Caption); |
301 | 258 | |
302 | - if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT ) |
|
303 | - { |
|
259 | + if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT ) { |
|
304 | 260 | if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1-$XMargin*2)/$XDivs; } |
305 | 261 | |
306 | 262 | $X = floor($X + $Point * $XStep); |
307 | 263 | $Y = floor($PosArray); |
308 | - } |
|
309 | - else |
|
310 | - { |
|
264 | + } else { |
|
311 | 265 | if ( $XDivs == 0 ) { $YStep = 0; } else { $YStep = ($this->pChartObject->GraphAreaY2-$this->pChartObject->GraphAreaY1-$XMargin*2)/$XDivs; } |
312 | 266 | |
313 | 267 | $X = floor($PosArray); |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | /* The GD extension is mandatory */ |
17 | - if (!extension_loaded('gd') && !extension_loaded('gd2')) |
|
18 | - { |
|
17 | + if (!extension_loaded('gd') && !extension_loaded('gd2')) { |
|
19 | 18 | echo "GD extension must be loaded. \r\n"; |
20 | 19 | exit(); |
21 | 20 | } |
@@ -31,8 +30,7 @@ discard block |
||
31 | 30 | /* ImageMap string delimiter */ |
32 | 31 | define("IMAGE_MAP_DELIMITER" , chr(1)); |
33 | 32 | |
34 | - class pImage extends pDraw |
|
35 | - { |
|
33 | + class pImage extends pDraw { |
|
36 | 34 | /* Image settings, size, quality, .. */ |
37 | 35 | var $XSize = NULL; // Width of the picture |
38 | 36 | var $YSize = NULL; // Height of the picture |
@@ -82,8 +80,7 @@ discard block |
||
82 | 80 | var $LastChartLayout = CHART_LAST_LAYOUT_REGULAR; // Last layout : regular or stacked |
83 | 81 | |
84 | 82 | /* Class constructor */ |
85 | - function pImage($XSize,$YSize,$DataSet=NULL,$TransparentBackground=FALSE) |
|
86 | - { |
|
83 | + function pImage($XSize,$YSize,$DataSet=NULL,$TransparentBackground=FALSE) { |
|
87 | 84 | $this->TransparentBackground = $TransparentBackground; |
88 | 85 | |
89 | 86 | if ( $DataSet != NULL ) { $this->DataSet = $DataSet; } |
@@ -92,23 +89,19 @@ discard block |
||
92 | 89 | $this->YSize = $YSize; |
93 | 90 | $this->Picture = imagecreatetruecolor($XSize,$YSize); |
94 | 91 | |
95 | - if ( $this->TransparentBackground ) |
|
96 | - { |
|
92 | + if ( $this->TransparentBackground ) { |
|
97 | 93 | imagealphablending($this->Picture,FALSE); |
98 | 94 | imagefilledrectangle($this->Picture, 0,0,$XSize, $YSize, imagecolorallocatealpha($this->Picture, 255, 255, 255, 127)); |
99 | 95 | imagealphablending($this->Picture,TRUE); |
100 | 96 | imagesavealpha($this->Picture,true); |
101 | - } |
|
102 | - else |
|
103 | - { |
|
97 | + } else { |
|
104 | 98 | $C_White = $this->AllocateColor($this->Picture,255,255,255); |
105 | 99 | imagefilledrectangle($this->Picture,0,0,$XSize,$YSize,$C_White); |
106 | 100 | } |
107 | 101 | } |
108 | 102 | |
109 | 103 | /* Enable / Disable and set shadow properties */ |
110 | - function setShadow($Enabled=TRUE,$Format="") |
|
111 | - { |
|
104 | + function setShadow($Enabled=TRUE,$Format="") { |
|
112 | 105 | $X = isset($Format["X"]) ? $Format["X"] : 2; |
113 | 106 | $Y = isset($Format["Y"]) ? $Format["Y"] : 2; |
114 | 107 | $R = isset($Format["R"]) ? $Format["R"] : 0; |
@@ -126,8 +119,7 @@ discard block |
||
126 | 119 | } |
127 | 120 | |
128 | 121 | /* Set the graph area position */ |
129 | - function setGraphArea($X1,$Y1,$X2,$Y2) |
|
130 | - { |
|
122 | + function setGraphArea($X1,$Y1,$X2,$Y2) { |
|
131 | 123 | if ( $X2 < $X1 || $X1 == $X2 || $Y2 < $Y1 || $Y1 == $Y2 ) { return(-1); } |
132 | 124 | |
133 | 125 | $this->GraphAreaX1 = $X1; $this->DataSet->Data["GraphArea"]["X1"] = $X1; |
@@ -145,19 +137,16 @@ discard block |
||
145 | 137 | { return($this->YSize); } |
146 | 138 | |
147 | 139 | /* Render the picture to a file */ |
148 | - function render($FileName) |
|
149 | - { |
|
140 | + function render($FileName) { |
|
150 | 141 | if ( $this->TransparentBackground ) { imagealphablending($this->Picture,false); imagesavealpha($this->Picture,true); } |
151 | 142 | imagepng($this->Picture,$FileName); |
152 | 143 | } |
153 | 144 | |
154 | 145 | /* Render the picture to a web browser stream */ |
155 | - function stroke($BrowserExpire=FALSE) |
|
156 | - { |
|
146 | + function stroke($BrowserExpire=FALSE) { |
|
157 | 147 | if ( $this->TransparentBackground ) { imagealphablending($this->Picture,false); imagesavealpha($this->Picture,true); } |
158 | 148 | |
159 | - if ( $BrowserExpire ) |
|
160 | - { |
|
149 | + if ( $BrowserExpire ) { |
|
161 | 150 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
162 | 151 | header("Cache-Control: no-cache"); |
163 | 152 | header("Pragma: no-cache"); |
@@ -168,8 +157,7 @@ discard block |
||
168 | 157 | } |
169 | 158 | |
170 | 159 | /* Automatic output method based on the calling interface */ |
171 | - function autoOutput($FileName="output.png") |
|
172 | - { |
|
160 | + function autoOutput($FileName="output.png") { |
|
173 | 161 | if (php_sapi_name() == "cli") |
174 | 162 | $this->Render($FileName); |
175 | 163 | else |
@@ -181,15 +169,13 @@ discard block |
||
181 | 169 | { return(sqrt(pow(max($X1,$X2)-min($X1,$X2),2)+pow(max($Y1,$Y2)-min($Y1,$Y2),2))); } |
182 | 170 | |
183 | 171 | /* Return the orientation of a line */ |
184 | - function getAngle($X1,$Y1,$X2,$Y2) |
|
185 | - { |
|
172 | + function getAngle($X1,$Y1,$X2,$Y2) { |
|
186 | 173 | $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent)); |
187 | 174 | if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); } |
188 | 175 | } |
189 | 176 | |
190 | 177 | /* Return the surrounding box of text area */ |
191 | - function getTextBox_deprecated($X,$Y,$FontName,$FontSize,$Angle,$Text) |
|
192 | - { |
|
178 | + function getTextBox_deprecated($X,$Y,$FontName,$FontSize,$Angle,$Text) { |
|
193 | 179 | $Size = imagettfbbox($FontSize,$Angle,$FontName,$Text); |
194 | 180 | $Width = $this->getLength($Size[0],$Size[1],$Size[2],$Size[3])+1; |
195 | 181 | $Height = $this->getLength($Size[2],$Size[3],$Size[4],$Size[5])+1; |
@@ -206,13 +192,11 @@ discard block |
||
206 | 192 | } |
207 | 193 | |
208 | 194 | /* Return the surrounding box of text area */ |
209 | - function getTextBox($X,$Y,$FontName,$FontSize,$Angle,$Text) |
|
210 | - { |
|
195 | + function getTextBox($X,$Y,$FontName,$FontSize,$Angle,$Text) { |
|
211 | 196 | $coords = imagettfbbox($FontSize, 0, $FontName, $Text); |
212 | 197 | |
213 | 198 | $a = deg2rad($Angle); $ca = cos($a); $sa = sin($a); $RealPos = array(); |
214 | - for($i = 0; $i < 7; $i += 2) |
|
215 | - { |
|
199 | + for($i = 0; $i < 7; $i += 2) { |
|
216 | 200 | $RealPos[$i/2]["X"] = $X + round($coords[$i] * $ca + $coords[$i+1] * $sa); |
217 | 201 | $RealPos[$i/2]["Y"] = $Y + round($coords[$i+1] * $ca - $coords[$i] * $sa); |
218 | 202 | } |
@@ -231,8 +215,7 @@ discard block |
||
231 | 215 | } |
232 | 216 | |
233 | 217 | /* Set current font properties */ |
234 | - function setFontProperties($Format="") |
|
235 | - { |
|
218 | + function setFontProperties($Format="") { |
|
236 | 219 | $R = isset($Format["R"]) ? $Format["R"] : -1; |
237 | 220 | $G = isset($Format["G"]) ? $Format["G"] : -1; |
238 | 221 | $B = isset($Format["B"]) ? $Format["B"] : -1; |
@@ -253,8 +236,7 @@ discard block |
||
253 | 236 | } |
254 | 237 | |
255 | 238 | /* Returns the 1st decimal values (used to correct AA bugs) */ |
256 | - function getFirstDecimal($Value) |
|
257 | - { |
|
239 | + function getFirstDecimal($Value) { |
|
258 | 240 | $Values = preg_split("/\./",$Value); |
259 | 241 | if ( isset($Values[1]) ) { return(substr($Values[1],0,1)); } else { return(0); } |
260 | 242 | } |
@@ -268,18 +250,14 @@ discard block |
||
268 | 250 | { print_r($this->DataSet); } |
269 | 251 | |
270 | 252 | /* Initialise the image map methods */ |
271 | - function initialiseImageMap($Name="pChart",$StorageMode=IMAGE_MAP_STORAGE_SESSION,$UniqueID="imageMap",$StorageFolder="tmp") |
|
272 | - { |
|
253 | + function initialiseImageMap($Name="pChart",$StorageMode=IMAGE_MAP_STORAGE_SESSION,$UniqueID="imageMap",$StorageFolder="tmp") { |
|
273 | 254 | $this->ImageMapIndex = $Name; |
274 | 255 | $this->ImageMapStorageMode = $StorageMode; |
275 | 256 | |
276 | - if ($StorageMode == IMAGE_MAP_STORAGE_SESSION) |
|
277 | - { |
|
257 | + if ($StorageMode == IMAGE_MAP_STORAGE_SESSION) { |
|
278 | 258 | if(!isset($_SESSION)) { session_start(); } |
279 | 259 | $_SESSION[$this->ImageMapIndex] = NULL; |
280 | - } |
|
281 | - elseif($StorageMode == IMAGE_MAP_STORAGE_FILE) |
|
282 | - { |
|
260 | + } elseif($StorageMode == IMAGE_MAP_STORAGE_FILE) { |
|
283 | 261 | $this->ImageMapFileName = $UniqueID; |
284 | 262 | $this->ImageMapStorageFolder = $StorageFolder; |
285 | 263 | |
@@ -288,27 +266,22 @@ discard block |
||
288 | 266 | } |
289 | 267 | |
290 | 268 | /* Add a zone to the image map */ |
291 | - function addToImageMap($Type,$Plots,$Color=NULL,$Title=NULL,$Message=NULL,$HTMLEncode=FALSE) |
|
292 | - { |
|
269 | + function addToImageMap($Type,$Plots,$Color=NULL,$Title=NULL,$Message=NULL,$HTMLEncode=FALSE) { |
|
293 | 270 | if ( $this->ImageMapStorageMode == NULL ) { $this->initialiseImageMap(); } |
294 | 271 | |
295 | 272 | /* Encode the characters in the imagemap in HTML standards */ |
296 | 273 | $Title = str_replace("€","\u20AC",$Title); |
297 | 274 | $Title = htmlentities($Title,ENT_QUOTES,"ISO-8859-15"); |
298 | - if ( $HTMLEncode ) |
|
299 | - { |
|
275 | + if ( $HTMLEncode ) { |
|
300 | 276 | $Message = htmlentities($Message,ENT_QUOTES,"ISO-8859-15"); |
301 | 277 | $Message = str_replace("<","<",$Message); |
302 | 278 | $Message = str_replace(">",">",$Message); |
303 | 279 | } |
304 | 280 | |
305 | - if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION ) |
|
306 | - { |
|
281 | + if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION ) { |
|
307 | 282 | if(!isset($_SESSION)) { $this->initialiseImageMap(); } |
308 | 283 | $_SESSION[$this->ImageMapIndex][] = array($Type,$Plots,$Color,$Title,$Message); |
309 | - } |
|
310 | - elseif($this->ImageMapStorageMode == IMAGE_MAP_STORAGE_FILE) |
|
311 | - { |
|
284 | + } elseif($this->ImageMapStorageMode == IMAGE_MAP_STORAGE_FILE) { |
|
312 | 285 | $Handle = fopen($this->ImageMapStorageFolder."/".$this->ImageMapFileName.".map", 'a'); |
313 | 286 | fwrite($Handle, $Type.IMAGE_MAP_DELIMITER.$Plots.IMAGE_MAP_DELIMITER.$Color.IMAGE_MAP_DELIMITER.$Title.IMAGE_MAP_DELIMITER.$Message."\r\n"); |
314 | 287 | fclose($Handle); |
@@ -316,8 +289,7 @@ discard block |
||
316 | 289 | } |
317 | 290 | |
318 | 291 | /* Remove VOID values from an imagemap custom values array */ |
319 | - function removeVOIDFromArray($SerieName, $Values) |
|
320 | - { |
|
292 | + function removeVOIDFromArray($SerieName, $Values) { |
|
321 | 293 | if ( !isset($this->DataSet->Data["Series"][$SerieName]) ) { return(-1); } |
322 | 294 | |
323 | 295 | $Result = ""; |
@@ -327,36 +299,28 @@ discard block |
||
327 | 299 | } |
328 | 300 | |
329 | 301 | /* Replace the title of one image map serie */ |
330 | - function replaceImageMapTitle($OldTitle, $NewTitle) |
|
331 | - { |
|
302 | + function replaceImageMapTitle($OldTitle, $NewTitle) { |
|
332 | 303 | if ( $this->ImageMapStorageMode == NULL ) { return(-1); } |
333 | 304 | |
334 | 305 | if ( is_array($NewTitle) ) { $NewTitle = $this->removeVOIDFromArray($OldTitle, $NewTitle); } |
335 | 306 | |
336 | - if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION ) |
|
337 | - { |
|
307 | + if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION ) { |
|
338 | 308 | if(!isset($_SESSION)) { return(-1); } |
339 | 309 | if ( is_array($NewTitle) ) |
340 | - { $ID = 0; foreach($_SESSION[$this->ImageMapIndex] as $Key => $Settings) { if ( $Settings[3] == $OldTitle && isset($NewTitle[$ID])) { $_SESSION[$this->ImageMapIndex][$Key][3] = $NewTitle[$ID]; $ID++; } } } |
|
341 | - else |
|
310 | + { $ID = 0; foreach($_SESSION[$this->ImageMapIndex] as $Key => $Settings) { if ( $Settings[3] == $OldTitle && isset($NewTitle[$ID])) { $_SESSION[$this->ImageMapIndex][$Key][3] = $NewTitle[$ID]; $ID++; } } } else |
|
342 | 311 | { foreach($_SESSION[$this->ImageMapIndex] as $Key => $Settings) { if ( $Settings[3] == $OldTitle ) { $_SESSION[$this->ImageMapIndex][$Key][3] = $NewTitle; } } } |
343 | - } |
|
344 | - elseif( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_FILE ) |
|
345 | - { |
|
312 | + } elseif( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_FILE ) { |
|
346 | 313 | $TempArray = ""; |
347 | 314 | $Handle = @fopen($this->ImageMapStorageFolder."/".$this->ImageMapFileName.".map", "r"); |
348 | - if ($Handle) |
|
349 | - { |
|
350 | - while (($Buffer = fgets($Handle, 4096)) !== false) |
|
351 | - { |
|
315 | + if ($Handle) { |
|
316 | + while (($Buffer = fgets($Handle, 4096)) !== false) { |
|
352 | 317 | $Fields = split(IMAGE_MAP_DELIMITER,str_replace(array(chr(10),chr(13)),"",$Buffer)); |
353 | 318 | $TempArray[] = array($Fields[0],$Fields[1],$Fields[2],$Fields[3],$Fields[4]); |
354 | 319 | } |
355 | 320 | fclose($Handle); |
356 | 321 | |
357 | 322 | if ( is_array($NewTitle) ) |
358 | - { $ID = 0; foreach($TempArray as $Key => $Settings) { if ( $Settings[3] == $OldTitle && isset($NewTitle[$ID]) ) { $TempArray[$Key][3] = $NewTitle[$ID]; $ID++; } } } |
|
359 | - else |
|
323 | + { $ID = 0; foreach($TempArray as $Key => $Settings) { if ( $Settings[3] == $OldTitle && isset($NewTitle[$ID]) ) { $TempArray[$Key][3] = $NewTitle[$ID]; $ID++; } } } else |
|
360 | 324 | { foreach($TempArray as $Key => $Settings) { if ( $Settings[3] == $OldTitle ) { $TempArray[$Key][3] = $NewTitle; } } } |
361 | 325 | |
362 | 326 | $Handle = fopen($this->ImageMapStorageFolder."/".$this->ImageMapFileName.".map", 'w'); |
@@ -368,25 +332,19 @@ discard block |
||
368 | 332 | } |
369 | 333 | |
370 | 334 | /* Replace the values of the image map contents */ |
371 | - function replaceImageMapValues($Title, $Values) |
|
372 | - { |
|
335 | + function replaceImageMapValues($Title, $Values) { |
|
373 | 336 | if ( $this->ImageMapStorageMode == NULL ) { return(-1); } |
374 | 337 | |
375 | 338 | $Values = $this->removeVOIDFromArray($Title, $Values); |
376 | 339 | $ID = 0; |
377 | - if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION ) |
|
378 | - { |
|
340 | + if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION ) { |
|
379 | 341 | if(!isset($_SESSION)) { return(-1); } |
380 | 342 | foreach($_SESSION[$this->ImageMapIndex] as $Key => $Settings) { if ( $Settings[3] == $Title ) { if ( isset($Values[$ID]) ) { $_SESSION[$this->ImageMapIndex][$Key][4] = $Values[$ID]; } $ID++; } } |
381 | - } |
|
382 | - elseif( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_FILE ) |
|
383 | - { |
|
343 | + } elseif( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_FILE ) { |
|
384 | 344 | $TempArray = ""; |
385 | 345 | $Handle = @fopen($this->ImageMapStorageFolder."/".$this->ImageMapFileName.".map", "r"); |
386 | - if ($Handle) |
|
387 | - { |
|
388 | - while (($Buffer = fgets($Handle, 4096)) !== false) |
|
389 | - { |
|
346 | + if ($Handle) { |
|
347 | + while (($Buffer = fgets($Handle, 4096)) !== false) { |
|
390 | 348 | $Fields = split(IMAGE_MAP_DELIMITER,str_replace(array(chr(10),chr(13)),"",$Buffer)); |
391 | 349 | $TempArray[] = array($Fields[0],$Fields[1],$Fields[2],$Fields[3],$Fields[4]); |
392 | 350 | } |
@@ -403,24 +361,18 @@ discard block |
||
403 | 361 | } |
404 | 362 | |
405 | 363 | /* Dump the image map */ |
406 | - function dumpImageMap($Name="pChart",$StorageMode=IMAGE_MAP_STORAGE_SESSION,$UniqueID="imageMap",$StorageFolder="tmp") |
|
407 | - { |
|
364 | + function dumpImageMap($Name="pChart",$StorageMode=IMAGE_MAP_STORAGE_SESSION,$UniqueID="imageMap",$StorageFolder="tmp") { |
|
408 | 365 | $this->ImageMapIndex = $Name; |
409 | 366 | $this->ImageMapStorageMode = $StorageMode; |
410 | 367 | |
411 | - if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION ) |
|
412 | - { |
|
368 | + if ( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION ) { |
|
413 | 369 | if(!isset($_SESSION)) { session_start(); } |
414 | - if ( $_SESSION[$Name] != NULL ) |
|
415 | - { |
|
370 | + if ( $_SESSION[$Name] != NULL ) { |
|
416 | 371 | foreach($_SESSION[$Name] as $Key => $Params) |
417 | 372 | { echo $Params[0].IMAGE_MAP_DELIMITER.$Params[1].IMAGE_MAP_DELIMITER.$Params[2].IMAGE_MAP_DELIMITER.$Params[3].IMAGE_MAP_DELIMITER.$Params[4]."\r\n"; } |
418 | 373 | } |
419 | - } |
|
420 | - elseif( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_FILE ) |
|
421 | - { |
|
422 | - if (file_exists($StorageFolder."/".$UniqueID.".map")) |
|
423 | - { |
|
374 | + } elseif( $this->ImageMapStorageMode == IMAGE_MAP_STORAGE_FILE ) { |
|
375 | + if (file_exists($StorageFolder."/".$UniqueID.".map")) { |
|
424 | 376 | $Handle = @fopen($StorageFolder."/".$UniqueID.".map", "r"); |
425 | 377 | if ($Handle) { while (($Buffer = fgets($Handle, 4096)) !== false) { echo $Buffer; } } |
426 | 378 | fclose($Handle); |
@@ -434,8 +386,7 @@ discard block |
||
434 | 386 | } |
435 | 387 | |
436 | 388 | /* Return the HTML converted color from the RGB composite values */ |
437 | - function toHTMLColor($R,$G,$B) |
|
438 | - { |
|
389 | + function toHTMLColor($R,$G,$B) { |
|
439 | 390 | $R=intval($R); $G=intval($G); $B=intval($B); |
440 | 391 | $R=dechex($R<0?0:($R>255?255:$R)); $G=dechex($G<0?0:($G>255?255:$G));$B=dechex($B<0?0:($B>255?255:$B)); |
441 | 392 | $Color="#".(strlen($R) < 2?'0':'').$R; $Color.=(strlen($G) < 2?'0':'').$G; $Color.= (strlen($B) < 2?'0':'').$B; |
@@ -443,16 +394,14 @@ discard block |
||
443 | 394 | } |
444 | 395 | |
445 | 396 | /* Reverse an array of points */ |
446 | - function reversePlots($Plots) |
|
447 | - { |
|
397 | + function reversePlots($Plots) { |
|
448 | 398 | $Result = ""; |
449 | 399 | for($i=count($Plots)-2;$i>=0;$i=$i-2) { $Result[] = $Plots[$i]; $Result[] = $Plots[$i+1]; } |
450 | 400 | return($Result); |
451 | 401 | } |
452 | 402 | |
453 | 403 | /* Mirror Effect */ |
454 | - function drawAreaMirror($X,$Y,$Width,$Height,$Format="") |
|
455 | - { |
|
404 | + function drawAreaMirror($X,$Y,$Width,$Height,$Format="") { |
|
456 | 405 | $StartAlpha = isset($Format["StartAlpha"]) ? $Format["StartAlpha"] : 80; |
457 | 406 | $EndAlpha = isset($Format["EndAlpha"]) ? $Format["EndAlpha"] : 0; |
458 | 407 | |
@@ -461,8 +410,7 @@ discard block |
||
461 | 410 | $Picture = imagecreatetruecolor($this->XSize,$this->YSize); |
462 | 411 | imagecopy($Picture,$this->Picture,0,0,0,0,$this->XSize,$this->YSize); |
463 | 412 | |
464 | - for($i=1;$i<=$Height;$i++) |
|
465 | - { |
|
413 | + for($i=1;$i<=$Height;$i++) { |
|
466 | 414 | if ( $Y+($i-1) < $this->YSize && $Y-$i > 0 ) { imagecopymerge($Picture,$this->Picture,$X,$Y+($i-1),$X,$Y-$i,$Width,1,$StartAlpha-$AlphaStep*$i); } |
467 | 415 | } |
468 | 416 |
@@ -14,15 +14,13 @@ discard block |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | /* pData class definition */ |
17 | - class pCache |
|
18 | - { |
|
17 | + class pCache { |
|
19 | 18 | var $CacheFolder; |
20 | 19 | var $CacheIndex; |
21 | 20 | var $CacheDB; |
22 | 21 | |
23 | 22 | /* Class creator */ |
24 | - function pCache($Settings="") |
|
25 | - { |
|
23 | + function pCache($Settings="") { |
|
26 | 24 | $CacheFolder = isset($Settings["CacheFolder"]) ? $Settings["CacheFolder"] : "cache"; |
27 | 25 | $CacheIndex = isset($Settings["CacheIndex"]) ? $Settings["CacheIndex"] : "index.db"; |
28 | 26 | $CacheDB = isset($Settings["CacheDB"]) ? $Settings["CacheDB"] : "cache.db"; |
@@ -36,8 +34,7 @@ discard block |
||
36 | 34 | } |
37 | 35 | |
38 | 36 | /* Flush the cache contents */ |
39 | - function flush() |
|
40 | - { |
|
37 | + function flush() { |
|
41 | 38 | if (file_exists($this->CacheFolder."/".$this->CacheIndex)) { unlink($this->CacheFolder."/".$this->CacheIndex); touch($this->CacheFolder."/".$this->CacheIndex); } |
42 | 39 | if (file_exists($this->CacheFolder."/".$this->CacheDB)) { unlink($this->CacheFolder."/".$this->CacheDB); touch($this->CacheFolder."/".$this->CacheDB); } |
43 | 40 | } |
@@ -47,8 +44,7 @@ discard block |
||
47 | 44 | { return(md5($Marker.serialize($Data->Data))); } |
48 | 45 | |
49 | 46 | /* Write the generated picture to the cache */ |
50 | - function writeToCache($ID,$pChartObject) |
|
51 | - { |
|
47 | + function writeToCache($ID,$pChartObject) { |
|
52 | 48 | /* Compute the paths */ |
53 | 49 | $TemporaryFile = $this->CacheFolder."/tmp_".rand(0,1000).".png"; |
54 | 50 | $Database = $this->CacheFolder."/".$this->CacheDB; |
@@ -89,8 +85,7 @@ discard block |
||
89 | 85 | { $this->dbRemoval(array("Name"=>$ID)); } |
90 | 86 | |
91 | 87 | /* Remove with specified criterias */ |
92 | - function dbRemoval($Settings) |
|
93 | - { |
|
88 | + function dbRemoval($Settings) { |
|
94 | 89 | $ID = isset($Settings["Name"]) ? $Settings["Name"] : NULL; |
95 | 90 | $Expiry = isset($Settings["Expiry"]) ? $Settings["Expiry"] : -(24*60*60); |
96 | 91 | $TS = time()-$Expiry; |
@@ -102,8 +97,7 @@ discard block |
||
102 | 97 | $IndexTemp = $this->CacheFolder."/".$this->CacheIndex.".tmp"; |
103 | 98 | |
104 | 99 | /* Single file removal */ |
105 | - if ( $ID != NULL ) |
|
106 | - { |
|
100 | + if ( $ID != NULL ) { |
|
107 | 101 | /* Retrieve object informations */ |
108 | 102 | $Object = $this->isInCache($ID,TRUE); |
109 | 103 | |
@@ -122,23 +116,20 @@ discard block |
||
122 | 116 | $DBTempHandle = @fopen($DatabaseTemp, "w"); |
123 | 117 | |
124 | 118 | /* Remove the selected ID from the database */ |
125 | - while (!feof($IndexHandle)) |
|
126 | - { |
|
119 | + while (!feof($IndexHandle)) { |
|
127 | 120 | $Entry = fgets($IndexHandle, 4096); |
128 | 121 | $Entry = str_replace("\r","",$Entry); |
129 | 122 | $Entry = str_replace("\n","",$Entry); |
130 | 123 | $Settings = preg_split("/,/",$Entry); |
131 | 124 | |
132 | - if ( $Entry != "" ) |
|
133 | - { |
|
125 | + if ( $Entry != "" ) { |
|
134 | 126 | $PicID = $Settings[0]; |
135 | 127 | $DBPos = $Settings[1]; |
136 | 128 | $PicSize = $Settings[2]; |
137 | 129 | $GeneratedTS = $Settings[3]; |
138 | 130 | $Hits = $Settings[4]; |
139 | 131 | |
140 | - if ( $Settings[0] != $ID && $GeneratedTS > $TS) |
|
141 | - { |
|
132 | + if ( $Settings[0] != $ID && $GeneratedTS > $TS) { |
|
142 | 133 | $CurrentPos = ftell($DBTempHandle); |
143 | 134 | fwrite($IndexTempHandle, $PicID.",".$CurrentPos.",".$PicSize.",".$GeneratedTS.",".$Hits."\r\n"); |
144 | 135 | |
@@ -164,23 +155,19 @@ discard block |
||
164 | 155 | rename($IndexTemp,$Index); |
165 | 156 | } |
166 | 157 | |
167 | - function isInCache($ID,$Verbose=FALSE,$UpdateHitsCount=FALSE) |
|
168 | - { |
|
158 | + function isInCache($ID,$Verbose=FALSE,$UpdateHitsCount=FALSE) { |
|
169 | 159 | /* Compute the paths */ |
170 | 160 | $Index = $this->CacheFolder."/".$this->CacheIndex; |
171 | 161 | |
172 | 162 | /* Search the picture in the index file */ |
173 | 163 | $Handle = @fopen($Index, "r"); |
174 | - while (!feof($Handle)) |
|
175 | - { |
|
164 | + while (!feof($Handle)) { |
|
176 | 165 | $IndexPos = ftell($Handle); |
177 | 166 | $Entry = fgets($Handle, 4096); |
178 | - if ( $Entry != "" ) |
|
179 | - { |
|
167 | + if ( $Entry != "" ) { |
|
180 | 168 | $Settings = preg_split("/,/",$Entry); |
181 | 169 | $PicID = $Settings[0]; |
182 | - if ( $PicID == $ID ) |
|
183 | - { |
|
170 | + if ( $PicID == $ID ) { |
|
184 | 171 | fclose($Handle); |
185 | 172 | |
186 | 173 | $DBPos = $Settings[1]; |
@@ -188,8 +175,7 @@ discard block |
||
188 | 175 | $GeneratedTS = $Settings[3]; |
189 | 176 | $Hits = intval($Settings[4]); |
190 | 177 | |
191 | - if ( $UpdateHitsCount ) |
|
192 | - { |
|
178 | + if ( $UpdateHitsCount ) { |
|
193 | 179 | $Hits++; |
194 | 180 | if ( strlen($Hits) < 7 ) { $Hits = $Hits.str_repeat(" ",7-strlen($Hits)); } |
195 | 181 | |
@@ -200,8 +186,7 @@ discard block |
||
200 | 186 | } |
201 | 187 | |
202 | 188 | if ($Verbose) |
203 | - { return(array("DBPos"=>$DBPos,"PicSize"=>$PicSize,"GeneratedTS"=>$GeneratedTS,"Hits"=>$Hits)); } |
|
204 | - else |
|
189 | + { return(array("DBPos"=>$DBPos,"PicSize"=>$PicSize,"GeneratedTS"=>$GeneratedTS,"Hits"=>$Hits)); } else |
|
205 | 190 | { return(TRUE); } |
206 | 191 | } |
207 | 192 | } |
@@ -213,16 +198,14 @@ discard block |
||
213 | 198 | } |
214 | 199 | |
215 | 200 | /* Automatic output method based on the calling interface */ |
216 | - function autoOutput($ID,$Destination="output.png") |
|
217 | - { |
|
201 | + function autoOutput($ID,$Destination="output.png") { |
|
218 | 202 | if (php_sapi_name() == "cli") |
219 | 203 | $this->saveFromCache($ID,$Destination); |
220 | 204 | else |
221 | 205 | $this->strokeFromCache($ID); |
222 | 206 | } |
223 | 207 | |
224 | - function strokeFromCache($ID) |
|
225 | - { |
|
208 | + function strokeFromCache($ID) { |
|
226 | 209 | /* Get the raw picture from the cache */ |
227 | 210 | $Picture = $this->getFromCache($ID); |
228 | 211 | |
@@ -235,8 +218,7 @@ discard block |
||
235 | 218 | return(TRUE); |
236 | 219 | } |
237 | 220 | |
238 | - function saveFromCache($ID,$Destination) |
|
239 | - { |
|
221 | + function saveFromCache($ID,$Destination) { |
|
240 | 222 | /* Get the raw picture from the cache */ |
241 | 223 | $Picture = $this->getFromCache($ID); |
242 | 224 | |
@@ -252,8 +234,7 @@ discard block |
||
252 | 234 | return(TRUE); |
253 | 235 | } |
254 | 236 | |
255 | - function getFromCache($ID) |
|
256 | - { |
|
237 | + function getFromCache($ID) { |
|
257 | 238 | /* Compute the path */ |
258 | 239 | $Database = $this->CacheFolder."/".$this->CacheDB; |
259 | 240 |
@@ -23,19 +23,16 @@ discard block |
||
23 | 23 | define("INDICATOR_VALUE_LABEL" , 700022); |
24 | 24 | |
25 | 25 | /* pIndicator class definition */ |
26 | - class pIndicator |
|
27 | - { |
|
26 | + class pIndicator { |
|
28 | 27 | var $pChartObject; |
29 | 28 | |
30 | 29 | /* Class creator */ |
31 | - function pIndicator($pChartObject) |
|
32 | - { |
|
30 | + function pIndicator($pChartObject) { |
|
33 | 31 | $this->pChartObject = $pChartObject; |
34 | 32 | } |
35 | 33 | |
36 | 34 | /* Draw an indicator */ |
37 | - function draw($X,$Y,$Width,$Height,$Format="") |
|
38 | - { |
|
35 | + function draw($X,$Y,$Width,$Height,$Format="") { |
|
39 | 36 | $Values = isset($Format["Values"]) ? $Format["Values"] : VOID; |
40 | 37 | $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL; |
41 | 38 | $ValueDisplay = isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE; |
@@ -70,8 +67,7 @@ discard block |
||
70 | 67 | |
71 | 68 | /* Determine indicator visual configuration */ |
72 | 69 | $OverallMin = $IndicatorSections[0]["End"]; $OverallMax = $IndicatorSections[0]["Start"]; |
73 | - foreach ($IndicatorSections as $Key => $Settings) |
|
74 | - { |
|
70 | + foreach ($IndicatorSections as $Key => $Settings) { |
|
75 | 71 | if ( $Settings["End"] > $OverallMax ) { $OverallMax = $Settings["End"]; } |
76 | 72 | if ( $Settings["Start"] < $OverallMin ) { $OverallMin = $Settings["Start"]; } |
77 | 73 | } |
@@ -79,16 +75,14 @@ discard block |
||
79 | 75 | $XScale = $RealWidth / ($OverallMax-$OverallMin); |
80 | 76 | |
81 | 77 | $X1 = $X; $ValuesPos = ""; |
82 | - foreach ($IndicatorSections as $Key => $Settings) |
|
83 | - { |
|
78 | + foreach ($IndicatorSections as $Key => $Settings) { |
|
84 | 79 | $Color = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"]); |
85 | 80 | $Caption = $Settings["Caption"]; |
86 | 81 | $SubCaption = $Settings["Start"]." - ".$Settings["End"]; |
87 | 82 | |
88 | 83 | $X2 = $X1 + ($Settings["End"] - $Settings["Start"]) * $XScale; |
89 | 84 | |
90 | - if ( $Key == 0 && $DrawLeftHead ) |
|
91 | - { |
|
85 | + if ( $Key == 0 && $DrawLeftHead ) { |
|
92 | 86 | $Poly = ""; $Poly[] = $X1-1; $Poly[] = $Y; $Poly[] = $X1-1; $Poly[] = $Y+$Height; $Poly[] = $X1-1-$HeadSize; $Poly[] = $Y+($Height/2); |
93 | 87 | $this->pChartObject->drawPolygon($Poly,$Color); |
94 | 88 | $this->pChartObject->drawLine($X1-2,$Y,$X1-2-$HeadSize,$Y+($Height/2),$Color); |
@@ -97,30 +91,23 @@ discard block |
||
97 | 91 | |
98 | 92 | /* Determine the position of the breaks */ |
99 | 93 | $Break = ""; |
100 | - foreach($Values as $iKey => $Value) |
|
101 | - { |
|
102 | - if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
103 | - { |
|
94 | + foreach($Values as $iKey => $Value) { |
|
95 | + if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) { |
|
104 | 96 | $XBreak = $X1 + ($Value - $Settings["Start"]) * $XScale; |
105 | 97 | $ValuesPos[$Value] = $XBreak; |
106 | 98 | $Break[] = floor($XBreak); |
107 | 99 | } |
108 | 100 | } |
109 | 101 | |
110 | - if ( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
111 | - { |
|
102 | + if ( $ValueDisplay == INDICATOR_VALUE_LABEL ) { |
|
112 | 103 | if ( $Break == "" ) |
113 | 104 | $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
114 | - else |
|
115 | - { |
|
105 | + else { |
|
116 | 106 | sort($Break); |
117 | 107 | $Poly = ""; $Poly[] = $X1; $Poly[] = $Y; $LastPointWritten = FALSE; |
118 | - foreach($Break as $iKey => $Value) |
|
119 | - { |
|
108 | + foreach($Break as $iKey => $Value) { |
|
120 | 109 | if ( $Value-5 >= $X1 ) |
121 | - { $Poly[] = $Value-5; $Poly[] = $Y; } |
|
122 | - elseif ($X1 - ($Value-5) > 0 ) |
|
123 | - { |
|
110 | + { $Poly[] = $Value-5; $Poly[] = $Y; } elseif ($X1 - ($Value-5) > 0 ) { |
|
124 | 111 | $Offset = $X1 - ($Value-5); |
125 | 112 | $Poly = ""; $Poly[] = $X1; $Poly[] = $Y + $Offset; |
126 | 113 | } |
@@ -128,9 +115,7 @@ discard block |
||
128 | 115 | $Poly[] = $Value; $Poly[] = $Y+5; |
129 | 116 | |
130 | 117 | if ( $Value+5 <= $X2 ) |
131 | - { $Poly[] = $Value+5; $Poly[] = $Y; } |
|
132 | - elseif (($Value+5) > $X2 ) |
|
133 | - { |
|
118 | + { $Poly[] = $Value+5; $Poly[] = $Y; } elseif (($Value+5) > $X2 ) { |
|
134 | 119 | $Offset = ($Value+5) - $X2; |
135 | 120 | $Poly[] = $X2; $Poly[] = $Y + $Offset; |
136 | 121 | $LastPointWritten = TRUE; |
@@ -143,37 +128,31 @@ discard block |
||
143 | 128 | |
144 | 129 | $this->pChartObject->drawPolygon($Poly,$Color); |
145 | 130 | } |
146 | - } |
|
147 | - else |
|
131 | + } else |
|
148 | 132 | $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
149 | 133 | |
150 | - if ( $Key == count($IndicatorSections)-1 && $DrawRightHead ) |
|
151 | - { |
|
134 | + if ( $Key == count($IndicatorSections)-1 && $DrawRightHead ) { |
|
152 | 135 | $Poly = ""; $Poly[] = $X2+1; $Poly[] = $Y; $Poly[] = $X2+1; $Poly[] = $Y+$Height; $Poly[] = $X2+1+$HeadSize; $Poly[] = $Y+($Height/2); |
153 | 136 | $this->pChartObject->drawPolygon($Poly,$Color); |
154 | 137 | $this->pChartObject->drawLine($X2+1,$Y,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
155 | 138 | $this->pChartObject->drawLine($X2+1,$Y+$Height,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
156 | 139 | } |
157 | 140 | |
158 | - if ( $CaptionPosition == INDICATOR_CAPTION_INSIDE ) |
|
159 | - { |
|
141 | + if ( $CaptionPosition == INDICATOR_CAPTION_INSIDE ) { |
|
160 | 142 | $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
161 | 143 | $YOffset = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding; |
162 | 144 | |
163 | - if ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
164 | - { |
|
145 | + if ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) { |
|
165 | 146 | $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$SubCaption); |
166 | 147 | $YOffset = $YOffset + ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding*2; |
167 | 148 | } |
168 | 149 | |
169 | 150 | $XOffset = $TextPadding; |
170 | - } |
|
171 | - else |
|
151 | + } else |
|
172 | 152 | { $YOffset = 0; $XOffset = 0; } |
173 | 153 | |
174 | 154 | if ( $CaptionColorFactor == NULL ) |
175 | - { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha); } |
|
176 | - else |
|
155 | + { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha); } else |
|
177 | 156 | { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$CaptionColorFactor,"G"=>$Settings["G"]+$CaptionColorFactor,"B"=>$Settings["B"]+$CaptionColorFactor); } |
178 | 157 | |
179 | 158 | if ( $SubCaptionColorFactor == NULL ) |
@@ -186,8 +165,7 @@ discard block |
||
186 | 165 | |
187 | 166 | if ( $CaptionLayout == INDICATOR_CAPTION_DEFAULT ) |
188 | 167 | $this->pChartObject->drawText($X1,$Y+$Height+$TextPadding,$Caption,$CaptionColor); |
189 | - elseif ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
190 | - { |
|
168 | + elseif ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) { |
|
191 | 169 | $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
192 | 170 | $CaptionHeight = $TxtPos[0]["Y"] - $TxtPos[2]["Y"]; |
193 | 171 | |
@@ -203,18 +181,13 @@ discard block |
||
203 | 181 | $RestoreShadow = $this->pChartObject->Shadow; |
204 | 182 | $this->pChartObject->Shadow = FALSE; |
205 | 183 | |
206 | - foreach($Values as $Key => $Value) |
|
207 | - { |
|
208 | - if ( $Value >= $OverallMin && $Value <= $OverallMax ) |
|
209 | - { |
|
210 | - foreach ($IndicatorSections as $Key => $Settings) |
|
211 | - { |
|
212 | - if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
213 | - { |
|
184 | + foreach($Values as $Key => $Value) { |
|
185 | + if ( $Value >= $OverallMin && $Value <= $OverallMax ) { |
|
186 | + foreach ($IndicatorSections as $Key => $Settings) { |
|
187 | + if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) { |
|
214 | 188 | $X1 = $ValuesPos[$Value]; //$X + $Key*$SectionsMargin + ($Value - $OverallMin) * $XScale; |
215 | 189 | |
216 | - if ( $ValueDisplay == INDICATOR_VALUE_BUBBLE ) |
|
217 | - { |
|
190 | + if ( $ValueDisplay == INDICATOR_VALUE_BUBBLE ) { |
|
218 | 191 | $TxtPos = $this->pChartObject->getTextBox($X1,$Y,$ValueFontName,$ValueFontSize,0,$Value.$Unit); |
219 | 192 | $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $TextPadding*4)/2); |
220 | 193 | |
@@ -223,9 +196,7 @@ discard block |
||
223 | 196 | |
224 | 197 | $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontName"=>$ValueFontName,"FontSize"=>$ValueFontSize); |
225 | 198 | $this->pChartObject->drawText($X1-1,$Y-1,$Value.$Unit,$TextSettings); |
226 | - } |
|
227 | - elseif( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
228 | - { |
|
199 | + } elseif( $ValueDisplay == INDICATOR_VALUE_LABEL ) { |
|
229 | 200 | $Caption = ""; |
230 | 201 | $Caption[] = array("Format"=>array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>100),"Caption"=>$Value.$Unit); |
231 | 202 | $this->pChartObject->drawLabelBox(floor($X1),floor($Y)+2,"Value - ".$Settings["Caption"],$Caption); |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | define("EURO_SYMBOL" , utf8_encode("€")); |
53 | 53 | |
54 | 54 | /* pData class definition */ |
55 | - class pData |
|
56 | - { |
|
55 | + class pData { |
|
57 | 56 | var $Data; |
58 | 57 | |
59 | 58 | var $Palette = array("0"=>array("R"=>188,"G"=>224,"B"=>46,"Alpha"=>100), |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | "7"=>array("R"=>224,"G"=>176,"B"=>46,"Alpha"=>100)); |
67 | 66 | |
68 | 67 | /* Class creator */ |
69 | - function pData() |
|
70 | - { |
|
68 | + function pData() { |
|
71 | 69 | $this->Data = ""; |
72 | 70 | $this->Data["XAxisDisplay"] = AXIS_FORMAT_DEFAULT; |
73 | 71 | $this->Data["XAxisFormat"] = NULL; |
@@ -82,21 +80,17 @@ discard block |
||
82 | 80 | } |
83 | 81 | |
84 | 82 | /* Add a single point or an array to the given serie */ |
85 | - function addPoints($Values,$SerieName="Serie1") |
|
86 | - { |
|
83 | + function addPoints($Values,$SerieName="Serie1") { |
|
87 | 84 | if (!isset($this->Data["Series"][$SerieName])) |
88 | 85 | $this->initialise($SerieName); |
89 | 86 | |
90 | - if ( is_array($Values) ) |
|
91 | - { |
|
87 | + if ( is_array($Values) ) { |
|
92 | 88 | foreach($Values as $Key => $Value) |
93 | 89 | { $this->Data["Series"][$SerieName]["Data"][] = $Value; } |
94 | - } |
|
95 | - else |
|
90 | + } else |
|
96 | 91 | $this->Data["Series"][$SerieName]["Data"][] = $Values; |
97 | 92 | |
98 | - if ( $Values != VOID ) |
|
99 | - { |
|
93 | + if ( $Values != VOID ) { |
|
100 | 94 | $StrippedData = $this->stripVOID($this->Data["Series"][$SerieName]["Data"]); |
101 | 95 | if ( empty($StrippedData) ) { $this->Data["Series"][$SerieName]["Max"] = 0; $this->Data["Series"][$SerieName]["Min"] =0; return(0); } |
102 | 96 | $this->Data["Series"][$SerieName]["Max"] = max($StrippedData); |
@@ -113,8 +107,7 @@ discard block |
||
113 | 107 | { if (isset($this->Data["Series"][$Serie]["Data"])) { return(sizeof($this->Data["Series"][$Serie]["Data"])); } else { return(0); } } |
114 | 108 | |
115 | 109 | /* Remove a serie from the pData object */ |
116 | - function removeSerie($Series) |
|
117 | - { |
|
110 | + function removeSerie($Series) { |
|
118 | 111 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
119 | 112 | foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie])) { unset($this->Data["Series"][$Serie]); } } |
120 | 113 | } |
@@ -128,8 +121,7 @@ discard block |
||
128 | 121 | { if (isset($this->Data["Series"][$Serie]["Data"])) { return($this->Data["Series"][$Serie]["Data"]); } else { return(NULL); } } |
129 | 122 | |
130 | 123 | /* Reverse the values in the given serie */ |
131 | - function reverseSerie($Series) |
|
132 | - { |
|
124 | + function reverseSerie($Series) { |
|
133 | 125 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
134 | 126 | foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]["Data"])) { $this->Data["Series"][$Serie]["Data"] = array_reverse($this->Data["Series"][$Serie]["Data"]); } } |
135 | 127 | } |
@@ -147,29 +139,25 @@ discard block |
||
147 | 139 | { if (isset($this->Data["Series"][$Serie]["Min"])) { return($this->Data["Series"][$Serie]["Min"]); } else { return(NULL); } } |
148 | 140 | |
149 | 141 | /* Set the description of a given serie */ |
150 | - function setSerieShape($Series,$Shape=SERIE_SHAPE_FILLEDCIRCLE) |
|
151 | - { |
|
142 | + function setSerieShape($Series,$Shape=SERIE_SHAPE_FILLEDCIRCLE) { |
|
152 | 143 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
153 | 144 | foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Shape"] = $Shape; } } |
154 | 145 | } |
155 | 146 | |
156 | 147 | /* Set the description of a given serie */ |
157 | - function setSerieDescription($Series,$Description="My serie") |
|
158 | - { |
|
148 | + function setSerieDescription($Series,$Description="My serie") { |
|
159 | 149 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
160 | 150 | foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Description"] = $Description; } } |
161 | 151 | } |
162 | 152 | |
163 | 153 | /* Set a serie as "drawable" while calling a rendering function */ |
164 | - function setSerieDrawable($Series,$Drawable=TRUE) |
|
165 | - { |
|
154 | + function setSerieDrawable($Series,$Drawable=TRUE) { |
|
166 | 155 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
167 | 156 | foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["isDrawable"] = $Drawable; } } |
168 | 157 | } |
169 | 158 | |
170 | 159 | /* Set the icon associated to a given serie */ |
171 | - function setSeriePicture($Series,$Picture=NULL) |
|
172 | - { |
|
160 | + function setSeriePicture($Series,$Picture=NULL) { |
|
173 | 161 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
174 | 162 | foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Picture"] = $Picture; } } |
175 | 163 | } |
@@ -226,15 +214,13 @@ discard block |
||
226 | 214 | { if ( isset($this->Data["ScatterSeries"][$ID]) ) { $this->Data["ScatterSeries"][$ID]["Weight"] = $Weight; } } |
227 | 215 | |
228 | 216 | /* Associate a color to a scatter serie */ |
229 | - function setScatterSerieColor($ID,$Format) |
|
230 | - { |
|
217 | + function setScatterSerieColor($ID,$Format) { |
|
231 | 218 | $R = isset($Format["R"]) ? $Format["R"] : 0; |
232 | 219 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
233 | 220 | $B = isset($Format["B"]) ? $Format["B"] : 0; |
234 | 221 | $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
235 | 222 | |
236 | - if ( isset($this->Data["ScatterSeries"][$ID]) ) |
|
237 | - { |
|
223 | + if ( isset($this->Data["ScatterSeries"][$ID]) ) { |
|
238 | 224 | $this->Data["ScatterSeries"][$ID]["Color"]["R"] = $R; |
239 | 225 | $this->Data["ScatterSeries"][$ID]["Color"]["G"] = $G; |
240 | 226 | $this->Data["ScatterSeries"][$ID]["Color"]["B"] = $B; |
@@ -243,15 +229,12 @@ discard block |
||
243 | 229 | } |
244 | 230 | |
245 | 231 | /* Compute the series limits for an individual and global point of view */ |
246 | - function limits() |
|
247 | - { |
|
232 | + function limits() { |
|
248 | 233 | $GlobalMin = ABSOLUTE_MAX; |
249 | 234 | $GlobalMax = ABSOLUTE_MIN; |
250 | 235 | |
251 | - foreach($this->Data["Series"] as $Key => $Value) |
|
252 | - { |
|
253 | - if ( $this->Data["Abscissa"] != $Key && $this->Data["Series"][$Key]["isDrawable"] == TRUE) |
|
254 | - { |
|
236 | + foreach($this->Data["Series"] as $Key => $Value) { |
|
237 | + if ( $this->Data["Abscissa"] != $Key && $this->Data["Series"][$Key]["isDrawable"] == TRUE) { |
|
255 | 238 | if ( $GlobalMin > $this->Data["Series"][$Key]["Min"] ) { $GlobalMin = $this->Data["Series"][$Key]["Min"]; } |
256 | 239 | if ( $GlobalMax < $this->Data["Series"][$Key]["Max"] ) { $GlobalMax = $this->Data["Series"][$Key]["Max"]; } |
257 | 240 | } |
@@ -267,68 +250,55 @@ discard block |
||
267 | 250 | { foreach($this->Data["Series"] as $Key => $Value) { if ( $this->Data["Abscissa"] != $Key ) { $this->Data["Series"][$Key]["isDrawable"]=TRUE; } } } |
268 | 251 | |
269 | 252 | /* Return the average value of the given serie */ |
270 | - function getSerieAverage($Serie) |
|
271 | - { |
|
272 | - if ( isset($this->Data["Series"][$Serie]) ) |
|
273 | - { |
|
253 | + function getSerieAverage($Serie) { |
|
254 | + if ( isset($this->Data["Series"][$Serie]) ) { |
|
274 | 255 | $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); |
275 | 256 | return(array_sum($SerieData)/sizeof($SerieData)); |
276 | - } |
|
277 | - else |
|
257 | + } else |
|
278 | 258 | return(NULL); |
279 | 259 | } |
280 | 260 | |
281 | 261 | /* Return the geometric mean of the given serie */ |
282 | - function getGeometricMean($Serie) |
|
283 | - { |
|
284 | - if ( isset($this->Data["Series"][$Serie]) ) |
|
285 | - { |
|
262 | + function getGeometricMean($Serie) { |
|
263 | + if ( isset($this->Data["Series"][$Serie]) ) { |
|
286 | 264 | $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); |
287 | 265 | $Seriesum = 1; foreach($SerieData as $Key => $Value) { $Seriesum = $Seriesum * $Value; } |
288 | 266 | return(pow($Seriesum,1/sizeof($SerieData))); |
289 | - } |
|
290 | - else |
|
267 | + } else |
|
291 | 268 | return(NULL); |
292 | 269 | } |
293 | 270 | |
294 | 271 | /* Return the harmonic mean of the given serie */ |
295 | - function getHarmonicMean($Serie) |
|
296 | - { |
|
297 | - if ( isset($this->Data["Series"][$Serie]) ) |
|
298 | - { |
|
272 | + function getHarmonicMean($Serie) { |
|
273 | + if ( isset($this->Data["Series"][$Serie]) ) { |
|
299 | 274 | $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); |
300 | 275 | $Seriesum = 0; foreach($SerieData as $Key => $Value) { $Seriesum = $Seriesum + 1/$Value; } |
301 | 276 | return(sizeof($SerieData)/$Seriesum); |
302 | - } |
|
303 | - else |
|
277 | + } else |
|
304 | 278 | return(NULL); |
305 | 279 | } |
306 | 280 | |
307 | 281 | /* Return the standard deviation of the given serie */ |
308 | - function getStandardDeviation($Serie) |
|
309 | - { |
|
310 | - if ( isset($this->Data["Series"][$Serie]) ) |
|
311 | - { |
|
282 | + function getStandardDeviation($Serie) { |
|
283 | + if ( isset($this->Data["Series"][$Serie]) ) { |
|
312 | 284 | $Average = $this->getSerieAverage($Serie); |
313 | 285 | $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); |
314 | 286 | |
315 | 287 | $DeviationSum = 0; |
316 | - foreach($SerieData as $Key => $Value) |
|
317 | - $DeviationSum = $DeviationSum + ($Value-$Average)*($Value-$Average); |
|
288 | + foreach($SerieData as $Key => $Value) { |
|
289 | + $DeviationSum = $DeviationSum + ($Value-$Average)*($Value-$Average); |
|
290 | + } |
|
318 | 291 | |
319 | 292 | $Deviation = sqrt($DeviationSum/count($SerieData)); |
320 | 293 | |
321 | 294 | return($Deviation); |
322 | - } |
|
323 | - else |
|
295 | + } else |
|
324 | 296 | return(NULL); |
325 | 297 | } |
326 | 298 | |
327 | 299 | /* Return the Coefficient of variation of the given serie */ |
328 | - function getCoefficientOfVariation($Serie) |
|
329 | - { |
|
330 | - if ( isset($this->Data["Series"][$Serie]) ) |
|
331 | - { |
|
300 | + function getCoefficientOfVariation($Serie) { |
|
301 | + if ( isset($this->Data["Series"][$Serie]) ) { |
|
332 | 302 | $Average = $this->getSerieAverage($Serie); |
333 | 303 | $StandardDeviation = $this->getStandardDeviation($Serie); |
334 | 304 | |
@@ -336,16 +306,13 @@ discard block |
||
336 | 306 | return($StandardDeviation/$Average); |
337 | 307 | else |
338 | 308 | return(NULL); |
339 | - } |
|
340 | - else |
|
309 | + } else |
|
341 | 310 | return(NULL); |
342 | 311 | } |
343 | 312 | |
344 | 313 | /* Return the median value of the given serie */ |
345 | - function getSerieMedian($Serie) |
|
346 | - { |
|
347 | - if ( isset($this->Data["Series"][$Serie]) ) |
|
348 | - { |
|
314 | + function getSerieMedian($Serie) { |
|
315 | + if ( isset($this->Data["Series"][$Serie]) ) { |
|
349 | 316 | $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]); |
350 | 317 | sort($SerieData); |
351 | 318 | $SerieCenter = floor(sizeof($SerieData)/2); |
@@ -354,14 +321,12 @@ discard block |
||
354 | 321 | return($SerieData[$SerieCenter]); |
355 | 322 | else |
356 | 323 | return(NULL); |
357 | - } |
|
358 | - else |
|
324 | + } else |
|
359 | 325 | return(NULL); |
360 | 326 | } |
361 | 327 | |
362 | 328 | /* Return the x th percentil of the given serie */ |
363 | - function getSeriePercentile($Serie="Serie1",$Percentil=95) |
|
364 | - { |
|
329 | + function getSeriePercentile($Serie="Serie1",$Percentil=95) { |
|
365 | 330 | if (!isset($this->Data["Series"][$Serie]["Data"])) { return(NULL); } |
366 | 331 | |
367 | 332 | $Values = count($this->Data["Series"][$Serie]["Data"])-1; |
@@ -378,23 +343,20 @@ discard block |
||
378 | 343 | } |
379 | 344 | |
380 | 345 | /* Add random values to a given serie */ |
381 | - function addRandomValues($SerieName="Serie1",$Options="") |
|
382 | - { |
|
346 | + function addRandomValues($SerieName="Serie1",$Options="") { |
|
383 | 347 | $Values = isset($Options["Values"]) ? $Options["Values"] : 20; |
384 | 348 | $Min = isset($Options["Min"]) ? $Options["Min"] : 0; |
385 | 349 | $Max = isset($Options["Max"]) ? $Options["Max"] : 100; |
386 | 350 | $withFloat = isset($Options["withFloat"]) ? $Options["withFloat"] : FALSE; |
387 | 351 | |
388 | - for ($i=0;$i<=$Values;$i++) |
|
389 | - { |
|
352 | + for ($i=0;$i<=$Values;$i++) { |
|
390 | 353 | if ( $withFloat ) { $Value = rand($Min*100,$Max*100)/100; } else { $Value = rand($Min,$Max); } |
391 | 354 | $this->addPoints($Value,$SerieName); |
392 | 355 | } |
393 | 356 | } |
394 | 357 | |
395 | 358 | /* Test if we have valid data */ |
396 | - function containsData() |
|
397 | - { |
|
359 | + function containsData() { |
|
398 | 360 | if (!isset($this->Data["Series"])) { return(FALSE); } |
399 | 361 | |
400 | 362 | $Result = FALSE; |
@@ -404,10 +366,8 @@ discard block |
||
404 | 366 | } |
405 | 367 | |
406 | 368 | /* Set the display mode of an Axis */ |
407 | - function setAxisDisplay($AxisID,$Mode=AXIS_FORMAT_DEFAULT,$Format=NULL) |
|
408 | - { |
|
409 | - if ( isset($this->Data["Axis"][$AxisID] ) ) |
|
410 | - { |
|
369 | + function setAxisDisplay($AxisID,$Mode=AXIS_FORMAT_DEFAULT,$Format=NULL) { |
|
370 | + if ( isset($this->Data["Axis"][$AxisID] ) ) { |
|
411 | 371 | $this->Data["Axis"][$AxisID]["Display"] = $Mode; |
412 | 372 | if ( $Format != NULL ) { $this->Data["Axis"][$AxisID]["Format"] = $Format; } |
413 | 373 | } |
@@ -426,15 +386,13 @@ discard block |
||
426 | 386 | { if ( isset($this->Data["Axis"][$AxisID] ) ) { $this->Data["Axis"][$AxisID]["Name"] = $Name; } } |
427 | 387 | |
428 | 388 | /* Associate a color to an axis */ |
429 | - function setAxisColor($AxisID,$Format) |
|
430 | - { |
|
389 | + function setAxisColor($AxisID,$Format) { |
|
431 | 390 | $R = isset($Format["R"]) ? $Format["R"] : 0; |
432 | 391 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
433 | 392 | $B = isset($Format["B"]) ? $Format["B"] : 0; |
434 | 393 | $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
435 | 394 | |
436 | - if ( isset($this->Data["Axis"][$AxisID] ) ) |
|
437 | - { |
|
395 | + if ( isset($this->Data["Axis"][$AxisID] ) ) { |
|
438 | 396 | $this->Data["Axis"][$AxisID]["Color"]["R"] = $R; |
439 | 397 | $this->Data["Axis"][$AxisID]["Color"]["G"] = $G; |
440 | 398 | $this->Data["Axis"][$AxisID]["Color"]["B"] = $B; |
@@ -448,11 +406,9 @@ discard block |
||
448 | 406 | { if ( isset($this->Data["Axis"][$AxisID] ) ) { $this->Data["Axis"][$AxisID]["Identity"] = $Identity; } } |
449 | 407 | |
450 | 408 | /* Associate one data serie with one axis */ |
451 | - function setSerieOnAxis($Series,$AxisID) |
|
452 | - { |
|
409 | + function setSerieOnAxis($Series,$AxisID) { |
|
453 | 410 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
454 | - foreach($Series as $Key => $Serie) |
|
455 | - { |
|
411 | + foreach($Series as $Key => $Serie) { |
|
456 | 412 | $PreviousAxis = $this->Data["Series"][$Serie]["Axis"]; |
457 | 413 | |
458 | 414 | /* Create missing axis */ |
@@ -469,22 +425,19 @@ discard block |
||
469 | 425 | } |
470 | 426 | |
471 | 427 | /* Define if a serie should be draw with ticks */ |
472 | - function setSerieTicks($Series,$Width=0) |
|
473 | - { |
|
428 | + function setSerieTicks($Series,$Width=0) { |
|
474 | 429 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
475 | 430 | foreach($Series as $Key => $Serie) { if ( isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Ticks"] = $Width; } } |
476 | 431 | } |
477 | 432 | |
478 | 433 | /* Define if a serie should be draw with a special weight */ |
479 | - function setSerieWeight($Series,$Weight=0) |
|
480 | - { |
|
434 | + function setSerieWeight($Series,$Weight=0) { |
|
481 | 435 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
482 | 436 | foreach($Series as $Key => $Serie) { if ( isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Weight"] = $Weight; } } |
483 | 437 | } |
484 | 438 | |
485 | 439 | /* Returns the palette of the given serie */ |
486 | - function getSeriePalette($Serie) |
|
487 | - { |
|
440 | + function getSeriePalette($Serie) { |
|
488 | 441 | if ( !isset($this->Data["Series"][$Serie]) ) { return(NULL); } |
489 | 442 | |
490 | 443 | $Result = ""; |
@@ -497,19 +450,16 @@ discard block |
||
497 | 450 | } |
498 | 451 | |
499 | 452 | /* Set the color of one serie */ |
500 | - function setPalette($Series,$Format=NULL) |
|
501 | - { |
|
453 | + function setPalette($Series,$Format=NULL) { |
|
502 | 454 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
503 | 455 | |
504 | - foreach($Series as $Key => $Serie) |
|
505 | - { |
|
456 | + foreach($Series as $Key => $Serie) { |
|
506 | 457 | $R = isset($Format["R"]) ? $Format["R"] : 0; |
507 | 458 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
508 | 459 | $B = isset($Format["B"]) ? $Format["B"] : 0; |
509 | 460 | $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
510 | 461 | |
511 | - if ( isset($this->Data["Series"][$Serie]) ) |
|
512 | - { |
|
462 | + if ( isset($this->Data["Series"][$Serie]) ) { |
|
513 | 463 | $OldR = $this->Data["Series"][$Serie]["Color"]["R"]; $OldG = $this->Data["Series"][$Serie]["Color"]["G"]; $OldB = $this->Data["Series"][$Serie]["Color"]["B"]; |
514 | 464 | $this->Data["Series"][$Serie]["Color"]["R"] = $R; |
515 | 465 | $this->Data["Series"][$Serie]["Color"]["G"] = $G; |
@@ -524,18 +474,15 @@ discard block |
||
524 | 474 | } |
525 | 475 | |
526 | 476 | /* Load a palette file */ |
527 | - function loadPalette($FileName,$Overwrite=FALSE) |
|
528 | - { |
|
477 | + function loadPalette($FileName,$Overwrite=FALSE) { |
|
529 | 478 | if ( !file_exists($FileName) ) { return(-1); } |
530 | 479 | if ( $Overwrite ) { $this->Palette = ""; } |
531 | 480 | |
532 | 481 | $fileHandle = @fopen($FileName, "r"); |
533 | 482 | if (!$fileHandle) { return(-1); } |
534 | - while (!feof($fileHandle)) |
|
535 | - { |
|
483 | + while (!feof($fileHandle)) { |
|
536 | 484 | $buffer = fgets($fileHandle, 4096); |
537 | - if ( preg_match("/,/",$buffer) ) |
|
538 | - { |
|
485 | + if ( preg_match("/,/",$buffer) ) { |
|
539 | 486 | list($R,$G,$B,$Alpha) = preg_split("/,/",$buffer); |
540 | 487 | if ( $this->Palette == "" ) { $ID = 0; } else { $ID = count($this->Palette); } |
541 | 488 | $this->Palette[$ID] = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
@@ -545,10 +492,8 @@ discard block |
||
545 | 492 | |
546 | 493 | /* Apply changes to current series */ |
547 | 494 | $ID = 0; |
548 | - if ( isset($this->Data["Series"])) |
|
549 | - { |
|
550 | - foreach($this->Data["Series"] as $Key => $Value) |
|
551 | - { |
|
495 | + if ( isset($this->Data["Series"])) { |
|
496 | + foreach($this->Data["Series"] as $Key => $Value) { |
|
552 | 497 | if ( !isset($this->Palette[$ID]) ) |
553 | 498 | $this->Data["Series"][$Key]["Color"] = array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>0); |
554 | 499 | else |
@@ -559,8 +504,7 @@ discard block |
||
559 | 504 | } |
560 | 505 | |
561 | 506 | /* Initialise a given scatter serie */ |
562 | - function initScatterSerie($ID) |
|
563 | - { |
|
507 | + function initScatterSerie($ID) { |
|
564 | 508 | if ( isset($this->Data["ScatterSeries"][$ID]) ) { return(0); } |
565 | 509 | |
566 | 510 | $this->Data["ScatterSeries"][$ID]["Description"] = "Scatter ".$ID; |
@@ -571,8 +515,7 @@ discard block |
||
571 | 515 | |
572 | 516 | if ( isset($this->Palette[$ID]) ) |
573 | 517 | $this->Data["ScatterSeries"][$ID]["Color"] = $this->Palette[$ID]; |
574 | - else |
|
575 | - { |
|
518 | + else { |
|
576 | 519 | $this->Data["ScatterSeries"][$ID]["Color"]["R"] = rand(0,255); |
577 | 520 | $this->Data["ScatterSeries"][$ID]["Color"]["G"] = rand(0,255); |
578 | 521 | $this->Data["ScatterSeries"][$ID]["Color"]["B"] = rand(0,255); |
@@ -581,8 +524,7 @@ discard block |
||
581 | 524 | } |
582 | 525 | |
583 | 526 | /* Initialise a given serie */ |
584 | - function initialise($Serie) |
|
585 | - { |
|
527 | + function initialise($Serie) { |
|
586 | 528 | if ( isset($this->Data["Series"]) ) { $ID = count($this->Data["Series"]); } else { $ID = 0; } |
587 | 529 | |
588 | 530 | $this->Data["Series"][$Serie]["Description"] = $Serie; |
@@ -597,8 +539,7 @@ discard block |
||
597 | 539 | |
598 | 540 | if ( isset($this->Palette[$ID]) ) |
599 | 541 | $this->Data["Series"][$Serie]["Color"] = $this->Palette[$ID]; |
600 | - else |
|
601 | - { |
|
542 | + else { |
|
602 | 543 | $this->Data["Series"][$Serie]["Color"]["R"] = rand(0,255); |
603 | 544 | $this->Data["Series"][$Serie]["Color"]["G"] = rand(0,255); |
604 | 545 | $this->Data["Series"][$Serie]["Color"]["B"] = rand(0,255); |
@@ -606,20 +547,16 @@ discard block |
||
606 | 547 | } |
607 | 548 | } |
608 | 549 | |
609 | - function normalize($NormalizationFactor=100,$UnitChange=NULL,$Round=1) |
|
610 | - { |
|
550 | + function normalize($NormalizationFactor=100,$UnitChange=NULL,$Round=1) { |
|
611 | 551 | $Abscissa = $this->Data["Abscissa"]; |
612 | 552 | |
613 | 553 | $SelectedSeries = ""; |
614 | 554 | $MaxVal = 0; |
615 | - foreach($this->Data["Axis"] as $AxisID => $Axis) |
|
616 | - { |
|
555 | + foreach($this->Data["Axis"] as $AxisID => $Axis) { |
|
617 | 556 | if ( $UnitChange != NULL ) { $this->Data["Axis"][$AxisID]["Unit"] = $UnitChange; } |
618 | 557 | |
619 | - foreach($this->Data["Series"] as $SerieName => $Serie) |
|
620 | - { |
|
621 | - if ($Serie["Axis"] == $AxisID && $Serie["isDrawable"] == TRUE && $SerieName != $Abscissa) |
|
622 | - { |
|
558 | + foreach($this->Data["Series"] as $SerieName => $Serie) { |
|
559 | + if ($Serie["Axis"] == $AxisID && $Serie["isDrawable"] == TRUE && $SerieName != $Abscissa) { |
|
623 | 560 | $SelectedSeries[$SerieName] = $SerieName; |
624 | 561 | |
625 | 562 | if ( count($Serie["Data"] ) > $MaxVal ) { $MaxVal = count($Serie["Data"]); } |
@@ -627,22 +564,18 @@ discard block |
||
627 | 564 | } |
628 | 565 | } |
629 | 566 | |
630 | - for($i=0;$i<=$MaxVal-1;$i++) |
|
631 | - { |
|
567 | + for($i=0;$i<=$MaxVal-1;$i++) { |
|
632 | 568 | $Factor = 0; |
633 | - foreach ($SelectedSeries as $Key => $SerieName ) |
|
634 | - { |
|
569 | + foreach ($SelectedSeries as $Key => $SerieName ) { |
|
635 | 570 | $Value = $this->Data["Series"][$SerieName]["Data"][$i]; |
636 | 571 | if ( $Value != VOID ) |
637 | 572 | $Factor = $Factor + abs($Value); |
638 | 573 | } |
639 | 574 | |
640 | - if ( $Factor != 0 ) |
|
641 | - { |
|
575 | + if ( $Factor != 0 ) { |
|
642 | 576 | $Factor = $NormalizationFactor / $Factor; |
643 | 577 | |
644 | - foreach ($SelectedSeries as $Key => $SerieName ) |
|
645 | - { |
|
578 | + foreach ($SelectedSeries as $Key => $SerieName ) { |
|
646 | 579 | $Value = $this->Data["Series"][$SerieName]["Data"][$i]; |
647 | 580 | |
648 | 581 | if ( $Value != VOID && $Factor != $NormalizationFactor ) |
@@ -655,41 +588,33 @@ discard block |
||
655 | 588 | } |
656 | 589 | } |
657 | 590 | |
658 | - foreach ($SelectedSeries as $Key => $SerieName ) |
|
659 | - { |
|
591 | + foreach ($SelectedSeries as $Key => $SerieName ) { |
|
660 | 592 | $this->Data["Series"][$SerieName]["Max"] = max($this->stripVOID($this->Data["Series"][$SerieName]["Data"])); |
661 | 593 | $this->Data["Series"][$SerieName]["Min"] = min($this->stripVOID($this->Data["Series"][$SerieName]["Data"])); |
662 | 594 | } |
663 | 595 | } |
664 | 596 | |
665 | 597 | /* Load data from a CSV (or similar) data source */ |
666 | - function importFromCSV($FileName,$Options="") |
|
667 | - { |
|
598 | + function importFromCSV($FileName,$Options="") { |
|
668 | 599 | $Delimiter = isset($Options["Delimiter"]) ? $Options["Delimiter"] : ","; |
669 | 600 | $GotHeader = isset($Options["GotHeader"]) ? $Options["GotHeader"] : FALSE; |
670 | 601 | $SkipColumns = isset($Options["SkipColumns"]) ? $Options["SkipColumns"] : array(-1); |
671 | 602 | $DefaultSerieName = isset($Options["DefaultSerieName"]) ? $Options["DefaultSerieName"] : "Serie"; |
672 | 603 | |
673 | 604 | $Handle = @fopen($FileName,"r"); |
674 | - if ($Handle) |
|
675 | - { |
|
605 | + if ($Handle) { |
|
676 | 606 | $HeaderParsed = FALSE; $SerieNames = ""; |
677 | - while (!feof($Handle)) |
|
678 | - { |
|
607 | + while (!feof($Handle)) { |
|
679 | 608 | $Buffer = fgets($Handle, 4096); |
680 | 609 | $Buffer = str_replace(chr(10),"",$Buffer); |
681 | 610 | $Buffer = str_replace(chr(13),"",$Buffer); |
682 | 611 | $Values = preg_split("/".$Delimiter."/",$Buffer); |
683 | 612 | |
684 | - if ( $Buffer != "" ) |
|
685 | - { |
|
686 | - if ( $GotHeader && !$HeaderParsed ) |
|
687 | - { |
|
613 | + if ( $Buffer != "" ) { |
|
614 | + if ( $GotHeader && !$HeaderParsed ) { |
|
688 | 615 | foreach($Values as $Key => $Name) { if ( !in_array($Key,$SkipColumns) ) { $SerieNames[$Key] = $Name; } } |
689 | 616 | $HeaderParsed = TRUE; |
690 | - } |
|
691 | - else |
|
692 | - { |
|
617 | + } else { |
|
693 | 618 | if ($SerieNames == "" ) { foreach($Values as $Key => $Name) { if ( !in_array($Key,$SkipColumns) ) { $SerieNames[$Key] = $DefaultSerieName.$Key; } } } |
694 | 619 | foreach($Values as $Key => $Value) { if ( !in_array($Key,$SkipColumns) ) { $this->addPoints($Value,$SerieNames[$Key]); } } |
695 | 620 | } |
@@ -700,8 +625,7 @@ discard block |
||
700 | 625 | } |
701 | 626 | |
702 | 627 | /* Create a dataset based on a formula */ |
703 | - function createFunctionSerie($SerieName,$Formula="",$Options="") |
|
704 | - { |
|
628 | + function createFunctionSerie($SerieName,$Formula="",$Options="") { |
|
705 | 629 | $MinX = isset($Options["MinX"]) ? $Options["MinX"] : -10; |
706 | 630 | $MaxX = isset($Options["MaxX"]) ? $Options["MaxX"] : 10; |
707 | 631 | $XStep = isset($Options["XStep"]) ? $Options["XStep"] : 1; |
@@ -712,8 +636,7 @@ discard block |
||
712 | 636 | if ( $Formula == "" ) { return(0); } |
713 | 637 | |
714 | 638 | $Result = ""; $Abscissa = ""; |
715 | - for($i=$MinX; $i<=$MaxX; $i=$i+$XStep) |
|
716 | - { |
|
639 | + for($i=$MinX; $i<=$MaxX; $i=$i+$XStep) { |
|
717 | 640 | $Expression = "\$return = '!'.(".str_replace("z",$i,$Formula).");"; |
718 | 641 | if ( @eval($Expression) === FALSE ) { $return = VOID; } |
719 | 642 | if ( $return == "!" ) { $return = VOID; } else { $return = $this->right($return,strlen($return)-1); } |
@@ -730,13 +653,10 @@ discard block |
||
730 | 653 | if ( $RecordAbscissa ) { $this->addPoints($Abscissa,$AbscissaSerie); } |
731 | 654 | } |
732 | 655 | |
733 | - function negateValues($Series) |
|
734 | - { |
|
656 | + function negateValues($Series) { |
|
735 | 657 | if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); } |
736 | - foreach($Series as $Key => $SerieName) |
|
737 | - { |
|
738 | - if (isset($this->Data["Series"][$SerieName])) |
|
739 | - { |
|
658 | + foreach($Series as $Key => $SerieName) { |
|
659 | + if (isset($this->Data["Series"][$SerieName])) { |
|
740 | 660 | $Data = ""; |
741 | 661 | foreach($this->Data["Series"][$SerieName]["Data"] as $Key => $Value) |
742 | 662 | { if ( $Value == VOID ) { $Data[] = VOID; } else { $Data[] = -$Value; } } |
@@ -17,21 +17,18 @@ discard block |
||
17 | 17 | define("SCATTER_MISSING_Y_SERIE" , 190002); |
18 | 18 | |
19 | 19 | /* pScatter class definition */ |
20 | - class pScatter |
|
21 | - { |
|
20 | + class pScatter { |
|
22 | 21 | var $pChartObject; |
23 | 22 | var $pDataObject; |
24 | 23 | |
25 | 24 | /* Class creator */ |
26 | - function pScatter($pChartObject,$pDataObject) |
|
27 | - { |
|
25 | + function pScatter($pChartObject,$pDataObject) { |
|
28 | 26 | $this->pChartObject = $pChartObject; |
29 | 27 | $this->pDataObject = $pDataObject; |
30 | 28 | } |
31 | 29 | |
32 | 30 | /* Prepare the scale */ |
33 | - function drawScatterScale($Format="") |
|
34 | - { |
|
31 | + function drawScatterScale($Format="") { |
|
35 | 32 | $Mode = isset($Format["Mode"]) ? $Format["Mode"] : SCALE_MODE_FLOATING; |
36 | 33 | $Floating = isset($Format["Floating"]) ? $Format["Floating"] : FALSE; |
37 | 34 | $XLabelsRotation = isset($Format["XLabelsRotation"]) ? $Format["XLabelsRotation"] : 90; |
@@ -80,8 +77,7 @@ discard block |
||
80 | 77 | |
81 | 78 | /* Check if we have at least both one X and Y axis */ |
82 | 79 | $GotXAxis = FALSE; $GotYAxis = FALSE; |
83 | - foreach($this->pDataObject->Data["Axis"] as $AxisID => $AxisSettings) |
|
84 | - { |
|
80 | + foreach($this->pDataObject->Data["Axis"] as $AxisID => $AxisSettings) { |
|
85 | 81 | if ( $AxisSettings["Identity"] == AXIS_X ) { $GotXAxis = TRUE; } |
86 | 82 | if ( $AxisSettings["Identity"] == AXIS_Y ) { $GotYAxis = TRUE; } |
87 | 83 | } |
@@ -93,20 +89,15 @@ discard block |
||
93 | 89 | |
94 | 90 | $Data = $this->pDataObject->getData(); |
95 | 91 | |
96 | - foreach($Data["Axis"] as $AxisID => $AxisSettings) |
|
97 | - { |
|
92 | + foreach($Data["Axis"] as $AxisID => $AxisSettings) { |
|
98 | 93 | if ( $AxisSettings["Identity"] == AXIS_X) |
99 | - { $Width = $this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin*2; } |
|
100 | - else |
|
94 | + { $Width = $this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin*2; } else |
|
101 | 95 | { $Width = $this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1 - $YMargin*2; } |
102 | 96 | |
103 | 97 | $AxisMin = ABSOLUTE_MAX; $AxisMax = OUT_OF_SIGHT; |
104 | - if ( $Mode == SCALE_MODE_FLOATING ) |
|
105 | - { |
|
106 | - foreach($Data["Series"] as $SerieID => $SerieParameter) |
|
107 | - { |
|
108 | - if ( $SerieParameter["Axis"] == $AxisID && $Data["Series"][$SerieID]["isDrawable"] ) |
|
109 | - { |
|
98 | + if ( $Mode == SCALE_MODE_FLOATING ) { |
|
99 | + foreach($Data["Series"] as $SerieID => $SerieParameter) { |
|
100 | + if ( $SerieParameter["Axis"] == $AxisID && $Data["Series"][$SerieID]["isDrawable"] ) { |
|
110 | 101 | $AxisMax = max($AxisMax,$Data["Series"][$SerieID]["Max"]); |
111 | 102 | $AxisMin = min($AxisMin,$Data["Series"][$SerieID]["Min"]); |
112 | 103 | } |
@@ -114,23 +105,18 @@ discard block |
||
114 | 105 | $AutoMargin = (($AxisMax-$AxisMin)/100)*$XReleasePercent; |
115 | 106 | |
116 | 107 | $Data["Axis"][$AxisID]["Min"] = $AxisMin-$AutoMargin; $Data["Axis"][$AxisID]["Max"] = $AxisMax+$AutoMargin; |
117 | - } |
|
118 | - elseif ( $Mode == SCALE_MODE_MANUAL ) |
|
119 | - { |
|
120 | - if ( isset($ManualScale[$AxisID]["Min"]) && isset($ManualScale[$AxisID]["Max"]) ) |
|
121 | - { |
|
108 | + } elseif ( $Mode == SCALE_MODE_MANUAL ) { |
|
109 | + if ( isset($ManualScale[$AxisID]["Min"]) && isset($ManualScale[$AxisID]["Max"]) ) { |
|
122 | 110 | $Data["Axis"][$AxisID]["Min"] = $ManualScale[$AxisID]["Min"]; |
123 | 111 | $Data["Axis"][$AxisID]["Max"] = $ManualScale[$AxisID]["Max"]; |
124 | - } |
|
125 | - else |
|
112 | + } else |
|
126 | 113 | { echo "Manual scale boundaries not set."; exit(); } |
127 | 114 | } |
128 | 115 | |
129 | 116 | /* Full manual scale */ |
130 | 117 | if ( isset($ManualScale[$AxisID]["Rows"]) && isset($ManualScale[$AxisID]["RowHeight"]) ) |
131 | 118 | $Scale = array("Rows"=>$ManualScale[$AxisID]["Rows"],"RowHeight"=>$ManualScale[$AxisID]["RowHeight"],"XMin"=>$ManualScale[$AxisID]["Min"],"XMax"=>$ManualScale[$AxisID]["Max"]); |
132 | - else |
|
133 | - { |
|
119 | + else { |
|
134 | 120 | $MaxDivs = floor($Width/$MinDivHeight); |
135 | 121 | $Scale = $this->pChartObject->computeScale($Data["Axis"][$AxisID]["Min"],$Data["Axis"][$AxisID]["Max"],$MaxDivs,$Factors,$AxisID); |
136 | 122 | } |
@@ -154,34 +140,27 @@ discard block |
||
154 | 140 | /* Set the original boundaries */ |
155 | 141 | $AxisPos["L"] = $this->pChartObject->GraphAreaX1; $AxisPos["R"] = $this->pChartObject->GraphAreaX2; $AxisPos["T"] = $this->pChartObject->GraphAreaY1; $AxisPos["B"] = $this->pChartObject->GraphAreaY2; |
156 | 142 | |
157 | - foreach($Data["Axis"] as $AxisID => $AxisSettings) |
|
158 | - { |
|
159 | - if ( isset($AxisSettings["Color"]) ) |
|
160 | - { |
|
143 | + foreach($Data["Axis"] as $AxisID => $AxisSettings) { |
|
144 | + if ( isset($AxisSettings["Color"]) ) { |
|
161 | 145 | $AxisR = $AxisSettings["Color"]["R"]; $AxisG = $AxisSettings["Color"]["G"]; $AxisB = $AxisSettings["Color"]["B"]; |
162 | 146 | $TickR = $AxisSettings["Color"]["R"]; $TickG = $AxisSettings["Color"]["G"]; $TickB = $AxisSettings["Color"]["B"]; |
163 | 147 | $this->pChartObject->setFontProperties(array("R"=>$AxisSettings["Color"]["R"],"G"=>$AxisSettings["Color"]["G"],"B"=>$AxisSettings["Color"]["B"])); |
164 | - } |
|
165 | - else |
|
166 | - { |
|
148 | + } else { |
|
167 | 149 | $AxisR = $AxisRo; $AxisG = $AxisGo; $AxisB = $AxisBo; |
168 | 150 | $TickR = $TickRo; $TickG = $TickGo; $TickB = $TickBo; |
169 | 151 | $this->pChartObject->setFontProperties(array("R"=>$FontColorRo,"G"=>$FontColorGo,"B"=>$FontColorBo)); |
170 | 152 | } |
171 | 153 | |
172 | 154 | $LastValue = "w00t"; $ID = 1; |
173 | - if ( $AxisSettings["Identity"] == AXIS_X ) |
|
174 | - { |
|
175 | - if ( $AxisSettings["Position"] == AXIS_POSITION_BOTTOM ) |
|
176 | - { |
|
155 | + if ( $AxisSettings["Identity"] == AXIS_X ) { |
|
156 | + if ( $AxisSettings["Position"] == AXIS_POSITION_BOTTOM ) { |
|
177 | 157 | if ( $XLabelsRotation == 0 ) { $LabelAlign = TEXT_ALIGN_TOPMIDDLE; $LabelOffset = 2; } |
178 | 158 | if ( $XLabelsRotation > 0 && $XLabelsRotation < 190 ) { $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $LabelOffset = 5; } |
179 | 159 | if ( $XLabelsRotation == 180 ) { $LabelAlign = TEXT_ALIGN_BOTTOMMIDDLE; $LabelOffset = 5; } |
180 | 160 | if ( $XLabelsRotation > 180 && $XLabelsRotation < 360 ) { $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $LabelOffset = 2; } |
181 | 161 | |
182 | 162 | if ( $Floating ) |
183 | - { $FloatingOffset = $YMargin; $this->pChartObject->drawLine($this->pChartObject->GraphAreaX1+$AxisSettings["Margin"],$AxisPos["B"],$this->pChartObject->GraphAreaX2-$AxisSettings["Margin"],$AxisPos["B"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } |
|
184 | - else |
|
163 | + { $FloatingOffset = $YMargin; $this->pChartObject->drawLine($this->pChartObject->GraphAreaX1+$AxisSettings["Margin"],$AxisPos["B"],$this->pChartObject->GraphAreaX2-$AxisSettings["Margin"],$AxisPos["B"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } else |
|
185 | 164 | { $FloatingOffset = 0; $this->pChartObject->drawLine($this->pChartObject->GraphAreaX1,$AxisPos["B"],$this->pChartObject->GraphAreaX2,$AxisPos["B"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } |
186 | 165 | |
187 | 166 | if ( $DrawArrows ) { $this->pChartObject->drawArrow($this->pChartObject->GraphAreaX2-$AxisSettings["Margin"],$AxisPos["B"],$this->pChartObject->GraphAreaX2+($ArrowSize*2),$AxisPos["B"],array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); } |
@@ -189,8 +168,7 @@ discard block |
||
189 | 168 | $Width = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) - $AxisSettings["Margin"]*2; |
190 | 169 | $Step = $Width / $AxisSettings["Rows"]; $SubTicksSize = $Step /2; $MaxBottom = $AxisPos["B"]; |
191 | 170 | $LastX = NULL; |
192 | - for($i=0;$i<=$AxisSettings["Rows"];$i++) |
|
193 | - { |
|
171 | + for($i=0;$i<=$AxisSettings["Rows"];$i++) { |
|
194 | 172 | $XPos = $this->pChartObject->GraphAreaX1 + $AxisSettings["Margin"] + $Step*$i; |
195 | 173 | $YPos = $AxisPos["B"]; |
196 | 174 | $Value = $this->pChartObject->scaleFormat($AxisSettings["ScaleMin"] + $AxisSettings["RowHeight"]*$i,$AxisSettings["Display"],$AxisSettings["Format"],$AxisSettings["Unit"]); |
@@ -210,8 +188,7 @@ discard block |
||
210 | 188 | $LastX = $XPos; |
211 | 189 | } |
212 | 190 | |
213 | - if ( isset($AxisSettings["Name"]) ) |
|
214 | - { |
|
191 | + if ( isset($AxisSettings["Name"]) ) { |
|
215 | 192 | $YPos = $MaxBottom+2; |
216 | 193 | $XPos = $this->pChartObject->GraphAreaX1+($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1)/2; |
217 | 194 | $Bounds = $this->pChartObject->drawText($XPos,$YPos,$AxisSettings["Name"],array("Align"=>TEXT_ALIGN_TOPMIDDLE)); |
@@ -221,17 +198,14 @@ discard block |
||
221 | 198 | } |
222 | 199 | |
223 | 200 | $AxisPos["B"] = $MaxBottom + $ScaleSpacing; |
224 | - } |
|
225 | - elseif ( $AxisSettings["Position"] == AXIS_POSITION_TOP ) |
|
226 | - { |
|
201 | + } elseif ( $AxisSettings["Position"] == AXIS_POSITION_TOP ) { |
|
227 | 202 | if ( $XLabelsRotation == 0 ) { $LabelAlign = TEXT_ALIGN_BOTTOMMIDDLE; $LabelOffset = 2; } |
228 | 203 | if ( $XLabelsRotation > 0 && $XLabelsRotation < 190 ) { $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $LabelOffset = 2; } |
229 | 204 | if ( $XLabelsRotation == 180 ) { $LabelAlign = TEXT_ALIGN_TOPMIDDLE; $LabelOffset = 5; } |
230 | 205 | if ( $XLabelsRotation > 180 && $SLabelxRotation < 360 ) { $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $LabelOffset = 5; } |
231 | 206 | |
232 | 207 | if ( $Floating ) |
233 | - { $FloatingOffset = $YMargin; $this->pChartObject->drawLine($this->pChartObject->GraphAreaX1+$AxisSettings["Margin"],$AxisPos["T"],$this->pChartObject->GraphAreaX2-$AxisSettings["Margin"],$AxisPos["T"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } |
|
234 | - else |
|
208 | + { $FloatingOffset = $YMargin; $this->pChartObject->drawLine($this->pChartObject->GraphAreaX1+$AxisSettings["Margin"],$AxisPos["T"],$this->pChartObject->GraphAreaX2-$AxisSettings["Margin"],$AxisPos["T"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } else |
|
235 | 209 | { $FloatingOffset = 0; $this->pChartObject->drawLine($this->pChartObject->GraphAreaX1,$AxisPos["T"],$this->pChartObject->GraphAreaX2,$AxisPos["T"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } |
236 | 210 | |
237 | 211 | if ( $DrawArrows ) { $this->pChartObject->drawArrow($this->pChartObject->GraphAreaX2-$AxisSettings["Margin"],$AxisPos["T"],$this->pChartObject->GraphAreaX2+($ArrowSize*2),$AxisPos["T"],array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); } |
@@ -239,8 +213,7 @@ discard block |
||
239 | 213 | $Width = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) - $AxisSettings["Margin"]*2; |
240 | 214 | $Step = $Width / $AxisSettings["Rows"]; $SubTicksSize = $Step /2; $MinTop = $AxisPos["T"]; |
241 | 215 | $LastX = NULL; |
242 | - for($i=0;$i<=$AxisSettings["Rows"];$i++) |
|
243 | - { |
|
216 | + for($i=0;$i<=$AxisSettings["Rows"];$i++) { |
|
244 | 217 | $XPos = $this->pChartObject->GraphAreaX1 + $AxisSettings["Margin"] + $Step*$i; |
245 | 218 | $YPos = $AxisPos["T"]; |
246 | 219 | $Value = $this->pChartObject->scaleFormat($AxisSettings["ScaleMin"] + $AxisSettings["RowHeight"]*$i,$AxisSettings["Display"],$AxisSettings["Format"],$AxisSettings["Unit"]); |
@@ -261,8 +234,7 @@ discard block |
||
261 | 234 | $LastX = $XPos; |
262 | 235 | } |
263 | 236 | |
264 | - if ( isset($AxisSettings["Name"]) ) |
|
265 | - { |
|
237 | + if ( isset($AxisSettings["Name"]) ) { |
|
266 | 238 | $YPos = $MinTop-2; |
267 | 239 | $XPos = $this->pChartObject->GraphAreaX1+($this->pChartObject->GraphAreaX2-$this->pChartObject->GraphAreaX1)/2; |
268 | 240 | $Bounds = $this->pChartObject->drawText($XPos,$YPos,$AxisSettings["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); |
@@ -273,15 +245,11 @@ discard block |
||
273 | 245 | |
274 | 246 | $AxisPos["T"] = $MinTop - $ScaleSpacing; |
275 | 247 | } |
276 | - } |
|
277 | - elseif ( $AxisSettings["Identity"] == AXIS_Y ) |
|
278 | - { |
|
279 | - if ( $AxisSettings["Position"] == AXIS_POSITION_LEFT ) |
|
280 | - { |
|
248 | + } elseif ( $AxisSettings["Identity"] == AXIS_Y ) { |
|
249 | + if ( $AxisSettings["Position"] == AXIS_POSITION_LEFT ) { |
|
281 | 250 | |
282 | 251 | if ( $Floating ) |
283 | - { $FloatingOffset = $XMargin; $this->pChartObject->drawLine($AxisPos["L"],$this->pChartObject->GraphAreaY1+$AxisSettings["Margin"],$AxisPos["L"],$this->pChartObject->GraphAreaY2-$AxisSettings["Margin"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } |
|
284 | - else |
|
252 | + { $FloatingOffset = $XMargin; $this->pChartObject->drawLine($AxisPos["L"],$this->pChartObject->GraphAreaY1+$AxisSettings["Margin"],$AxisPos["L"],$this->pChartObject->GraphAreaY2-$AxisSettings["Margin"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } else |
|
285 | 253 | { $FloatingOffset = 0; $this->pChartObject->drawLine($AxisPos["L"],$this->pChartObject->GraphAreaY1,$AxisPos["L"],$this->pChartObject->GraphAreaY2,array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } |
286 | 254 | |
287 | 255 | if ( $DrawArrows ) { $this->pChartObject->drawArrow($AxisPos["L"],$this->pChartObject->GraphAreaY1+$AxisSettings["Margin"],$AxisPos["L"],$this->pChartObject->GraphAreaY1-($ArrowSize*2),array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); } |
@@ -289,8 +257,7 @@ discard block |
||
289 | 257 | $Height = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) - $AxisSettings["Margin"]*2; |
290 | 258 | $Step = $Height / $AxisSettings["Rows"]; $SubTicksSize = $Step /2; $MinLeft = $AxisPos["L"]; |
291 | 259 | $LastY = NULL; |
292 | - for($i=0;$i<=$AxisSettings["Rows"];$i++) |
|
293 | - { |
|
260 | + for($i=0;$i<=$AxisSettings["Rows"];$i++) { |
|
294 | 261 | $YPos = $this->pChartObject->GraphAreaY2 - $AxisSettings["Margin"] - $Step*$i; |
295 | 262 | $XPos = $AxisPos["L"]; |
296 | 263 | $Value = $this->pChartObject->scaleFormat($AxisSettings["ScaleMin"] + $AxisSettings["RowHeight"]*$i,$AxisSettings["Display"],$AxisSettings["Format"],$AxisSettings["Unit"]); |
@@ -311,8 +278,7 @@ discard block |
||
311 | 278 | $LastY = $YPos; |
312 | 279 | } |
313 | 280 | |
314 | - if ( isset($AxisSettings["Name"]) ) |
|
315 | - { |
|
281 | + if ( isset($AxisSettings["Name"]) ) { |
|
316 | 282 | $XPos = $MinLeft-2; |
317 | 283 | $YPos = $this->pChartObject->GraphAreaY1+($this->pChartObject->GraphAreaY2-$this->pChartObject->GraphAreaY1)/2; |
318 | 284 | $Bounds = $this->pChartObject->drawText($XPos,$YPos,$AxisSettings["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE,"Angle"=>90)); |
@@ -322,13 +288,10 @@ discard block |
||
322 | 288 | } |
323 | 289 | |
324 | 290 | $AxisPos["L"] = $MinLeft - $ScaleSpacing; |
325 | - } |
|
326 | - elseif ( $AxisSettings["Position"] == AXIS_POSITION_RIGHT ) |
|
327 | - { |
|
291 | + } elseif ( $AxisSettings["Position"] == AXIS_POSITION_RIGHT ) { |
|
328 | 292 | |
329 | 293 | if ( $Floating ) |
330 | - { $FloatingOffset = $XMargin; $this->pChartObject->drawLine($AxisPos["R"],$this->pChartObject->GraphAreaY1+$AxisSettings["Margin"],$AxisPos["R"],$this->pChartObject->GraphAreaY2-$AxisSettings["Margin"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } |
|
331 | - else |
|
294 | + { $FloatingOffset = $XMargin; $this->pChartObject->drawLine($AxisPos["R"],$this->pChartObject->GraphAreaY1+$AxisSettings["Margin"],$AxisPos["R"],$this->pChartObject->GraphAreaY2-$AxisSettings["Margin"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } else |
|
332 | 295 | { $FloatingOffset = 0; $this->pChartObject->drawLine($AxisPos["R"],$this->pChartObject->GraphAreaY1,$AxisPos["R"],$this->pChartObject->GraphAreaY2,array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); } |
333 | 296 | |
334 | 297 | if ( $DrawArrows ) { $this->pChartObject->drawArrow($AxisPos["R"],$this->pChartObject->GraphAreaY1+$AxisSettings["Margin"],$AxisPos["R"],$this->pChartObject->GraphAreaY1-($ArrowSize*2),array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); } |
@@ -336,8 +299,7 @@ discard block |
||
336 | 299 | $Height = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) - $AxisSettings["Margin"]*2; |
337 | 300 | $Step = $Height / $AxisSettings["Rows"]; $SubTicksSize = $Step /2; $MaxLeft = $AxisPos["R"]; |
338 | 301 | $LastY = NULL; |
339 | - for($i=0;$i<=$AxisSettings["Rows"];$i++) |
|
340 | - { |
|
302 | + for($i=0;$i<=$AxisSettings["Rows"];$i++) { |
|
341 | 303 | $YPos = $this->pChartObject->GraphAreaY2 - $AxisSettings["Margin"] - $Step*$i; |
342 | 304 | $XPos = $AxisPos["R"]; |
343 | 305 | $Value = $this->pChartObject->scaleFormat($AxisSettings["ScaleMin"] + $AxisSettings["RowHeight"]*$i,$AxisSettings["Display"],$AxisSettings["Format"],$AxisSettings["Unit"]); |
@@ -358,8 +320,7 @@ discard block |
||
358 | 320 | $LastY = $YPos; |
359 | 321 | } |
360 | 322 | |
361 | - if ( isset($AxisSettings["Name"]) ) |
|
362 | - { |
|
323 | + if ( isset($AxisSettings["Name"]) ) { |
|
363 | 324 | $XPos = $MaxLeft+6; |
364 | 325 | $YPos = $this->pChartObject->GraphAreaY1+($this->pChartObject->GraphAreaY2-$this->pChartObject->GraphAreaY1)/2; |
365 | 326 | $Bounds = $this->pChartObject->drawText($XPos,$YPos,$AxisSettings["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE,"Angle"=>270)); |
@@ -377,8 +338,7 @@ discard block |
||
377 | 338 | } |
378 | 339 | |
379 | 340 | /* Draw a scatter plot chart */ |
380 | - function drawScatterPlotChart($Format=NULL) |
|
381 | - { |
|
341 | + function drawScatterPlotChart($Format=NULL) { |
|
382 | 342 | $PlotSize = isset($Format["PlotSize"]) ? $Format["PlotSize"] : 3; |
383 | 343 | $PlotBorder = isset($Format["PlotBorder"]) ? $Format["PlotBorder"] : FALSE; |
384 | 344 | $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 250; |
@@ -396,18 +356,15 @@ discard block |
||
396 | 356 | |
397 | 357 | $BorderColor = array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha); |
398 | 358 | |
399 | - foreach($Data["ScatterSeries"] as $Key => $Series) |
|
400 | - { |
|
401 | - if ( $Series["isDrawable"] == TRUE ) |
|
402 | - { |
|
359 | + foreach($Data["ScatterSeries"] as $Key => $Series) { |
|
360 | + if ( $Series["isDrawable"] == TRUE ) { |
|
403 | 361 | $SerieX = $Series["X"]; $SerieValuesX = $Data["Series"][$SerieX]["Data"]; $SerieXAxis = $Data["Series"][$SerieX]["Axis"]; |
404 | 362 | $SerieY = $Series["Y"]; $SerieValuesY = $Data["Series"][$SerieY]["Data"]; $SerieYAxis = $Data["Series"][$SerieY]["Axis"]; |
405 | 363 | |
406 | 364 | if ( $ImageMapTitle == NULL ) { $Description = $Data["Series"][$Series["X"]]["Description"]." / ".$Data["Series"][$Series["Y"]]["Description"]; } else { $Description = $ImageMapTitle; } |
407 | 365 | |
408 | 366 | if ( isset($Series["Picture"]) && $Series["Picture"] != "" ) |
409 | - { $Picture = $Series["Picture"]; list($PicWidth,$PicHeight,$PicType) = $this->pChartObject->getPicInfo($Picture); } |
|
410 | - else |
|
367 | + { $Picture = $Series["Picture"]; list($PicWidth,$PicHeight,$PicType) = $this->pChartObject->getPicInfo($Picture); } else |
|
411 | 368 | { $Picture = NULL; } |
412 | 369 | |
413 | 370 | $PosArrayX = $this->getPosArray($SerieValuesX,$SerieXAxis); |
@@ -417,23 +374,18 @@ discard block |
||
417 | 374 | |
418 | 375 | $Color = array("R"=>$Series["Color"]["R"],"G"=>$Series["Color"]["G"],"B"=>$Series["Color"]["B"],"Alpha"=>$Series["Color"]["Alpha"]); |
419 | 376 | |
420 | - foreach($PosArrayX as $Key => $Value) |
|
421 | - { |
|
377 | + foreach($PosArrayX as $Key => $Value) { |
|
422 | 378 | $X = $Value; $Y = $PosArrayY[$Key]; |
423 | 379 | |
424 | - if ( $X != VOID && $Y != VOID ) |
|
425 | - { |
|
380 | + if ( $X != VOID && $Y != VOID ) { |
|
426 | 381 | $RealValue = round($Data["Series"][$Series["X"]]["Data"][$Key],2)." / ".round($Data["Series"][$Series["Y"]]["Data"][$Key],2); |
427 | 382 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".floor($PlotSize+$BorderSize),$this->pChartObject->toHTMLColor($Series["Color"]["R"],$Series["Color"]["G"],$Series["Color"]["B"]),$Description,$RealValue); } |
428 | 383 | |
429 | 384 | if( isset($Series["Shape"]) ) |
430 | - { $this->pChartObject->drawShape($X,$Y,$Series["Shape"],$PlotSize,$PlotBorder,$BorderSize,$Series["Color"]["R"],$Series["Color"]["G"],$Series["Color"]["B"],$Series["Color"]["Alpha"],$BorderR,$BorderG,$BorderB,$BorderAlpha); } |
|
431 | - elseif ( $Picture == NULL ) |
|
432 | - { |
|
385 | + { $this->pChartObject->drawShape($X,$Y,$Series["Shape"],$PlotSize,$PlotBorder,$BorderSize,$Series["Color"]["R"],$Series["Color"]["G"],$Series["Color"]["B"],$Series["Color"]["Alpha"],$BorderR,$BorderG,$BorderB,$BorderAlpha); } elseif ( $Picture == NULL ) { |
|
433 | 386 | if ( $PlotBorder ) { $this->pChartObject->drawFilledCircle($X,$Y,$PlotSize+$BorderSize,$BorderColor); } |
434 | 387 | $this->pChartObject->drawFilledCircle($X,$Y,$PlotSize,$Color); |
435 | - } |
|
436 | - else |
|
388 | + } else |
|
437 | 389 | { $this->pChartObject->drawFromPicture($PicType,$Picture,$X-$PicWidth/2,$Y-$PicHeight/2); } |
438 | 390 | } |
439 | 391 | } |
@@ -442,8 +394,7 @@ discard block |
||
442 | 394 | } |
443 | 395 | |
444 | 396 | /* Draw a scatter line chart */ |
445 | - function drawScatterLineChart($Format=NULL) |
|
446 | - { |
|
397 | + function drawScatterLineChart($Format=NULL) { |
|
447 | 398 | $Data = $this->pDataObject->getData(); |
448 | 399 | $Palette = $this->pDataObject->getPalette(); |
449 | 400 | $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE; |
@@ -452,10 +403,8 @@ discard block |
||
452 | 403 | $ImageMapPrecision = isset($Format["ImageMapPrecision"]) ? $Format["ImageMapPrecision"] : 2; |
453 | 404 | |
454 | 405 | /* Parse all the series to draw */ |
455 | - foreach($Data["ScatterSeries"] as $Key => $Series) |
|
456 | - { |
|
457 | - if ( $Series["isDrawable"] == TRUE ) |
|
458 | - { |
|
406 | + foreach($Data["ScatterSeries"] as $Key => $Series) { |
|
407 | + if ( $Series["isDrawable"] == TRUE ) { |
|
459 | 408 | $SerieX = $Series["X"]; $SerieValuesX = $Data["Series"][$SerieX]["Data"]; $SerieXAxis = $Data["Series"][$SerieX]["Axis"]; |
460 | 409 | $SerieY = $Series["Y"]; $SerieValuesY = $Data["Series"][$SerieY]["Data"]; $SerieYAxis = $Data["Series"][$SerieY]["Axis"]; |
461 | 410 | $Ticks = $Series["Ticks"]; |
@@ -473,12 +422,10 @@ discard block |
||
473 | 422 | if ( $Weight != 0 ) { $Color["Weight"] = $Weight; } |
474 | 423 | |
475 | 424 | $LastX = VOID; $LastY = VOID; |
476 | - foreach($PosArrayX as $Key => $Value) |
|
477 | - { |
|
425 | + foreach($PosArrayX as $Key => $Value) { |
|
478 | 426 | $X = $Value; $Y = $PosArrayY[$Key]; |
479 | 427 | |
480 | - if ( $X != VOID && $Y != VOID ) |
|
481 | - { |
|
428 | + if ( $X != VOID && $Y != VOID ) { |
|
482 | 429 | $RealValue = round($Data["Series"][$Series["X"]]["Data"][$Key],2)." / ".round($Data["Series"][$Series["Y"]]["Data"][$Key],2); |
483 | 430 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$ImageMapPlotSize,$this->pChartObject->toHTMLColor($Series["Color"]["R"],$Series["Color"]["G"],$Series["Color"]["B"]),$Description,$RealValue); } |
484 | 431 | } |
@@ -493,8 +440,7 @@ discard block |
||
493 | 440 | } |
494 | 441 | |
495 | 442 | /* Draw a scatter spline chart */ |
496 | - function drawScatterSplineChart($Format=NULL) |
|
497 | - { |
|
443 | + function drawScatterSplineChart($Format=NULL) { |
|
498 | 444 | $Data = $this->pDataObject->getData(); |
499 | 445 | $Palette = $this->pDataObject->getPalette(); |
500 | 446 | $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE; |
@@ -502,10 +448,8 @@ discard block |
||
502 | 448 | $ImageMapPlotSize = isset($Format["ImageMapPlotSize"]) ? $Format["ImageMapPlotSize"] : 10; |
503 | 449 | $ImageMapPrecision = isset($Format["ImageMapPrecision"]) ? $Format["ImageMapPrecision"] : 2; |
504 | 450 | |
505 | - foreach($Data["ScatterSeries"] as $Key => $Series) |
|
506 | - { |
|
507 | - if ( $Series["isDrawable"] == TRUE ) |
|
508 | - { |
|
451 | + foreach($Data["ScatterSeries"] as $Key => $Series) { |
|
452 | + if ( $Series["isDrawable"] == TRUE ) { |
|
509 | 453 | $SerieX = $Series["X"]; $SerieValuesX = $Data["Series"][$SerieX]["Data"]; $SerieXAxis = $Data["Series"][$SerieX]["Axis"]; |
510 | 454 | $SerieY = $Series["Y"]; $SerieValuesY = $Data["Series"][$SerieY]["Data"]; $SerieYAxis = $Data["Series"][$SerieY]["Axis"]; |
511 | 455 | $Ticks = $Series["Ticks"]; |
@@ -523,13 +467,11 @@ discard block |
||
523 | 467 | if ( $Weight != 0 ) { $SplineSettings["Weight"] = $Weight; } |
524 | 468 | |
525 | 469 | $LastX = VOID; $LastY = VOID; $WayPoints = ""; $Forces = ""; |
526 | - foreach($PosArrayX as $Key => $Value) |
|
527 | - { |
|
470 | + foreach($PosArrayX as $Key => $Value) { |
|
528 | 471 | $X = $Value; $Y = $PosArrayY[$Key]; |
529 | 472 | $Force = $this->pChartObject->getLength($LastX,$LastY,$X,$Y)/5; |
530 | 473 | |
531 | - if ( $X != VOID && $Y != VOID ) |
|
532 | - { |
|
474 | + if ( $X != VOID && $Y != VOID ) { |
|
533 | 475 | $RealValue = round($Data["Series"][$Series["X"]]["Data"][$Key],2)." / ".round($Data["Series"][$Series["Y"]]["Data"][$Key],2); |
534 | 476 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$ImageMapPlotSize,$this->pChartObject->toHTMLColor($Series["Color"]["R"],$Series["Color"]["G"],$Series["Color"]["B"]),$Description,$RealValue); } |
535 | 477 | } |
@@ -549,21 +491,18 @@ discard block |
||
549 | 491 | } |
550 | 492 | |
551 | 493 | /* Return the scaled plot position */ |
552 | - function getPosArray($Values,$AxisID) |
|
553 | - { |
|
494 | + function getPosArray($Values,$AxisID) { |
|
554 | 495 | $Data = $this->pDataObject->getData(); |
555 | 496 | |
556 | 497 | if ( !is_array($Values) ) { $Values = array($Values); } |
557 | 498 | |
558 | - if ( $Data["Axis"][$AxisID]["Identity"] == AXIS_X ) |
|
559 | - { |
|
499 | + if ( $Data["Axis"][$AxisID]["Identity"] == AXIS_X ) { |
|
560 | 500 | $Height = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) - $Data["Axis"][$AxisID]["Margin"]*2; |
561 | 501 | $ScaleHeight = $Data["Axis"][$AxisID]["ScaleMax"] - $Data["Axis"][$AxisID]["ScaleMin"]; |
562 | 502 | $Step = $Height / $ScaleHeight; |
563 | 503 | |
564 | 504 | $Result = ""; |
565 | - foreach($Values as $Key => $Value) |
|
566 | - { |
|
505 | + foreach($Values as $Key => $Value) { |
|
567 | 506 | if ( $Value == VOID ) |
568 | 507 | $Result[] = VOID; |
569 | 508 | else |
@@ -571,16 +510,13 @@ discard block |
||
571 | 510 | } |
572 | 511 | |
573 | 512 | if ( count($Result) == 1 ) { return($Result[0]); } else { return($Result); } |
574 | - } |
|
575 | - else |
|
576 | - { |
|
513 | + } else { |
|
577 | 514 | $Height = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) - $Data["Axis"][$AxisID]["Margin"]*2; |
578 | 515 | $ScaleHeight = $Data["Axis"][$AxisID]["ScaleMax"] - $Data["Axis"][$AxisID]["ScaleMin"]; |
579 | 516 | $Step = $Height / $ScaleHeight; |
580 | 517 | |
581 | 518 | $Result = ""; |
582 | - foreach($Values as $Key => $Value) |
|
583 | - { |
|
519 | + foreach($Values as $Key => $Value) { |
|
584 | 520 | if ( $Value == VOID ) |
585 | 521 | $Result[] = VOID; |
586 | 522 | else |
@@ -592,8 +528,7 @@ discard block |
||
592 | 528 | } |
593 | 529 | |
594 | 530 | /* Draw the legend of the active series */ |
595 | - function drawScatterLegend($X,$Y,$Format="") |
|
596 | - { |
|
531 | + function drawScatterLegend($X,$Y,$Format="") { |
|
597 | 532 | $Family = isset($Format["Family"]) ? $Format["Family"] : LEGEND_FAMILY_BOX; |
598 | 533 | $FontName = isset($Format["FontName"]) ? $Format["FontName"] : $this->pChartObject->FontName; |
599 | 534 | $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->pChartObject->FontSize; |
@@ -621,10 +556,8 @@ discard block |
||
621 | 556 | |
622 | 557 | $Data = $this->pDataObject->getData(); |
623 | 558 | |
624 | - foreach($Data["ScatterSeries"] as $Key => $Series) |
|
625 | - { |
|
626 | - if ( $Series["isDrawable"] == TRUE && isset($Series["Picture"])) |
|
627 | - { |
|
559 | + foreach($Data["ScatterSeries"] as $Key => $Series) { |
|
560 | + if ( $Series["isDrawable"] == TRUE && isset($Series["Picture"])) { |
|
628 | 561 | list($PicWidth,$PicHeight) = $this->pChartObject->getPicInfo($Series["Picture"]); |
629 | 562 | if ( $IconAreaWidth < $PicWidth ) { $IconAreaWidth = $PicWidth; } |
630 | 563 | if ( $IconAreaHeight < $PicHeight ) { $IconAreaHeight = $PicHeight; } |
@@ -636,12 +569,9 @@ discard block |
||
636 | 569 | $XStep = $XSpacing; |
637 | 570 | |
638 | 571 | $Boundaries = ""; $Boundaries["L"] = $X; $Boundaries["T"] = $Y; $Boundaries["R"] = 0; $Boundaries["B"] = 0; $vY = $Y; $vX = $X; |
639 | - foreach($Data["ScatterSeries"] as $Key => $Series) |
|
640 | - { |
|
641 | - if ( $Series["isDrawable"] == TRUE ) |
|
642 | - { |
|
643 | - if ( $Mode == LEGEND_VERTICAL ) |
|
644 | - { |
|
572 | + foreach($Data["ScatterSeries"] as $Key => $Series) { |
|
573 | + if ( $Series["isDrawable"] == TRUE ) { |
|
574 | + if ( $Mode == LEGEND_VERTICAL ) { |
|
645 | 575 | $BoxArray = $this->pChartObject->getTextBox($vX+$IconAreaWidth+4,$vY+$IconAreaHeight/2,$FontName,$FontSize,0,$Series["Description"]); |
646 | 576 | |
647 | 577 | if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; } |
@@ -650,13 +580,10 @@ discard block |
||
650 | 580 | |
651 | 581 | $Lines = preg_split("/\n/",$Series["Description"]); |
652 | 582 | $vY = $vY + max($this->pChartObject->FontSize*count($Lines),$IconAreaHeight) + 5; |
653 | - } |
|
654 | - elseif ( $Mode == LEGEND_HORIZONTAL ) |
|
655 | - { |
|
583 | + } elseif ( $Mode == LEGEND_HORIZONTAL ) { |
|
656 | 584 | $Lines = preg_split("/\n/",$Series["Description"]); |
657 | 585 | $Width = ""; |
658 | - foreach($Lines as $Key => $Value) |
|
659 | - { |
|
586 | + foreach($Lines as $Key => $Value) { |
|
660 | 587 | $BoxArray = $this->pChartObject->getTextBox($vX+$IconAreaWidth+6,$Y+$IconAreaHeight/2+(($this->pChartObject->FontSize+3)*$Key),$FontName,$FontSize,0,$Value); |
661 | 588 | |
662 | 589 | if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; } |
@@ -681,57 +608,44 @@ discard block |
||
681 | 608 | $this->pChartObject->drawFilledRectangle($Boundaries["L"]-$Margin,$Boundaries["T"]-$Margin,$Boundaries["R"]+$Margin,$Boundaries["B"]+$Margin,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB)); |
682 | 609 | |
683 | 610 | $RestoreShadow = $this->pChartObject->Shadow; $this->Shadow = FALSE; |
684 | - foreach($Data["ScatterSeries"] as $Key => $Series) |
|
685 | - { |
|
686 | - if ( $Series["isDrawable"] == TRUE ) |
|
687 | - { |
|
611 | + foreach($Data["ScatterSeries"] as $Key => $Series) { |
|
612 | + if ( $Series["isDrawable"] == TRUE ) { |
|
688 | 613 | $R = $Series["Color"]["R"]; $G = $Series["Color"]["G"]; $B = $Series["Color"]["B"]; |
689 | 614 | $Ticks = $Series["Ticks"]; $Weight = $Series["Weight"]; |
690 | 615 | |
691 | - if ( isset($Series["Picture"]) ) |
|
692 | - { |
|
616 | + if ( isset($Series["Picture"]) ) { |
|
693 | 617 | $Picture = $Series["Picture"]; |
694 | 618 | list($PicWidth,$PicHeight) = $this->pChartObject->getPicInfo($Picture); |
695 | 619 | $PicX = $X+$IconAreaWidth/2; $PicY = $Y+$IconAreaHeight/2; |
696 | 620 | |
697 | 621 | $this->pChartObject->drawFromPNG($PicX-$PicWidth/2,$PicY-$PicHeight/2,$Picture); |
698 | - } |
|
699 | - else |
|
700 | - { |
|
701 | - if ( $Family == LEGEND_FAMILY_BOX ) |
|
702 | - { |
|
622 | + } else { |
|
623 | + if ( $Family == LEGEND_FAMILY_BOX ) { |
|
703 | 624 | if ( $BoxWidth != $IconAreaWidth ) { $XOffset = floor(($IconAreaWidth-$BoxWidth)/2); } else { $XOffset = 0; } |
704 | 625 | if ( $BoxHeight != $IconAreaHeight ) { $YOffset = floor(($IconAreaHeight-$BoxHeight)/2); } else { $YOffset = 0; } |
705 | 626 | |
706 | 627 | $this->pChartObject->drawFilledRectangle($X+1+$XOffset,$Y+1+$YOffset,$X+$BoxWidth+$XOffset+1,$Y+$BoxHeight+1+$YOffset,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20)); |
707 | 628 | $this->pChartObject->drawFilledRectangle($X+$XOffset,$Y+$YOffset,$X+$BoxWidth+$XOffset,$Y+$BoxHeight+$YOffset,array("R"=>$R,"G"=>$G,"B"=>$B,"Surrounding"=>20)); |
708 | - } |
|
709 | - elseif ( $Family == LEGEND_FAMILY_CIRCLE ) |
|
710 | - { |
|
629 | + } elseif ( $Family == LEGEND_FAMILY_CIRCLE ) { |
|
711 | 630 | $this->pChartObject->drawFilledCircle($X+1+$IconAreaWidth/2,$Y+1+$IconAreaHeight/2,min($IconAreaHeight/2,$IconAreaWidth/2),array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20)); |
712 | 631 | $this->pChartObject->drawFilledCircle($X+$IconAreaWidth/2,$Y+$IconAreaHeight/2,min($IconAreaHeight/2,$IconAreaWidth/2),array("R"=>$R,"G"=>$G,"B"=>$B,"Surrounding"=>20)); |
713 | - } |
|
714 | - elseif ( $Family == LEGEND_FAMILY_LINE ) |
|
715 | - { |
|
632 | + } elseif ( $Family == LEGEND_FAMILY_LINE ) { |
|
716 | 633 | $this->pChartObject->drawLine($X+1,$Y+1+$IconAreaHeight/2,$X+1+$IconAreaWidth,$Y+1+$IconAreaHeight/2,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20,"Ticks"=>$Ticks,"Weight"=>$Weight)); |
717 | 634 | $this->pChartObject->drawLine($X,$Y+$IconAreaHeight/2,$X+$IconAreaWidth,$Y+$IconAreaHeight/2,array("R"=>$R,"G"=>$G,"B"=>$B,"Ticks"=>$Ticks,"Weight"=>$Weight)); |
718 | 635 | } |
719 | 636 | } |
720 | 637 | |
721 | - if ( $Mode == LEGEND_VERTICAL ) |
|
722 | - { |
|
638 | + if ( $Mode == LEGEND_VERTICAL ) { |
|
723 | 639 | $Lines = preg_split("/\n/",$Series["Description"]); |
724 | - foreach($Lines as $Key => $Value) |
|
725 | - $this->pChartObject->drawText($X+$IconAreaWidth+4,$Y+$IconAreaHeight/2+(($this->pChartObject->FontSize+3)*$Key),$Value,array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_MIDDLELEFT)); |
|
640 | + foreach($Lines as $Key => $Value) { |
|
641 | + $this->pChartObject->drawText($X+$IconAreaWidth+4,$Y+$IconAreaHeight/2+(($this->pChartObject->FontSize+3)*$Key),$Value,array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_MIDDLELEFT)); |
|
642 | + } |
|
726 | 643 | |
727 | 644 | $Y=$Y+max($this->pChartObject->FontSize*count($Lines),$IconAreaHeight) + 5; |
728 | - } |
|
729 | - elseif ( $Mode == LEGEND_HORIZONTAL ) |
|
730 | - { |
|
645 | + } elseif ( $Mode == LEGEND_HORIZONTAL ) { |
|
731 | 646 | $Lines = preg_split("/\n/",$Series["Description"]); |
732 | 647 | $Width = ""; |
733 | - foreach($Lines as $Key => $Value) |
|
734 | - { |
|
648 | + foreach($Lines as $Key => $Value) { |
|
735 | 649 | $BoxArray = $this->pChartObject->drawText($X+$IconAreaWidth+4,$Y+$IconAreaHeight/2+(($this->pChartObject->FontSize+3)*$Key),$Value,array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_MIDDLELEFT)); |
736 | 650 | $Width[] = $BoxArray[1]["X"]; |
737 | 651 | } |
@@ -744,8 +658,7 @@ discard block |
||
744 | 658 | } |
745 | 659 | |
746 | 660 | /* Get the legend box size */ |
747 | - function getScatterLegendSize($Format="") |
|
748 | - { |
|
661 | + function getScatterLegendSize($Format="") { |
|
749 | 662 | $FontName = isset($Format["FontName"]) ? $Format["FontName"] : $this->pChartObject->FontName; |
750 | 663 | $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->pChartObject->FontSize; |
751 | 664 | $BoxSize = isset($Format["BoxSize"]) ? $Format["BoxSize"] : 5; |
@@ -760,10 +673,8 @@ discard block |
||
760 | 673 | |
761 | 674 | $Data = $this->pDataObject->getData(); |
762 | 675 | |
763 | - foreach($Data["ScatterSeries"] as $Key => $Series) |
|
764 | - { |
|
765 | - if ( $Series["isDrawable"] == TRUE && isset($Series["Picture"])) |
|
766 | - { |
|
676 | + foreach($Data["ScatterSeries"] as $Key => $Series) { |
|
677 | + if ( $Series["isDrawable"] == TRUE && isset($Series["Picture"])) { |
|
767 | 678 | list($PicWidth,$PicHeight) = $this->pChartObject->getPicInfo($Series["Picture"]); |
768 | 679 | if ( $IconAreaWidth < $PicWidth ) { $IconAreaWidth = $PicWidth; } |
769 | 680 | if ( $IconAreaHeight < $PicHeight ) { $IconAreaHeight = $PicHeight; } |
@@ -775,12 +686,9 @@ discard block |
||
775 | 686 | $XStep = $XSpacing; |
776 | 687 | |
777 | 688 | $Boundaries = ""; $Boundaries["L"] = $X; $Boundaries["T"] = $Y; $Boundaries["R"] = 0; $Boundaries["B"] = 0; $vY = $Y; $vX = $X; |
778 | - foreach($Data["ScatterSeries"] as $Key => $Series) |
|
779 | - { |
|
780 | - if ( $Series["isDrawable"] == TRUE ) |
|
781 | - { |
|
782 | - if ( $Mode == LEGEND_VERTICAL ) |
|
783 | - { |
|
689 | + foreach($Data["ScatterSeries"] as $Key => $Series) { |
|
690 | + if ( $Series["isDrawable"] == TRUE ) { |
|
691 | + if ( $Mode == LEGEND_VERTICAL ) { |
|
784 | 692 | $BoxArray = $this->pChartObject->getTextBox($vX+$IconAreaWidth+4,$vY+$IconAreaHeight/2,$FontName,$FontSize,0,$Series["Description"]); |
785 | 693 | |
786 | 694 | if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; } |
@@ -789,13 +697,10 @@ discard block |
||
789 | 697 | |
790 | 698 | $Lines = preg_split("/\n/",$Series["Description"]); |
791 | 699 | $vY = $vY + max($this->pChartObject->FontSize*count($Lines),$IconAreaHeight) + 5; |
792 | - } |
|
793 | - elseif ( $Mode == LEGEND_HORIZONTAL ) |
|
794 | - { |
|
700 | + } elseif ( $Mode == LEGEND_HORIZONTAL ) { |
|
795 | 701 | $Lines = preg_split("/\n/",$Series["Description"]); |
796 | 702 | $Width = ""; |
797 | - foreach($Lines as $Key => $Value) |
|
798 | - { |
|
703 | + foreach($Lines as $Key => $Value) { |
|
799 | 704 | $BoxArray = $this->pChartObject->getTextBox($vX+$IconAreaWidth+6,$Y+$IconAreaHeight/2+(($this->pChartObject->FontSize+3)*$Key),$FontName,$FontSize,0,$Value); |
800 | 705 | |
801 | 706 | if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; } |
@@ -821,16 +726,13 @@ discard block |
||
821 | 726 | } |
822 | 727 | |
823 | 728 | /* Draw the line of best fit */ |
824 | - function drawScatterBestFit($Format="") |
|
825 | - { |
|
729 | + function drawScatterBestFit($Format="") { |
|
826 | 730 | $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : 0; |
827 | 731 | |
828 | 732 | $Data = $this->pDataObject->getData(); |
829 | 733 | |
830 | - foreach($Data["ScatterSeries"] as $Key => $Series) |
|
831 | - { |
|
832 | - if ( $Series["isDrawable"] == TRUE ) |
|
833 | - { |
|
734 | + foreach($Data["ScatterSeries"] as $Key => $Series) { |
|
735 | + if ( $Series["isDrawable"] == TRUE ) { |
|
834 | 736 | $SerieX = $Series["X"]; $SerieValuesX = $Data["Series"][$SerieX]["Data"]; $SerieXAxis = $Data["Series"][$SerieX]["Axis"]; |
835 | 737 | $SerieY = $Series["Y"]; $SerieValuesY = $Data["Series"][$SerieY]["Data"]; $SerieYAxis = $Data["Series"][$SerieY]["Axis"]; |
836 | 738 | |
@@ -841,8 +743,7 @@ discard block |
||
841 | 743 | $PosArrayY = $Data["Series"][$Series["Y"]]["Data"]; |
842 | 744 | |
843 | 745 | $Sxy = 0; $Sx = 0; $Sy = 0; $Sxx = 0; |
844 | - foreach($PosArrayX as $Key => $Value) |
|
845 | - { |
|
746 | + foreach($PosArrayX as $Key => $Value) { |
|
846 | 747 | $X = $Value; $Y = $PosArrayY[$Key]; |
847 | 748 | |
848 | 749 | $Sxy = $Sxy + $X*$Y; |
@@ -853,15 +754,12 @@ discard block |
||
853 | 754 | |
854 | 755 | $n = count($PosArrayX); |
855 | 756 | |
856 | - if ((($n*$Sxx) == ($Sx*$Sx))) |
|
857 | - { |
|
757 | + if ((($n*$Sxx) == ($Sx*$Sx))) { |
|
858 | 758 | $X1 = $this->getPosArray($Data["Axis"][$SerieXAxis]["ScaleMin"],$SerieXAxis); |
859 | 759 | $X2 = $X1; |
860 | 760 | $Y1 = $this->pChartObject->GraphAreaY1; |
861 | 761 | $Y2 = $this->pChartObject->GraphAreaY2; |
862 | - } |
|
863 | - else |
|
864 | - { |
|
762 | + } else { |
|
865 | 763 | $M = (($n*$Sxy)-($Sx*$Sy)) / (($n*$Sxx)-($Sx*$Sx)); |
866 | 764 | $B = (($Sy)-($M*$Sx))/($n); |
867 | 765 | |
@@ -883,8 +781,7 @@ discard block |
||
883 | 781 | } |
884 | 782 | } |
885 | 783 | |
886 | - function writeScatterLabel($ScatterSerieID,$Points,$Format="") |
|
887 | - { |
|
784 | + function writeScatterLabel($ScatterSerieID,$Points,$Format="") { |
|
888 | 785 | $OverrideTitle = isset($Format["OverrideTitle"]) ? $Format["OverrideTitle"] : NULL; |
889 | 786 | $DrawPoint = isset($Format["DrawPoint"]) ? $Format["DrawPoint"] : LABEL_POINT_BOX; |
890 | 787 | $Decimals = isset($Format["Decimals"]) ? $Format["Decimals"] : NULL; |
@@ -906,10 +803,8 @@ discard block |
||
906 | 803 | $PosArrayY = $this->getPosArray($SerieValuesY,$SerieYAxis); |
907 | 804 | if ( !is_array($PosArrayY) ) { $Value = $PosArrayY; $PosArrayY = ""; $PosArrayY[0] = $Value; } |
908 | 805 | |
909 | - foreach($Points as $Key => $Point) |
|
910 | - { |
|
911 | - if ( isset($PosArrayX[$Point]) && isset($PosArrayY[$Point]) ) |
|
912 | - { |
|
806 | + foreach($Points as $Key => $Point) { |
|
807 | + if ( isset($PosArrayX[$Point]) && isset($PosArrayY[$Point]) ) { |
|
913 | 808 | $X = floor($PosArrayX[$Point]); |
914 | 809 | $Y = floor($PosArrayY[$Point]); |
915 | 810 | |
@@ -952,8 +847,7 @@ discard block |
||
952 | 847 | } |
953 | 848 | |
954 | 849 | /* Draw a Scatter threshold */ |
955 | - function drawScatterThreshold($Value,$Format="") |
|
956 | - { |
|
850 | + function drawScatterThreshold($Value,$Format="") { |
|
957 | 851 | $AxisID = isset($Format["AxisID"]) ? $Format["AxisID"] : 0; |
958 | 852 | $R = isset($Format["R"]) ? $Format["R"] : 255; |
959 | 853 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
@@ -997,51 +891,42 @@ discard block |
||
997 | 891 | |
998 | 892 | if ( !isset($Data["Axis"][$AxisID]) ) { return(-1); } |
999 | 893 | |
1000 | - if ( $Data["Axis"][$AxisID]["Identity"] == AXIS_Y ) |
|
1001 | - { |
|
894 | + if ( $Data["Axis"][$AxisID]["Identity"] == AXIS_Y ) { |
|
1002 | 895 | $X1 = $this->pChartObject->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"]; |
1003 | 896 | $X2 = $this->pChartObject->GraphAreaX2 - $Data["Axis"][$AxisID]["Margin"]; |
1004 | 897 | $Y = $this->getPosArray($Value,$AxisID); |
1005 | 898 | |
1006 | 899 | $this->pChartObject->drawLine($X1,$Y,$X2,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight)); |
1007 | 900 | |
1008 | - if ( $Wide ) |
|
1009 | - { |
|
901 | + if ( $Wide ) { |
|
1010 | 902 | $this->pChartObject->drawLine($X1,$Y-1,$X2,$Y-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks)); |
1011 | 903 | $this->pChartObject->drawLine($X1,$Y+1,$X2,$Y+1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks)); |
1012 | 904 | } |
1013 | 905 | |
1014 | - if ( $WriteCaption ) |
|
1015 | - { |
|
906 | + if ( $WriteCaption ) { |
|
1016 | 907 | if ( $CaptionAlign == CAPTION_LEFT_TOP ) |
1017 | - { $X = $this->pChartObject->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"] + $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
|
1018 | - else |
|
908 | + { $X = $this->pChartObject->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"] + $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_MIDDLELEFT; } else |
|
1019 | 909 | { $X = $this->pChartObject->GraphAreaX2 - $Data["Axis"][$AxisID]["Margin"] - $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
1020 | 910 | |
1021 | 911 | $this->pChartObject->drawText($X,$Y,$Caption,$CaptionSettings); |
1022 | 912 | } |
1023 | 913 | |
1024 | 914 | return(array("Y"=>$Y)); |
1025 | - } |
|
1026 | - elseif ( $Data["Axis"][$AxisID]["Identity"] == AXIS_X ) |
|
1027 | - { |
|
915 | + } elseif ( $Data["Axis"][$AxisID]["Identity"] == AXIS_X ) { |
|
1028 | 916 | $X = $this->getPosArray($Value,$AxisID); |
1029 | 917 | $Y1 = $this->pChartObject->GraphAreaY1 + $Data["Axis"][$AxisID]["Margin"]; |
1030 | 918 | $Y2 = $this->pChartObject->GraphAreaY2 - $Data["Axis"][$AxisID]["Margin"]; |
1031 | 919 | |
1032 | 920 | $this->pChartObject->drawLine($X,$Y1,$X,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight)); |
1033 | 921 | |
1034 | - if ( $Wide ) |
|
1035 | - { |
|
922 | + if ( $Wide ) { |
|
1036 | 923 | $this->pChartObject->drawLine($X-1,$Y1,$X-1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks)); |
1037 | 924 | $this->pChartObject->drawLine($X+1,$Y1,$X+1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks)); |
1038 | 925 | } |
1039 | 926 | |
1040 | - if ( $WriteCaption ) |
|
1041 | - { |
|
927 | + if ( $WriteCaption ) { |
|
1042 | 928 | if ( $CaptionAlign == CAPTION_LEFT_TOP ) |
1043 | - { $Y = $this->pChartObject->GraphAreaY1 + $Data["Axis"][$AxisID]["Margin"] + $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_TOPMIDDLE; } |
|
1044 | - else |
|
929 | + { $Y = $this->pChartObject->GraphAreaY1 + $Data["Axis"][$AxisID]["Margin"] + $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_TOPMIDDLE; } else |
|
1045 | 930 | { $Y = $this->pChartObject->GraphAreaY2 - $Data["Axis"][$AxisID]["Margin"] - $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; } |
1046 | 931 | |
1047 | 932 | $CaptionSettings["Align"] = TEXT_ALIGN_TOPMIDDLE; |
@@ -1053,8 +938,7 @@ discard block |
||
1053 | 938 | } |
1054 | 939 | |
1055 | 940 | /* Draw a Scatter threshold area */ |
1056 | - function drawScatterThresholdArea($Value1,$Value2,$Format="") |
|
1057 | - { |
|
941 | + function drawScatterThresholdArea($Value1,$Value2,$Format="") { |
|
1058 | 942 | $AxisID = isset($Format["AxisID"]) ? $Format["AxisID"] : 0; |
1059 | 943 | $R = isset($Format["R"]) ? $Format["R"] : 255; |
1060 | 944 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
@@ -1085,8 +969,7 @@ discard block |
||
1085 | 969 | |
1086 | 970 | if ( !isset($Data["Axis"][$AxisID]) ) { return(-1); } |
1087 | 971 | |
1088 | - if ( $Data["Axis"][$AxisID]["Identity"] == AXIS_X ) |
|
1089 | - { |
|
972 | + if ( $Data["Axis"][$AxisID]["Identity"] == AXIS_X ) { |
|
1090 | 973 | $Y1 = $this->pChartObject->GraphAreaY1 + $Data["Axis"][$AxisID]["Margin"]; |
1091 | 974 | $Y2 = $this->pChartObject->GraphAreaY2 - $Data["Axis"][$AxisID]["Margin"]; |
1092 | 975 | $X1 = $this->getPosArray($Value1,$AxisID); |
@@ -1097,19 +980,16 @@ discard block |
||
1097 | 980 | |
1098 | 981 | $this->pChartObject->drawFilledRectangle($X1,$Y1,$X2,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha)); |
1099 | 982 | |
1100 | - if ( $Border ) |
|
1101 | - { |
|
983 | + if ( $Border ) { |
|
1102 | 984 | $this->pChartObject->drawLine($X1,$Y1,$X1,$Y2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks)); |
1103 | 985 | $this->pChartObject->drawLine($X2,$Y1,$X2,$Y2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks)); |
1104 | 986 | } |
1105 | 987 | |
1106 | - if ( $AreaName != NULL ) |
|
1107 | - { |
|
988 | + if ( $AreaName != NULL ) { |
|
1108 | 989 | $XPos = ($X2-$X1)/2 + $X1; |
1109 | 990 | $YPos = ($Y2-$Y1)/2 + $Y1; |
1110 | 991 | |
1111 | - if ( $NameAngle == ZONE_NAME_ANGLE_AUTO ) |
|
1112 | - { |
|
992 | + if ( $NameAngle == ZONE_NAME_ANGLE_AUTO ) { |
|
1113 | 993 | $TxtPos = $this->pChartObject->getTextBox($XPos,$YPos,$this->pChartObject->FontName,$this->pChartObject->FontSize,0,$AreaName); |
1114 | 994 | $TxtWidth = $TxtPos[1]["X"] - $TxtPos[0]["X"]; |
1115 | 995 | if ( abs($X2 - $X1) > $TxtWidth ) { $NameAngle = 0; } else { $NameAngle = 90; } |
@@ -1121,9 +1001,7 @@ discard block |
||
1121 | 1001 | |
1122 | 1002 | $this->pChartObject->Shadow = $RestoreShadow; |
1123 | 1003 | return(array("X1"=>$X1,"X2"=>$X2)); |
1124 | - } |
|
1125 | - elseif ( $Data["Axis"][$AxisID]["Identity"] == AXIS_Y ) |
|
1126 | - { |
|
1004 | + } elseif ( $Data["Axis"][$AxisID]["Identity"] == AXIS_Y ) { |
|
1127 | 1005 | $X1 = $this->pChartObject->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"]; |
1128 | 1006 | $X2 = $this->pChartObject->GraphAreaX2 - $Data["Axis"][$AxisID]["Margin"]; |
1129 | 1007 | $Y1 = $this->getPosArray($Value1,$AxisID); |
@@ -1134,14 +1012,12 @@ discard block |
||
1134 | 1012 | |
1135 | 1013 | $this->pChartObject->drawFilledRectangle($X1,$Y1,$X2,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha)); |
1136 | 1014 | |
1137 | - if ( $Border ) |
|
1138 | - { |
|
1015 | + if ( $Border ) { |
|
1139 | 1016 | $this->pChartObject->drawLine($X1,$Y1,$X2,$Y1,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks)); |
1140 | 1017 | $this->pChartObject->drawLine($X1,$Y2,$X2,$Y2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks)); |
1141 | 1018 | } |
1142 | 1019 | |
1143 | - if ( $AreaName != NULL ) |
|
1144 | - { |
|
1020 | + if ( $AreaName != NULL ) { |
|
1145 | 1021 | $XPos = ($X2-$X1)/2 + $X1; |
1146 | 1022 | $YPos = ($Y2-$Y1)/2 + $Y1; |
1147 | 1023 |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | define("TEXT_POS_RIGHT" , 690002); |
18 | 18 | |
19 | 19 | /* pSplit class definition */ |
20 | - class pSplit |
|
21 | - { |
|
20 | + class pSplit { |
|
22 | 21 | var $pChartObject; |
23 | 22 | |
24 | 23 | /* Class creator */ |
@@ -26,8 +25,7 @@ discard block |
||
26 | 25 | { } |
27 | 26 | |
28 | 27 | /* Create the encoded string */ |
29 | - function drawSplitPath($Object,$Values,$Format="") |
|
30 | - { |
|
28 | + function drawSplitPath($Object,$Values,$Format="") { |
|
31 | 29 | $this->pChartObject = $Object; |
32 | 30 | |
33 | 31 | $Spacing = isset($Format["Spacing"]) ? $Format["Spacing"] : 20; |
@@ -63,11 +61,9 @@ discard block |
||
63 | 61 | $LeftHeight = $DataSerieSum * $YScale; |
64 | 62 | |
65 | 63 | /* Re-compute graph width depending of the text mode choosen */ |
66 | - if ( $TextPos == TEXT_POS_RIGHT ) |
|
67 | - { |
|
64 | + if ( $TextPos == TEXT_POS_RIGHT ) { |
|
68 | 65 | $MaxWidth = 0; |
69 | - foreach($Data["Series"][$LabelSerie]["Data"] as $Key => $Label) |
|
70 | - { |
|
66 | + foreach($Data["Series"][$LabelSerie]["Data"] as $Key => $Label) { |
|
71 | 67 | $Boundardies = $Object->getTextBox(0,0,$Object->FontName,$Object->FontSize,0,$Label); |
72 | 68 | if ( $Boundardies[1]["X"] > $MaxWidth ) { $MaxWidth = $Boundardies[1]["X"] + $TextPadding*2; } |
73 | 69 | } |
@@ -79,8 +75,7 @@ discard block |
||
79 | 75 | $RightY = $Y1; |
80 | 76 | $VectorX = (($X2-$X1) / 2); |
81 | 77 | |
82 | - foreach($Data["Series"][$DataSerie]["Data"] as $Key => $Value) |
|
83 | - { |
|
78 | + foreach($Data["Series"][$DataSerie]["Data"] as $Key => $Value) { |
|
84 | 79 | if ( isset($Data["Series"][$LabelSerie]["Data"][$Key]) ) |
85 | 80 | $Label = $Data["Series"][$LabelSerie]["Data"][$Key]; |
86 | 81 | else |