author | Dan |
Thu, 10 Apr 2008 07:58:56 -0400 | |
changeset 529 | 7803c9db3506 |
parent 323 | a82133ce2d76 |
child 536 | 218a627eb53e |
permissions | -rw-r--r-- |
1 | 1 |
<?php |
2 |
||
3 |
/* |
|
4 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
5 |
* Version 1.1.1 |
1 | 6 |
* Copyright (C) 2006-2007 Dan Fuhry |
7 |
* |
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
13 |
*/ |
|
14 |
||
15 |
// BarGraph for PHP |
|
16 |
// Source: http://www.phpclasses.org/browse/package/1567.html |
|
17 |
// License: PHP license, see licenses/phplic.html included with this package |
|
18 |
||
19 |
class GraphMaker { |
|
20 |
/** |
|
21 |
* GraphMaker::bar_width |
|
22 |
* Width of bars |
|
23 |
*/ |
|
24 |
var $bar_width = 32; |
|
25 |
/** |
|
26 |
* GraphMaker::bar_height |
|
27 |
* Height of bars |
|
28 |
*/ |
|
29 |
var $bar_height = 8; |
|
30 |
/** |
|
31 |
* GraphMaker::bar_data |
|
32 |
* Data of all bars |
|
33 |
*/ |
|
34 |
var $bar_data = array('a' => 7, 'b' => 3, 'c' => 6, 'd' => 0, 'e' => 2); |
|
35 |
/** |
|
36 |
* GraphMaker::bar_padding |
|
37 |
* Padding of bars |
|
38 |
*/ |
|
39 |
var $bar_padding = 5; |
|
40 |
/** |
|
41 |
* GraphMaker::bar_bordercolor |
|
42 |
* Border color of bars |
|
43 |
*/ |
|
44 |
var $bar_bordercolor = array(39, 78, 120); |
|
45 |
/** |
|
46 |
* GraphMaker::bar_bgcolor |
|
47 |
* Background color of bars |
|
48 |
*/ |
|
49 |
var $bar_bgcolor = array(69, 129, 194); |
|
50 |
//--------------------------------------------- |
|
51 |
/** |
|
52 |
* GraphMaker::graph_areaheight |
|
53 |
* Height of graphic area |
|
54 |
*/ |
|
55 |
var $graph_areaheight = 100; |
|
56 |
/** |
|
57 |
* GraphMaker::graph_padding |
|
58 |
* Paddings of graph |
|
59 |
*/ |
|
60 |
var $graph_padding = array('left' => 50, 'top' => 20, 'right' => 20, 'bottom' => 20); |
|
61 |
/** |
|
62 |
* GraphMaker::graph_title |
|
63 |
* Title text of graph |
|
64 |
*/ |
|
65 |
var $graph_title = ""; |
|
66 |
/** |
|
67 |
* GraphMaker::graph_bgcolor |
|
68 |
* Background color of graph |
|
69 |
*/ |
|
70 |
var $graph_bgcolor = array(255, 255, 255); |
|
71 |
/** |
|
72 |
* GraphMaker::graph_bgtransparent |
|
73 |
* Boolean for background transparency |
|
74 |
*/ |
|
75 |
var $graph_bgtransparent = 0; |
|
76 |
/** |
|
77 |
* GraphMaker::graph_transparencylevel |
|
78 |
* Transparency level (0=opaque, 127=transparent) |
|
79 |
*/ |
|
80 |
var $graph_transparencylevel = 0; |
|
81 |
/** |
|
82 |
* GraphMaker::graph_borderwidth |
|
83 |
* Width of graph border |
|
84 |
*/ |
|
85 |
var $graph_borderwidth = 1; |
|
86 |
/** |
|
87 |
* GraphMaker::graph_bordercolor |
|
88 |
* Border color of graph |
|
89 |
*/ |
|
90 |
var $graph_bordercolor = array(218, 218, 239); |
|
91 |
/** |
|
92 |
* GraphMaker::graph_titlecolor |
|
93 |
* Color of title text of graph |
|
94 |
*/ |
|
95 |
var $graph_titlecolor = array(99, 88, 78); |
|
96 |
//--------------------------------------------- |
|
97 |
/** |
|
98 |
* GraphMaker::axis_step |
|
99 |
* Scale step of axis |
|
100 |
*/ |
|
101 |
var $axis_step = 2; |
|
102 |
/** |
|
103 |
* GraphMaker::axis_bordercolor |
|
104 |
* Border color of axis |
|
105 |
*/ |
|
106 |
var $axis_bordercolor = array(99, 88, 78); |
|
107 |
/** |
|
108 |
* GraphMaker::axis_bgcolor |
|
109 |
* Background color of axis |
|
110 |
*/ |
|
111 |
var $axis_bgcolor = array(152, 137, 124); |
|
112 |
||
113 |
/**************************************************************** |
|
114 |
GRAPH |
|
115 |
****************************************************************/ |
|
116 |
||
117 |
/** |
|
118 |
* GraphMaker::SetGraphAreaHeight() |
|
119 |
* Sets graph height (not counting top and bottom margins) |
|
120 |
**/ |
|
121 |
function SetGraphAreaHeight($height) { |
|
122 |
if ($height > 0) $this->graph_areaheight = $height; |
|
123 |
} |
|
124 |
||
125 |
/** |
|
126 |
* GraphMaker::SetGraphPadding() |
|
127 |
* Sets graph padding (margins) |
|
128 |
**/ |
|
129 |
function SetGraphPadding($left, $top, $right, $bottom) { |
|
130 |
$this->graph_padding = array('left' => (int) $left, |
|
131 |
'top' => (int) $top, |
|
132 |
'right' => (int) $right, |
|
133 |
'bottom' => (int) $bottom); |
|
134 |
} |
|
135 |
||
136 |
/** |
|
137 |
* GraphMaker::SetGraphTitle() |
|
138 |
* Set title text |
|
139 |
**/ |
|
140 |
function SetGraphTitle($title) { |
|
141 |
$this->graph_title = $title; |
|
142 |
} |
|
143 |
||
144 |
/** |
|
145 |
* GraphMaker::SetGraphBorderColor() |
|
146 |
* Sets border color for graph |
|
147 |
**/ |
|
148 |
function SetGraphBorderColor($red, $green, $blue) { |
|
149 |
$this->graph_bordercolor = array($red, $green, $blue); |
|
150 |
} |
|
151 |
||
152 |
/** |
|
153 |
* GraphMaker::SetGraphBorderWidth() |
|
154 |
* Set width of border. 0 disables border |
|
155 |
**/ |
|
156 |
function SetGraphBorderWidth($width = 0) { |
|
157 |
$this->graph_borderwidth = $width; |
|
158 |
} |
|
159 |
||
160 |
/** |
|
161 |
* GraphMaker::SetGraphBackgroundColor() |
|
162 |
* Sets background color for graph |
|
163 |
**/ |
|
164 |
function SetGraphBackgroundColor($red, $green, $blue) { |
|
165 |
$this->graph_bgcolor = array($red, $green, $blue); |
|
166 |
} |
|
167 |
||
168 |
/** |
|
169 |
* GraphMaker::SetGraphBackgroundTransparent() |
|
170 |
* Sets background color for graph (and set it transparent) |
|
171 |
**/ |
|
172 |
function SetGraphBackgroundTransparent($red, $green, $blue, $addtransparency = 1) { |
|
173 |
$this->graph_bgcolor = array($red, $green, $blue); |
|
174 |
$this->graph_bgtransparent = ($addtransparency ? 1 : 0); |
|
175 |
} |
|
176 |
||
177 |
/** |
|
178 |
* GraphMaker::SetGraphTitleColor() |
|
179 |
* Sets title color for graph |
|
180 |
**/ |
|
181 |
function SetGraphTitleColor($red, $green, $blue) { |
|
182 |
$this->graph_titlecolor = array($red, $green, $blue); |
|
183 |
} |
|
184 |
||
185 |
/** |
|
186 |
* GraphMaker::SetGraphTransparency() |
|
187 |
* Sets transparency for graph |
|
188 |
**/ |
|
189 |
function SetGraphTransparency($percent) { |
|
190 |
if ($percent < 0) $percent = 0; |
|
191 |
elseif ($percent > 100) $percent = 127; |
|
192 |
else $percent = $percent * 1.27; |
|
193 |
$this->graph_transparencylevel = $percent; |
|
194 |
} |
|
195 |
||
196 |
/**************************************************************** |
|
197 |
BAR |
|
198 |
****************************************************************/ |
|
199 |
||
200 |
/** |
|
201 |
* GraphMaker::SetBarBorderColor() |
|
202 |
* Sets border color for bars |
|
203 |
**/ |
|
204 |
function SetBarBorderColor($red, $green, $blue) { |
|
205 |
$this->bar_bordercolor = array($red, $green, $blue); |
|
206 |
} |
|
207 |
||
208 |
/** |
|
209 |
* GraphMaker::SetBarBackgroundColor() |
|
210 |
* Sets background color for bars |
|
211 |
**/ |
|
212 |
function SetBarBackgroundColor($red, $green, $blue) { |
|
213 |
$this->bar_bgcolor = array($red, $green, $blue); |
|
214 |
} |
|
215 |
||
216 |
/** |
|
217 |
* GraphMaker::SetBarData() |
|
218 |
* Sets data of graph (parameter should be an array with key |
|
219 |
* being the name of the bar and the value the value of the bar. |
|
220 |
**/ |
|
221 |
function SetBarData($data) { |
|
222 |
if (is_array($data)) $this->bar_data = $data; |
|
223 |
} |
|
224 |
||
225 |
/** |
|
226 |
* GraphMaker::SetBarDimensions() |
|
227 |
* Sets with and height of each bar |
|
228 |
**/ |
|
229 |
function SetBarDimensions($width, $height) { |
|
230 |
if ($width > 0) $this->bar_width = $width; |
|
231 |
if ($height > 0) $this->bar_height = $height; |
|
232 |
} |
|
233 |
||
234 |
/** |
|
235 |
* GraphMaker::SetBarPadding() |
|
236 |
* Sets padding (border) around each bar |
|
237 |
**/ |
|
238 |
function SetBarPadding($padding) { |
|
239 |
if ($padding > 0) $this->bar_padding = $padding; |
|
240 |
} |
|
241 |
||
242 |
/**************************************************************** |
|
243 |
AXIS |
|
244 |
****************************************************************/ |
|
245 |
||
246 |
/** |
|
247 |
* GraphMaker::SetAxisBorderColor() |
|
248 |
* Sets border color for axis |
|
249 |
**/ |
|
250 |
function SetAxisBorderColor($red, $green, $blue) { |
|
251 |
$this->axis_bordercolor = array($red, $green, $blue); |
|
252 |
} |
|
253 |
||
254 |
/** |
|
255 |
* GraphMaker::SetAxisBackgroundColor() |
|
256 |
* Sets background color for axis |
|
257 |
**/ |
|
258 |
function SetAxisBackgroundColor($red, $green, $blue) { |
|
259 |
$this->axis_bgcolor = array($red, $green, $blue); |
|
260 |
} |
|
261 |
||
262 |
/** |
|
263 |
* GraphMaker::SetAxisStep() |
|
264 |
* Sets axis scale step |
|
265 |
**/ |
|
266 |
function SetAxisStep($step) { |
|
267 |
if ($step > 0) $this->axis_step = $step; |
|
268 |
} |
|
269 |
||
270 |
/** |
|
271 |
* GraphMaker::GetFinalGraphDimensions() |
|
272 |
* From the values already setted, it calculates image |
|
273 |
* width and height |
|
274 |
**/ |
|
275 |
function GetFinalGraphDimensions() { |
|
276 |
$w = $this->graph_padding['left'] + |
|
277 |
(count($this->bar_data) * ($this->bar_width + ($this->bar_padding * 2))) + |
|
278 |
$this->graph_padding['right']; |
|
279 |
$h = $this->graph_padding['top'] + |
|
280 |
$this->graph_areaheight + |
|
281 |
$this->graph_padding['bottom']; |
|
282 |
return array($w, $h); |
|
283 |
} |
|
284 |
||
285 |
/** |
|
286 |
* GraphMaker::LoadGraph() |
|
287 |
* Loads definitions from a file |
|
288 |
**/ |
|
289 |
function LoadGraph($path) { |
|
290 |
if (($fp = @fopen($path, "r")) !== false) { |
|
291 |
$content = ""; |
|
292 |
while (!feof($fp)) { // I do not use filesize() here |
|
293 |
$content .= fread($fp, 4096); // because of remote files. If |
|
294 |
} // there is no problem with them |
|
295 |
fclose($fp); // please let me know |
|
296 |
$this->__LoadGraphDefinitions($content); |
|
297 |
return true; |
|
298 |
} else return false; |
|
299 |
} |
|
300 |
||
301 |
/** |
|
302 |
* GraphMaker::DrawGraph() |
|
303 |
* Draw all the graph: bg, axis, bars, text.. and output it |
|
304 |
* Optional file parameter turns output to file, and bool on success |
|
305 |
**/ |
|
306 |
function DrawGraph($file = "") { |
|
307 |
list($w, $h) = $this->GetFinalGraphDimensions(); |
|
308 |
$this->graph_width = $w; |
|
309 |
$this->graph_height = $h; |
|
310 |
||
311 |
$this->im = imagecreatetruecolor($w, $h); |
|
312 |
if ($this->graph_transparencylevel) { |
|
313 |
imagealphablending($this->im, true); |
|
314 |
} |
|
315 |
||
316 |
$this->__PaintBackground(); |
|
317 |
$this->__DrawAxis(); |
|
318 |
||
319 |
$p = 0; |
|
320 |
foreach ($this->bar_data as $name => $value) { |
|
321 |
$p++; |
|
322 |
$this->__DrawBarText($p, $name); |
|
323 |
$this->__DrawBar($p, $value); |
|
324 |
} |
|
325 |
||
326 |
if (strlen($this->graph_title)) { |
|
327 |
$this->__AllocateColor("im_graph_titlecolor", |
|
328 |
$this->graph_titlecolor, |
|
329 |
$this->graph_transparencylevel); |
|
330 |
$this->__DrawText($this->graph_title, |
|
331 |
floor($this->graph_width / 2), |
|
332 |
$this->graph_borderwidth + 2, |
|
333 |
$this->im_graph_titlecolor, |
|
334 |
2, |
|
335 |
1); |
|
336 |
} |
|
337 |
||
338 |
if (strlen($file)) { |
|
339 |
$ret = imagepng($this->im, $file); |
|
340 |
} else { |
|
341 |
header('Content-Type: image/png'); |
|
342 |
imagepng($this->im); |
|
343 |
$ret = true; |
|
344 |
} |
|
345 |
imagedestroy($this->im); |
|
346 |
return $ret; |
|
347 |
} |
|
348 |
||
349 |
/** |
|
350 |
* GraphMaker::PaintBackground() |
|
351 |
* Draw all the graph: bg, axis, bars, text.. and output it |
|
352 |
* Optional file parameter turns output to file, and bool on success |
|
353 |
**/ |
|
354 |
function __PaintBackground() { |
|
355 |
$this->__AllocateColor("im_graph_bgcolor", |
|
356 |
$this->graph_bgcolor, |
|
357 |
0); |
|
358 |
imagefilledrectangle($this->im, |
|
359 |
0, |
|
360 |
0, |
|
361 |
$this->graph_width, |
|
362 |
$this->graph_height, |
|
363 |
$this->im_graph_bgcolor); |
|
364 |
if ($this->graph_bgtransparent) { |
|
365 |
imagecolortransparent($this->im, $this->im_graph_bgcolor); |
|
366 |
} |
|
367 |
if ($this->graph_borderwidth) { |
|
368 |
$this->__AllocateColor("im_graph_bordercolor", |
|
369 |
$this->graph_bordercolor, |
|
370 |
$this->graph_transparencylevel); |
|
371 |
for ($i = 0; $i < $this->graph_borderwidth; $i++) { |
|
372 |
imagerectangle($this->im, |
|
373 |
$i, |
|
374 |
$i, |
|
375 |
$this->graph_width - 1 - $i, |
|
376 |
$this->graph_height - 1 - $i, |
|
377 |
$this->im_graph_bordercolor); |
|
378 |
} |
|
379 |
} |
|
380 |
} |
|
381 |
||
382 |
/** |
|
383 |
* GraphMaker::__DrawAxis() |
|
384 |
* Draws all the axis stuff (and scale steps) |
|
385 |
**/ |
|
386 |
function __DrawAxis() { |
|
387 |
$this->__AllocateColor("im_axis_bordercolor", |
|
388 |
$this->axis_bordercolor, |
|
389 |
$this->graph_transparencylevel); |
|
390 |
$this->__AllocateColor("im_axis_bgcolor", |
|
391 |
$this->axis_bgcolor, |
|
392 |
$this->graph_transparencylevel); |
|
393 |
$this->__DrawPolygon($this->graph_padding['left'], $this->graph_height - $this->graph_padding['bottom'], |
|
394 |
$this->graph_padding['left'], $this->graph_padding['top'], |
|
395 |
$this->graph_padding['left'] + $this->bar_height - 1, $this->graph_padding['top'] - $this->bar_height + 1, |
|
396 |
$this->graph_padding['left'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1, |
|
397 |
$this->im_axis_bgcolor, true); |
|
398 |
$this->__DrawPolygon($this->graph_padding['left'], $this->graph_height - $this->graph_padding['bottom'], |
|
399 |
$this->graph_padding['left'], $this->graph_padding['top'], |
|
400 |
$this->graph_padding['left'] + $this->bar_height - 1, $this->graph_padding['top'] - $this->bar_height + 1, |
|
401 |
$this->graph_padding['left'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1, |
|
402 |
$this->im_axis_bordercolor); |
|
403 |
||
404 |
$this->__DrawPolygon($this->graph_padding['left'], $this->graph_height - $this->graph_padding['bottom'], |
|
405 |
$this->graph_padding['left'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1, |
|
406 |
$this->graph_width - $this->graph_padding['right'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1, |
|
407 |
$this->graph_width - $this->graph_padding['right'], $this->graph_height - $this->graph_padding['bottom'], |
|
408 |
$this->im_axis_bgcolor, true); |
|
409 |
$this->__DrawPolygon($this->graph_padding['left'], $this->graph_height - $this->graph_padding['bottom'], |
|
410 |
$this->graph_padding['left'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1, |
|
411 |
$this->graph_width - $this->graph_padding['right'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1, |
|
412 |
$this->graph_width - $this->graph_padding['right'], $this->graph_height - $this->graph_padding['bottom'], |
|
413 |
$this->im_axis_bordercolor); |
|
414 |
||
415 |
// draw lines that separate bars |
|
416 |
$total_bars = count($this->bar_data); |
|
417 |
for ($i = 1; $i < $total_bars; $i++) { |
|
418 |
$offset = $this->graph_padding['left'] + |
|
419 |
(($this->bar_width + ($this->bar_padding * 2)) * $i); |
|
420 |
imageline($this->im, |
|
421 |
$offset, |
|
422 |
$this->graph_height - $this->graph_padding['bottom'], |
|
423 |
$offset + $this->bar_height - 1, |
|
424 |
$this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1, |
|
425 |
$this->im_axis_bordercolor); |
|
426 |
} |
|
427 |
||
428 |
// draw scale steps |
|
429 |
$max_value = $this->__GetMaxGraphValue(); |
|
430 |
if (($max_value % 10) > 0) { |
|
431 |
$max_value = $max_value + (10 - ($max_value % 10)); |
|
432 |
} |
|
433 |
$this->axis_max = $max_value; |
|
434 |
$y = 0; |
|
435 |
$style = array($this->im_axis_bordercolor, $this->im_graph_bgcolor); |
|
436 |
imagesetstyle($this->im, $style); |
|
437 |
while ($y <= $max_value) { |
|
438 |
if ($max_value == 0) { $max_value=1; } // corrected by Marcelo Trenkenchu |
|
439 |
$offset = floor($this->graph_height - $this->graph_padding['bottom'] - |
|
440 |
($y * $this->graph_areaheight / $max_value)); |
|
441 |
imageline($this->im, |
|
442 |
$this->graph_padding['left'], |
|
443 |
$offset, |
|
444 |
$this->graph_padding['left'] + $this->bar_height - 1, |
|
445 |
$offset - $this->bar_height + 1, |
|
446 |
$this->im_axis_bordercolor); |
|
447 |
$this->__DrawText($y, |
|
448 |
$this->graph_padding['left'], |
|
449 |
$offset, |
|
450 |
$this->im_axis_bordercolor, |
|
451 |
1, |
|
452 |
2, |
|
453 |
1); |
|
454 |
// gridline |
|
455 |
if ($y > 0) { |
|
456 |
imageline($this->im, |
|
457 |
$this->graph_padding['left'] + $this->bar_height, |
|
458 |
$offset - $this->bar_height + 1, |
|
459 |
$this->graph_width - $this->graph_padding['right'] + $this->bar_height - 1, |
|
460 |
$offset - $this->bar_height + 1, |
|
461 |
IMG_COLOR_STYLED); |
|
462 |
} |
|
463 |
$y += $this->axis_step; |
|
464 |
} |
|
465 |
||
466 |
imageline($this->im, |
|
467 |
$this->graph_width - $this->graph_padding['right'] + $this->bar_height - 1, |
|
468 |
$this->graph_padding['top'] - $this->bar_height + 1, |
|
469 |
$this->graph_width - $this->graph_padding['right'] + $this->bar_height - 1, |
|
470 |
$this->graph_height - $this->graph_padding['bottom'] - $this->bar_height, |
|
471 |
IMG_COLOR_STYLED); |
|
472 |
} |
|
473 |
||
474 |
/** |
|
475 |
* GraphMaker::__DrawText() |
|
476 |
* Draws text on image with color, size and alignment options |
|
477 |
**/ |
|
478 |
function __DrawText($text, $x, $y, $color, $size = 1, $align = 0, $valign = 0) { |
|
479 |
/* |
|
480 |
* Align: 0=left | 1=center | 2=right |
|
481 |
*/ |
|
482 |
if ($align == 1) $x -= floor(strlen($text) * imagefontwidth($size) / 2); |
|
483 |
elseif ($align == 2) $x -= (strlen($text) * imagefontwidth($size)); |
|
484 |
if ($valign == 1) $y -= floor(imagefontheight($size) / 2); |
|
485 |
elseif ($valign == 2) $y -= imagefontheight($size); |
|
486 |
imagestring($this->im, |
|
487 |
$size, |
|
488 |
$x, |
|
489 |
$y, |
|
490 |
$text, |
|
491 |
$color); |
|
492 |
} |
|
493 |
||
494 |
/** |
|
495 |
* GraphMaker::__GetMaxGraphValue() |
|
496 |
* Returns max bar value |
|
497 |
**/ |
|
498 |
function __GetMaxGraphValue() { |
|
499 |
$max_value = 0; |
|
500 |
foreach ($this->bar_data as $name => $value) { |
|
501 |
if ($value > $max_value) $max_value = $value; |
|
502 |
} |
|
503 |
return $max_value; |
|
504 |
} |
|
505 |
||
506 |
/** |
|
507 |
* GraphMaker::__DrawBarText() |
|
508 |
* Determines top and left to draw text to a choosen bar |
|
509 |
**/ |
|
510 |
function __DrawBarText($bar, $text) { |
|
511 |
$this->__DrawText($text, |
|
512 |
$this->graph_padding['left'] + (($this->bar_width + ($this->bar_padding * 2)) * ($bar - 0.5)), |
|
513 |
$this->graph_height - $this->graph_padding['bottom'] + 1, |
|
514 |
$this->axis_bordercolor, |
|
515 |
1, |
|
516 |
1); |
|
517 |
} |
|
518 |
||
519 |
/** |
|
520 |
* GraphMaker::__DrawBar() |
|
521 |
* Draws a choosen bar with it's value |
|
522 |
**/ |
|
523 |
function __DrawBar($bar, $value) { |
|
524 |
$x = $this->graph_padding['left'] + |
|
525 |
(($this->bar_width + ($this->bar_padding * 2)) * ($bar - 1)) + |
|
526 |
$this->bar_padding; |
|
527 |
if ($this->axis_max == 0) { $this->axis_max = 1; } // corrected by Marcelo Trenkenchu |
|
528 |
$y = $value * $this->graph_areaheight / $this->axis_max; |
|
529 |
$this->____DrawBar($x, |
|
530 |
$this->graph_height - $this->graph_padding['bottom'] - $y, |
|
531 |
$x + $this->bar_width, |
|
532 |
$this->graph_height - $this->graph_padding['bottom']); |
|
533 |
} |
|
534 |
||
535 |
/** |
|
536 |
* GraphMaker::____DrawBar() |
|
537 |
* Draws the actual rectangles that form a bar |
|
538 |
**/ |
|
539 |
function ____DrawBar($x1, $y1, $x2, $y2) { |
|
540 |
$this->__AllocateColor("im_bar_bordercolor", |
|
541 |
$this->bar_bordercolor, |
|
542 |
$this->graph_transparencylevel); |
|
543 |
$this->__AllocateColor("im_bar_bgcolor", |
|
544 |
$this->bar_bgcolor, |
|
545 |
$this->graph_transparencylevel); |
|
546 |
$this->__DrawPolygon($x1, $y1, |
|
547 |
$x2, $y1, |
|
548 |
$x2, $y2, |
|
549 |
$x1, $y2, |
|
550 |
$this->im_bar_bgcolor, true); |
|
551 |
$this->__DrawPolygon($x1, $y1, |
|
552 |
$x2, $y1, |
|
553 |
$x2, $y2, |
|
554 |
$x1, $y2, |
|
555 |
$this->im_bar_bordercolor); |
|
556 |
$this->__DrawPolygon($x1, $y1, |
|
557 |
$x2, $y1, |
|
558 |
$x2 + $this->bar_height - 1, $y1 - $this->bar_height + 1, |
|
559 |
$x1 + $this->bar_height - 1, $y1 - $this->bar_height + 1, |
|
560 |
$this->im_bar_bgcolor, true); |
|
561 |
$this->__DrawPolygon($x1, $y1, |
|
562 |
$x2, $y1, |
|
563 |
$x2 + $this->bar_height - 1, $y1 - $this->bar_height + 1, |
|
564 |
$x1 + $this->bar_height - 1, $y1 - $this->bar_height + 1, |
|
565 |
$this->im_bar_bordercolor); |
|
566 |
$this->__DrawPolygon($x2, $y2, |
|
567 |
$x2, $y1, |
|
568 |
$x2 + $this->bar_height - 1, $y1 - $this->bar_height + 1, |
|
569 |
$x2 + $this->bar_height - 1, $y2 - $this->bar_height + 1, |
|
570 |
$this->im_bar_bgcolor, true); |
|
571 |
$this->__DrawPolygon($x2, $y2, |
|
572 |
$x2, $y1, |
|
573 |
$x2 + $this->bar_height - 1, $y1 - $this->bar_height + 1, |
|
574 |
$x2 + $this->bar_height - 1, $y2 - $this->bar_height + 1, |
|
575 |
$this->im_bar_bordercolor); |
|
576 |
} |
|
577 |
||
578 |
/** |
|
579 |
* GraphMaker::__DrawPolygon() |
|
580 |
* Draws a (filled) (ir)regular polygon |
|
581 |
**/ |
|
582 |
function __DrawPolygon($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $color, $filled = false) { |
|
583 |
if ($filled) { |
|
584 |
imagefilledpolygon($this->im, array($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4), 4, $color); |
|
585 |
} else { |
|
586 |
imagepolygon($this->im, array($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4), 4, $color); |
|
587 |
} |
|
588 |
} |
|
589 |
||
590 |
/** |
|
591 |
* GraphMaker::__LoadGraphDefinitions() |
|
592 |
* Loads definitions to a graph from text lines (normaly |
|
593 |
* they come from a file). This function is called by |
|
594 |
* GraphMaker::LoadGraph() |
|
595 |
**/ |
|
596 |
function __LoadGraphDefinitions($text) { |
|
597 |
$text = preg_split("/\r?\n/", $text); |
|
598 |
$data = array(); |
|
599 |
$section = ''; |
|
600 |
for ($i = 0; $i < count($text); $i++) { |
|
601 |
if (preg_match("/^\s*#/", $text[$i])) { |
|
602 |
//ignore.. it's just a comment |
|
603 |
} elseif (preg_match("/^\s*\}\s*/", $text[$i])) { |
|
604 |
$section = ''; |
|
605 |
} elseif (preg_match("/^\s*(\w+)\s*\{\s*$/", $text[$i], $r)) { |
|
606 |
$section = $r[1]; |
|
607 |
} else { |
|
608 |
$p = strpos($text[$i], "="); |
|
609 |
if ($p !== false) { |
|
610 |
$data[$section][trim(substr($text[$i], 0, $p))] = trim(substr($text[$i], $p + 1)); |
|
611 |
} |
|
612 |
} |
|
613 |
} |
|
614 |
if (is_array($data['graph'])) { |
|
615 |
$this->__LoadGraphValues($data['graph']); |
|
616 |
} |
|
617 |
if (is_array($data['bar'])) { |
|
618 |
$this->__LoadBarValues($data['bar']); |
|
619 |
} |
|
620 |
if (is_array($data['axis'])) { |
|
621 |
$this->__LoadAxisValues($data['axis']); |
|
622 |
} |
|
623 |
if (is_array($data['data'])) { |
|
624 |
$this->bar_data = $data['data']; |
|
625 |
} |
|
626 |
} |
|
627 |
||
628 |
/** |
|
629 |
* GraphMaker::__LoadGraphValues() |
|
630 |
* Loads definitions to main graph settings |
|
631 |
**/ |
|
632 |
function __LoadGraphValues($data) { |
|
633 |
foreach ($data as $name => $value) { |
|
634 |
$name = strtolower($name); |
|
635 |
switch ($name) { |
|
636 |
case 'background-color': |
|
637 |
$this->__SetColorToValue("graph_bgcolor", $value); |
|
638 |
break; |
|
639 |
case 'border-color': |
|
640 |
$this->__SetColorToValue("graph_bordercolor", $value); |
|
641 |
break; |
|
642 |
case 'title-color': |
|
643 |
$this->__SetColorToValue("graph_titlecolor", $value); |
|
644 |
break; |
|
645 |
case 'background-transparent': |
|
646 |
$this->graph_bgtransparent = ($value == 1 || $value == 'yes' ? 1 : 0); |
|
647 |
break; |
|
648 |
case 'transparency': |
|
649 |
$this->SetGraphTransparency(str_replace('%', '', $value)); |
|
650 |
break; |
|
651 |
case 'title': |
|
652 |
$this->graph_title = $value; |
|
653 |
break; |
|
654 |
case 'border-width': |
|
655 |
$this->graph_borderwidth = (int) $value; |
|
656 |
break; |
|
657 |
case 'area-height': |
|
658 |
$this->graph_areaheight = (int) $value; |
|
659 |
break; |
|
660 |
default: |
|
661 |
if (substr($name, 0, 8) == 'padding-' && strlen($name) > 8) { |
|
662 |
$this->graph_padding[substr($name, 8)] = $value; |
|
663 |
} |
|
664 |
} |
|
665 |
} |
|
666 |
} |
|
667 |
||
668 |
/** |
|
669 |
* GraphMaker::__LoadBarValues() |
|
670 |
* Loads definitions to bar settings |
|
671 |
**/ |
|
672 |
function __LoadBarValues($data) { |
|
673 |
foreach ($data as $name => $value) { |
|
674 |
$name = strtolower($name); |
|
675 |
switch ($name) { |
|
676 |
case 'background-color': |
|
677 |
$this->__SetColorToValue("bar_bgcolor", $value); |
|
678 |
break; |
|
679 |
case 'border-color': |
|
680 |
$this->__SetColorToValue("bar_bordercolor", $value); |
|
681 |
break; |
|
682 |
case 'padding': |
|
683 |
$this->bar_padding = $value; |
|
684 |
break; |
|
685 |
case 'width': |
|
686 |
$this->bar_width = (int) $value; |
|
687 |
break; |
|
688 |
case 'height': |
|
689 |
$this->bar_height = (int) $value; |
|
690 |
break; |
|
691 |
} |
|
692 |
} |
|
693 |
} |
|
694 |
||
695 |
/** |
|
696 |
* GraphMaker::__LoadAxisValues() |
|
697 |
* Loads definitions to axis settings |
|
698 |
**/ |
|
699 |
function __LoadAxisValues($data) { |
|
700 |
foreach ($data as $name => $value) { |
|
701 |
switch (strtolower($name)) { |
|
702 |
case 'step': |
|
703 |
$this->SetAxisStep($value); |
|
704 |
break; |
|
705 |
case 'background-color': |
|
706 |
$this->__SetColorToValue("axis_bgcolor", $value); |
|
707 |
break; |
|
708 |
case 'border-color': |
|
709 |
$this->__SetColorToValue("axis_bordercolor", $value); |
|
710 |
} |
|
711 |
} |
|
712 |
} |
|
713 |
||
714 |
/** |
|
715 |
* GraphMaker::__SetColorToValue() |
|
716 |
* Sets a color (rgb or in html format) to a variable |
|
717 |
**/ |
|
718 |
function __SetColorToValue($varname, $color) { |
|
719 |
if ($color[0] == "#") { // if it's hex (html format), change to rgb array |
|
720 |
if (strlen($color) == 4) { |
|
721 |
// if only 3 hex values (I assume it's a shade of grey: #ddd) |
|
722 |
$color .= substr($color, -3); |
|
723 |
} |
|
724 |
$color = array(hexdec($color[1].$color[2]), |
|
725 |
hexdec($color[3].$color[4]), |
|
726 |
hexdec($color[5].$color[6])); |
|
727 |
} |
|
728 |
$this->$varname = $color; |
|
729 |
} |
|
730 |
||
731 |
function __AllocateColor($varname, $color, $alpha) { |
|
732 |
$this->$varname = imagecolorallocatealpha($this->im, |
|
733 |
$color[0], |
|
734 |
$color[1], |
|
735 |
$color[2], |
|
736 |
$alpha); |
|
737 |
} |
|
738 |
} |
|
739 |
||
740 |
// Graph Generator for PHP |
|
741 |
// Originally located at http://szewo.com/php/graph, but link was broken, so this file was retrieved from: |
|
742 |
// http://web.archive.org/web/20030130065944/szewo.com/php/graph/graph.class.php3.txt |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
743 |
// License unknown, however sources on the web have shown this to be either GPL or public domain. |
1 | 744 |
|
745 |
class GraphMaker_compat { |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
746 |
var $_values; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
747 |
var $_ShowLabels; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
748 |
var $_ShowCounts; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
749 |
var $_ShowCountsMode; |
1 | 750 |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
751 |
var $_BarWidth; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
752 |
var $_GraphWidth; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
753 |
var $_BarImg; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
754 |
var $_BarBorderWidth; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
755 |
var $_BarBorderColor; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
756 |
var $_BarBackgroundColor; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
757 |
var $_RowSortMode; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
758 |
var $_TDClassHead; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
759 |
var $_TDClassLabel; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
760 |
var $_TDClassCount; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
761 |
var $_GraphTitle; |
1 | 762 |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
763 |
function __construct() { |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
764 |
$this->_values = array(); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
765 |
$this->_ShowLabels = true; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
766 |
$this->_BarWidth = 32; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
767 |
$this->_GraphWidth = 360; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
768 |
$this->_BarImg = scriptPath . "/images/graphbit.png"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
769 |
$this->_BarBorderWidth = 0; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
770 |
$this->_BarBorderColor = "red"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
771 |
$this->_ShowCountsMode = 2; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
772 |
$this->_RowSortMode = 1; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
773 |
$this->_TDClassHead = "graph-title"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
774 |
$this->_TDClassLabel = "graph-label"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
775 |
$this->_TDClassCount = "graph-count"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
776 |
$this->_GraphTitle="Graph title"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
777 |
$this->_BarBackgroundColor = "#456798"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
778 |
} |
1 | 779 |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
780 |
function GraphMaker_compat() { |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
781 |
$this->__construct(); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
782 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
783 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
784 |
function SetBarBorderWidth($width) { |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
785 |
$this->_BarBorderWidth = $width; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
786 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
787 |
function SetBorderColor($color) { |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
788 |
$this->_BarBorderColor = $color; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
789 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
790 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
791 |
function SetBarBackgroundColor($color) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
792 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
793 |
$this->_BarBackgroundColor = $color; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
794 |
} |
1 | 795 |
|
796 |
// mode = 1 labels asc, 2 label desc |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
797 |
function SetSortMode($mode) { |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
798 |
switch ($mode) { |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
799 |
case 1: |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
800 |
asort($this->_values); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
801 |
break; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
802 |
case 2: |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
803 |
arsort($this->_values); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
804 |
break; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
805 |
default: |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
806 |
break; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
807 |
} |
1 | 808 |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
809 |
} |
1 | 810 |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
811 |
function AddValue($labelName, $theValue) { |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
812 |
array_push($this->_values, array("label" => $labelName, "value" => $theValue)); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
813 |
} |
1 | 814 |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
815 |
function SetBarData($data) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
816 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
817 |
foreach ( $data as $name => $value ) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
818 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
819 |
$this->AddValue($name, $value); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
820 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
821 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
822 |
function DrawGraph() |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
823 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
824 |
$this->BarGraphVert(); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
825 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
826 |
function SetBarWidth($width) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
827 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
828 |
$this->_BarWidth = $width; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
829 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
830 |
function SetBarImg($img) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
831 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
832 |
$this->_BarImg = $img; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
833 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
834 |
function SetShowLabels($lables) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
835 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
836 |
$this->_ShowLabels = $labels; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
837 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
838 |
function SetGraphWidth($width) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
839 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
840 |
$this->_GraphWidth = $width; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
841 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
842 |
function SetGraphTitle($title) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
843 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
844 |
$this->_GraphTitle = $title; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
845 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
846 |
//mode = percentage or counts |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
847 |
function SetShowCountsMode($mode) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
848 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
849 |
$this->_ShowCountsMode = $mode; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
850 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
851 |
//mode = none(0) label(1) or count(2) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
852 |
function SetRowSortMode($sortmode) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
853 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
854 |
$this->_RowSortMode = $sortmode; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
855 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
856 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
857 |
function SetTDClassHead($class) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
858 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
859 |
$this->_TDClassHead = $class; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
860 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
861 |
function SetTDClassLabel($class) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
862 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
863 |
$this->_TDClassLabel = $class; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
864 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
865 |
function SetTDClassCount($class) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
866 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
867 |
$this->_TDClassCount = $class; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
868 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
869 |
function GetMaxVal() |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
870 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
871 |
$maxval = 0; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
872 |
foreach ( $this->_values as $value ) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
873 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
874 |
if ( $maxval < $value["value"] ) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
875 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
876 |
$maxval = $value["value"]; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
877 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
878 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
879 |
return $maxval; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
880 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
881 |
function BarGraphVert() |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
882 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
883 |
$maxval = $this->GetMaxVal(); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
884 |
foreach($this->_values as $value) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
885 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
886 |
$sumval += $value["value"]; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
887 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
888 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
889 |
$this->SetSortMode($this->_RowSortMode); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
890 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
891 |
echo "\n<!-- ----------------------------------------- -->\n<div class=\"tblholder\" style=\"width: 100%; clip: rect(0px,auto,auto,0px); overflow: auto;\">\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\">\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
892 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
893 |
if ( strlen($this->_GraphTitle) > 0 ) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
894 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
895 |
echo "<tr>\n <th colspan=\"".count($this->_values)."\" class=\"".$this->_TDClassHead."\">".$this->_GraphTitle."</th>\n </tr>\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
896 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
897 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
898 |
echo "<tr>\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
899 |
$css_class = 'row1'; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
900 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
901 |
foreach($this->_values as $value) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
902 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
903 |
$css_class = ( $css_class == 'row1' ) ? 'row3' : 'row1'; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
904 |
echo " <td valign=\"bottom\" align=\"center\" class=\"$css_class\">\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
905 |
$width = $this->_BarWidth; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
906 |
$height = ceil( $value["value"] * $this->_GraphWidth / $maxval ); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
907 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
908 |
echo "<div style=\"width: {$width}px; height: {$height}px; background-color: {$this->_BarBackgroundColor}; border: ".$this->_BarBorderWidth."px solid ".$this->_BarBorderColor."\">\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
909 |
echo "</div>\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
910 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
911 |
// echo "<img src=\"".$this->_BarImg."\" height=\"$width\" width=\"$height\" "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
912 |
// echo " style=\"border: ".$this->_BarBorderWidth."px solid ".$this->_BarBorderColor."\""; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
913 |
// echo ">"; |
1 | 914 |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
915 |
echo "</td>\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
916 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
917 |
echo "</tr>\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
918 |
if ( $this->_ShowCountsMode > 0 ) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
919 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
920 |
$css_class = 'row1'; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
921 |
echo "<tr>\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
922 |
foreach($this->_values as $value) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
923 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
924 |
$css_class = ( $css_class == 'row1' ) ? 'row3' : 'row1'; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
925 |
switch ($this->_ShowCountsMode) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
926 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
927 |
case 1: |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
928 |
$count = round ( 100 * $value["value"] / $sumval ) . "%"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
929 |
break; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
930 |
case 2: |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
931 |
$count = $value["value"]; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
932 |
break; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
933 |
default: |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
934 |
break; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
935 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
936 |
echo " <td align=\"center\" class=\"$css_class ".$this->_TDClassCount."\">$count</td>\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
937 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
938 |
echo "</tr>\n"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
939 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
940 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
941 |
if ($this->_ShowLabels) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
942 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
943 |
$css_class = 'row1'; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
944 |
echo " <tr>\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
945 |
foreach($this->_values as $value) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
946 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
947 |
$css_class = ( $css_class == 'row1' ) ? 'row3' : 'row1'; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
948 |
echo " <td align=\"center\" class=\"$css_class ".$this->_TDClassLabel."\""; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
949 |
echo ">".$value["label"]."</td>\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
950 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
951 |
echo "</tr>\n"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
952 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
953 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
954 |
echo "</table>"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
955 |
} |
1 | 956 |
|
323
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
957 |
function BarGraphHoriz() |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
958 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
959 |
$maxval = $this->GetMaxVal(); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
960 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
961 |
foreach($this->_values as $value) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
962 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
963 |
$sumval += $value["value"]; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
964 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
965 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
966 |
$this->SetSortMode($this->_RowSortMode); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
967 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
968 |
echo "<table border=\"0\">"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
969 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
970 |
if ( strlen($this->_GraphTitle) > 0 ) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
971 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
972 |
echo "<tr><td "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
973 |
if ( $this->_ShowCountsMode > 0 ) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
974 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
975 |
echo " colspan=\"2\""; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
976 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
977 |
echo " class=\"".$this->_TDClassHead."\">".$this->_GraphTitle."</td></tr>"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
978 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
979 |
foreach($this->_values as $value) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
980 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
981 |
if ($this->_ShowLabels) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
982 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
983 |
echo "<tr>"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
984 |
echo "<td class=\"".$this->_TDClassLabel."\""; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
985 |
if ( $this->_ShowCountsMode > 0 ) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
986 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
987 |
echo " colspan=\"2\""; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
988 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
989 |
echo ">".$value["label"]."</td></tr>"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
990 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
991 |
echo "<tr>"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
992 |
if ( $this->_ShowCountsMode > 0 ) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
993 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
994 |
switch ($this->_ShowCountsMode) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
995 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
996 |
case 1: |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
997 |
$count = round(100 * $value["value"] / $sumval )."%"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
998 |
break; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
999 |
case 2: |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1000 |
$count = $value["value"]; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1001 |
break; /* Exit the switch and the while. */ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1002 |
default: |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1003 |
break; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1004 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1005 |
echo "<td class=\"".$this->_TDClassCount."\">$count</TD>"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1006 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1007 |
echo "<td>"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1008 |
$height = $this->_BarWidth; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1009 |
$width = ceil( $value["value"] * $this->_GraphWidth / $maxval ); |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1010 |
echo "<div style=\"width: {$width}px; height: {$height}px; background-color: #456798; border: ".$this->_BarBorderWidth."px solid ".$this->_BarBorderColor."\">\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1011 |
echo "</div>\n "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1012 |
//echo "<img SRC=\"".$this->_BarImg."\" height=$height width=$width "; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1013 |
//echo " style=\"border: ".$this->_BarBorderWidth."px solid ".$this->_BarBorderColor."\""; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1014 |
//echo ">"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1015 |
echo "</td></tr>"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1016 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1017 |
echo "</table>"; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1018 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1019 |
/** |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1020 |
* Dummy functions for compatibility with the GD version of the class |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1021 |
*/ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1022 |
|
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1023 |
function SetGraphPadding($a, $b, $c, $d) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1024 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1025 |
return true; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1026 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1027 |
function SetBarPadding($a) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1028 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1029 |
return true; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1030 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1031 |
function SetAxisStep($a) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1032 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1033 |
return true; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1034 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1035 |
function SetGraphBackgroundTransparent($r, $g, $b, $a) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1036 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1037 |
return true; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1038 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1039 |
function SetGraphTransparency($a) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1040 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1041 |
return true; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1042 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1043 |
function SetGraphAreaHeight($a) |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1044 |
{ |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1045 |
return true; |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1046 |
} |
a82133ce2d76
A number of updates to the graphing code (it should actually work now)
Dan
parents:
322
diff
changeset
|
1047 |
} |
1 | 1048 |
|
1049 |