1 |
<?php |
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 |
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 |
|
---|
23 |
class PHPlot { |
---|
24 |
|
---|
25 |
|
---|
26 |
* but now the variables left are those which can be tweaked by the user. This is intended to |
---|
27 |
* be the first step towards moving most of the Set...() methods into a subclass which will be |
---|
28 |
* used only when strictly necessary. Many users will be able to put default values here in the |
---|
29 |
* class and thus avoid memory overhead and reduce parsing times. |
---|
30 |
*/ |
---|
31 |
//////////////// CONFIG PARAMETERS ////////////////////// |
---|
32 |
|
---|
33 |
var $is_inline = FALSE; |
---|
34 |
var $browser_cache = FALSE; |
---|
35 |
// (only if is_inline = FALSE also) |
---|
36 |
|
---|
37 |
var $safe_margin = 5; |
---|
38 |
|
---|
39 |
var $x_axis_position = ''; |
---|
40 |
var $y_axis_position = ''; |
---|
41 |
|
---|
42 |
var $xscale_type = 'linear'; |
---|
43 |
var $yscale_type = 'linear'; |
---|
44 |
|
---|
45 |
|
---|
46 |
var $use_ttf = FALSE; |
---|
47 |
var $ttf_path = '.'; |
---|
48 |
var $default_ttfont = 'benjamingothic.ttf'; |
---|
49 |
$line_spacing = 4; |
---|
50 |
|
---|
51 |
|
---|
52 |
var $x_label_angle = 0; |
---|
53 |
var $y_label_angle = 0; |
---|
54 |
|
---|
55 |
|
---|
56 |
var $file_format = 'png'; |
---|
57 |
$output_file = ''; |
---|
58 |
|
---|
59 |
|
---|
60 |
var $data_type = 'text-data'; |
---|
61 |
var $plot_type= 'linepoints'; |
---|
62 |
|
---|
63 |
var $label_scale_position = 0.5; |
---|
64 |
var $group_frac_width = 0.7; |
---|
65 |
var $bar_extra_space = 0.5; |
---|
66 |
var $bar_width_adjust = 1; |
---|
67 |
|
---|
68 |
var $y_precision = 1; |
---|
69 |
$x_precision = 1; |
---|
70 |
|
---|
71 |
$data_units_text = ''; |
---|
72 |
|
---|
73 |
|
---|
74 |
var $title_txt = ''; |
---|
75 |
|
---|
76 |
$x_title_txt = ''; |
---|
77 |
$x_title_pos = 'plotdown'; |
---|
78 |
|
---|
79 |
var $y_title_txt = ''; |
---|
80 |
$y_title_pos = 'plotleft'; |
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 |
var $x_tick_label_pos = 'plotdown'; |
---|
93 |
var $y_tick_label_pos = 'plotleft'; |
---|
94 |
|
---|
95 |
|
---|
96 |
var $x_data_label_pos = 'plotdown'; |
---|
97 |
var $y_data_label_pos = 'plotleft'; |
---|
98 |
|
---|
99 |
var $draw_x_data_label_lines = FALSE; |
---|
100 |
var $draw_y_data_label_lines = FALSE; |
---|
101 |
|
---|
102 |
|
---|
103 |
var $x_label_type = ''; |
---|
104 |
var $y_label_type = ''; |
---|
105 |
var $x_time_format = '%H:%M:%S'; |
---|
106 |
var $y_time_format = '%H:%M:%S'; |
---|
107 |
|
---|
108 |
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|
112 |
|
---|
113 |
|
---|
114 |
var $legend = ''; |
---|
115 |
|
---|
116 |
|
---|
117 |
|
---|
118 |
|
---|
119 |
|
---|
120 |
|
---|
121 |
|
---|
122 |
|
---|
123 |
var $x_tick_length = 5; |
---|
124 |
var $y_tick_length = 5; |
---|
125 |
|
---|
126 |
var $x_tick_cross = 3; |
---|
127 |
var $y_tick_cross = 3; |
---|
128 |
|
---|
129 |
var $x_tick_pos = 'plotdown'; |
---|
130 |
var $y_tick_pos = 'plotleft'; |
---|
131 |
|
---|
132 |
var $num_x_ticks = ''; |
---|
133 |
$num_y_ticks = ''; |
---|
134 |
|
---|
135 |
$x_tick_inc = ''; |
---|
136 |
var $y_tick_inc = ''; |
---|
137 |
|
---|
138 |
var $skip_top_tick = FALSE; |
---|
139 |
$skip_bottom_tick = FALSE; |
---|
140 |
$skip_left_tick = FALSE; |
---|
141 |
$skip_right_tick = FALSE; |
---|
142 |
|
---|
143 |
|
---|
144 |
var $draw_x_grid = FALSE; |
---|
145 |
$draw_y_grid = TRUE; |
---|
146 |
|
---|
147 |
$dashed_grid = TRUE; |
---|
148 |
$grid_at_foreground = FALSE; |
---|
149 |
|
---|
150 |
|
---|
151 |
var $color_array = 'small'; |
---|
152 |
|
---|
153 |
var $i_border = array(194, 194, 194); |
---|
154 |
$plot_bg_color = 'white'; |
---|
155 |
$bg_color = 'white'; |
---|
156 |
$label_color = 'black'; |
---|
157 |
$text_color = 'black'; |
---|
158 |
$grid_color = 'black'; |
---|
159 |
$light_grid_color = 'gray'; |
---|
160 |
$tick_color = 'black'; |
---|
161 |
$title_color = 'black'; |
---|
162 |
$data_colors = array('SkyBlue', 'green', 'orange', 'blue', 'orange', 'red', 'violet', 'azure1'); |
---|
163 |
$error_bar_colors = array('SkyBlue', 'green', 'orange', 'blue', 'orange', 'red', 'violet', 'azure1'); |
---|
164 |
$data_border_colors = array('black'); |
---|
165 |
|
---|
166 |
$line_widths = 1; |
---|
167 |
var $line_styles = array('solid', 'solid', 'dashed'); |
---|
168 |
var $dashed_style = '2-4'; |
---|
169 |
|
---|
170 |
var $point_sizes = array(5,5,3); |
---|
171 |
var $point_shapes = array('diamond'); |
---|
172 |
|
---|
173 |
var $error_bar_size = 5; |
---|
174 |
var $error_bar_shape = 'tee'; |
---|
175 |
var $error_bar_line_width = 1; |
---|
176 |
|
---|
177 |
var $plot_border_type = 'sides'; |
---|
178 |
var $image_border_type = 'none'; |
---|
179 |
|
---|
180 |
var $shading = 5; |
---|
181 |
|
---|
182 |
var $draw_plot_area_background = FALSE; |
---|
183 |
$draw_broken_lines = FALSE; |
---|
184 |
|
---|
185 |
|
---|
186 |
var $callbacks = array( |
---|
187 |
'draw_setup' => NULL, |
---|
188 |
'draw_image_background' => NULL, |
---|
189 |
'draw_plotarea_background' => NULL, |
---|
190 |
'draw_titles' => NULL, |
---|
191 |
'draw_axes' => NULL, |
---|
192 |
'draw_graph' => NULL, |
---|
193 |
'draw_border' => NULL, |
---|
194 |
'draw_legend' => NULL, |
---|
195 |
'debug_textbox' => NULL, |
---|
196 |
'debug_scale' => NULL, |
---|
197 |
); |
---|
198 |
|
---|
199 |
|
---|
200 |
|
---|
201 |
|
---|
202 |
|
---|
203 |
|
---|
204 |
|
---|
205 |
|
---|
206 |
|
---|
207 |
|
---|
208 |
|
---|
209 |
|
---|
210 |
|
---|
211 |
|
---|
212 |
function PHPlot($which_width=600, $which_height=400, $which_output_file=NULL, $which_input_file=NULL) |
---|
213 |
|
---|
214 |
$this->SetRGBArray($this->color_array); |
---|
215 |
|
---|
216 |
$this->background_done = FALSE; |
---|
217 |
$this->plot_margins_set = FALSE; |
---|
218 |
|
---|
219 |
if ($which_output_file) |
---|
220 |
$this->SetOutputFile($which_output_file); |
---|
221 |
|
---|
222 |
$which_input_file) |
---|
223 |
$this->SetInputFile($which_input_file); |
---|
224 |
|
---|
225 |
$this->image_width = $which_width; |
---|
226 |
$this->image_height = $which_height; |
---|
227 |
|
---|
228 |
$this->img = ImageCreate($this->image_width, $this->image_height); |
---|
229 |
$this->img) |
---|
230 |
$this->PrintError('PHPlot(): Could not create image resource.'); |
---|
231 |
|
---|
232 |
|
---|
233 |
|
---|
234 |
$this->SetDefaultStyles(); |
---|
235 |
$this->SetDefaultFonts(); |
---|
236 |
|
---|
237 |
$this->SetTitle(''); |
---|
238 |
$this->SetXTitle(''); |
---|
239 |
$this->SetYTitle(''); |
---|
240 |
|
---|
241 |
$this->print_image = TRUE; |
---|
242 |
} |
---|
243 |
|
---|
244 |
|
---|
245 |
|
---|
246 |
|
---|
247 |
|
---|
248 |
|
---|
249 |
function GetImage($image_filename, &$width, &$height) |
---|
250 |
|
---|
251 |
$error = ''; |
---|
252 |
$size = getimagesize($image_filename); |
---|
253 |
$size) { |
---|
254 |
$error = "Unable to query image file $image_filename"; |
---|
255 |
|
---|
256 |
$image_type = $size[2]; |
---|
257 |
$image_type) { |
---|
258 |
IMAGETYPE_GIF: |
---|
259 |
$img = @ ImageCreateFromGIF ($image_filename); |
---|
260 |
|
---|
261 |
IMAGETYPE_PNG: |
---|
262 |
$img = @ ImageCreateFromPNG ($image_filename); |
---|
263 |
|
---|
264 |
IMAGETYPE_JPEG: |
---|
265 |
$img = @ ImageCreateFromJPEG ($image_filename); |
---|
266 |
|
---|
267 |
|
---|
268 |
$error = "Unknown image type ($image_type) for image file $image_filename"; |
---|
269 |
|
---|
270 |
|
---|
271 |
|
---|
272 |
$error) && !$img) { |
---|
273 |
|
---|
274 |
$error = "Failed to read image file $image_filename"; |
---|
275 |
|
---|
276 |
$error)) { |
---|
277 |
$this->PrintError("GetImage(): $error"); |
---|
278 |
|
---|
279 |
$width = $size[0]; |
---|
280 |
$height = $size[1]; |
---|
281 |
$img; |
---|
282 |
|
---|
283 |
|
---|
284 |
|
---|
285 |
|
---|
286 |
|
---|
287 |
|
---|
288 |
|
---|
289 |
function SetInputFile($which_input_file) |
---|
290 |
|
---|
291 |
$im = $this->GetImage($which_input_file, $this->image_width, $this->image_height); |
---|
292 |
$im) |
---|
293 |
FALSE; |
---|
294 |
|
---|
295 |
|
---|
296 |
if (isset($this->img)) |
---|
297 |
imagedestroy($this->img); |
---|
298 |
|
---|
299 |
$this->img = $im; |
---|
300 |
|
---|
301 |
|
---|
302 |
$this->background_done = TRUE; |
---|
303 |
|
---|
304 |
TRUE; |
---|
305 |
|
---|
306 |
|
---|
307 |
|
---|
308 |
|
---|
309 |
|
---|
310 |
|
---|
311 |
|
---|
312 |
|
---|
313 |
|
---|
314 |
|
---|
315 |
|
---|
316 |
|
---|
317 |
function SetIndexColor($which_color) |
---|
318 |
|
---|
319 |
$r, $g, $b) = $this->SetRGBColor($which_color); |
---|
320 |
if (!isset($r)) return NULL; |
---|
321 |
ImageColorResolve($this->img, $r, $g, $b); |
---|
322 |
|
---|
323 |
|
---|
324 |
|
---|
325 |
|
---|
326 |
|
---|
327 |
|
---|
328 |
|
---|
329 |
function SetIndexDarkColor($which_color) |
---|
330 |
|
---|
331 |
$r, $g, $b) = $this->SetRGBColor($which_color); |
---|
332 |
$r)) return NULL; |
---|
333 |
$r = max(0, $r - 0x30); |
---|
334 |
$g = max(0, $g - 0x30); |
---|
335 |
$b = max(0, $b - 0x30); |
---|
336 |
ImageColorResolve($this->img, $r, $g, $b); |
---|
337 |
|
---|
338 |
|
---|
339 |
|
---|
340 |
|
---|
341 |
|
---|
342 |
|
---|
343 |
|
---|
344 |
|
---|
345 |
|
---|
346 |
|
---|
347 |
function SetDefaultStyles() |
---|
348 |
|
---|
349 |
|
---|
350 |
|
---|
351 |
if (! isset($this->session_set)) { |
---|
352 |
|
---|
353 |
|
---|
354 |
|
---|
355 |
$this->session_set = TRUE; |
---|
356 |
|
---|
357 |
|
---|
358 |
$this->SetLineWidths(); |
---|
359 |
$this->SetLineStyles(); |
---|
360 |
$this->SetDefaultDashedStyle($this->dashed_style); |
---|
361 |
$this->SetPointSizes($this->point_sizes); |
---|
362 |
|
---|
363 |
|
---|
364 |
$this->SetImageBorderColor($this->i_border); |
---|
365 |
$this->SetPlotBgColor($this->plot_bg_color); |
---|
366 |
$this->SetBackgroundColor($this->bg_color); |
---|
367 |
$this->SetLabelColor($this->label_color); |
---|
368 |
$this->SetTextColor($this->text_color); |
---|
369 |
$this->SetGridColor($this->grid_color); |
---|
370 |
$this->SetLightGridColor($this->light_grid_color); |
---|
371 |
$this->SetTickColor($this->tick_color); |
---|
372 |
$this->SetTitleColor($this->title_color); |
---|
373 |
$this->SetDataColors(); |
---|
374 |
$this->SetErrorBarColors(); |
---|
375 |
$this->SetDataBorderColors(); |
---|
376 |
TRUE; |
---|
377 |
|
---|
378 |
|
---|
379 |
|
---|
380 |
|
---|
381 |
|
---|
382 |
|
---|
383 |
function SetBackgroundColor($which_color) |
---|
384 |
|
---|
385 |
$this->bg_color= $which_color; |
---|
386 |
$this->ndx_bg_color= $this->SetIndexColor($this->bg_color); |
---|
387 |
$this->ndx_bg_color); |
---|
388 |
|
---|
389 |
|
---|
390 |
|
---|
391 |
|
---|
392 |
|
---|
393 |
function SetPlotBgColor($which_color) |
---|
394 |
|
---|
395 |
$this->plot_bg_color= $which_color; |
---|
396 |
$this->ndx_plot_bg_color= $this->SetIndexColor($this->plot_bg_color); |
---|
397 |
$this->ndx_plot_bg_color); |
---|
398 |
|
---|
399 |
|
---|
400 |
|
---|
401 |
|
---|
402 |
|
---|
403 |
function SetTitleColor($which_color) |
---|
404 |
|
---|
405 |
$this->title_color= $which_color; |
---|
406 |
$this->ndx_title_color= $this->SetIndexColor($this->title_color); |
---|
407 |
$this->ndx_title_color); |
---|
408 |
|
---|
409 |
|
---|
410 |
|
---|
411 |
|
---|
412 |
|
---|
413 |
function SetTickColor ($which_color) |
---|
414 |
|
---|
415 |
$this->tick_color= $which_color; |
---|
416 |
$this->ndx_tick_color= $this->SetIndexColor($this->tick_color); |
---|
417 |
$this->ndx_tick_color); |
---|
418 |
|
---|
419 |
|
---|
420 |
|
---|
421 |
|
---|
422 |
|
---|
423 |
|
---|
424 |
function SetLabelColor ($which_color) |
---|
425 |
|
---|
426 |
$this->label_color = $which_color; |
---|
427 |
$this->ndx_title_color= $this->SetIndexColor($this->label_color); |
---|
428 |
$this->ndx_title_color); |
---|
429 |
|
---|
430 |
|
---|
431 |
|
---|
432 |
|
---|
433 |
|
---|
434 |
|
---|
435 |
function SetTextColor ($which_color) |
---|
436 |
|
---|
437 |
$this->text_color= $which_color; |
---|
438 |
$this->ndx_text_color= $this->SetIndexColor($this->text_color); |
---|
439 |
$this->ndx_text_color); |
---|
440 |
|
---|
441 |
|
---|
442 |
|
---|
443 |
|
---|
444 |
|
---|
445 |
|
---|
446 |
function SetLightGridColor ($which_color) |
---|
447 |
|
---|
448 |
$this->light_grid_color= $which_color; |
---|
449 |
$this->ndx_light_grid_color= $this->SetIndexColor($this->light_grid_color); |
---|
450 |
$this->ndx_light_grid_color); |
---|
451 |
|
---|
452 |
|
---|
453 |
|
---|
454 |
|
---|
455 |
|
---|
456 |
|
---|
457 |
function SetGridColor ($which_color) |
---|
458 |
|
---|
459 |
$this->grid_color = $which_color; |
---|
460 |
$this->ndx_grid_color= $this->SetIndexColor($this->grid_color); |
---|
461 |
$this->ndx_grid_color); |
---|
462 |
|
---|
463 |
|
---|
464 |
|
---|
465 |
|
---|
466 |
|
---|
467 |
|
---|
468 |
function SetImageBorderColor($which_color) |
---|
469 |
|
---|
470 |
$this->i_border = $which_color; |
---|
471 |
$this->ndx_i_border = $this->SetIndexColor($this->i_border); |
---|
472 |
$this->ndx_i_border_dark = $this->SetIndexDarkColor($this->i_border); |
---|
473 |
$this->ndx_i_border); |
---|
474 |
|
---|
475 |
|
---|
476 |
|
---|
477 |
|
---|
478 |
|
---|
479 |
|
---|
480 |
function SetTransparentColor($which_color) |
---|
481 |
|
---|
482 |
$ndx = $this->SetIndexColor($which_color); |
---|
483 |
$ndx)) |
---|
484 |
FALSE; |
---|
485 |
ImageColorTransparent($this->img, $ndx); |
---|
486 |
TRUE; |
---|
487 |
|
---|
488 |
|
---|
489 |
|
---|
490 |
|
---|
491 |
|
---|
492 |
|
---|
493 |
|
---|
494 |
|
---|
495 |
|
---|
496 |
|
---|
497 |
function SetRGBArray ($which_color_array) |
---|
498 |
|
---|
499 |
is_array($which_color_array) ) { |
---|
500 |
$this->rgb_array = $which_color_array; |
---|
501 |
TRUE; |
---|
502 |
$which_color_array == 'small') { |
---|
503 |
$this->rgb_array = array( |
---|
504 |
'white' => array(255, 255, 255), |
---|
505 |
'snow' => array(255, 250, 250), |
---|
506 |
'PeachPuff' => array(255, 218, 185), |
---|
507 |
'ivory' => array(255, 255, 240), |
---|
508 |
'lavender' => array(230, 230, 250), |
---|
509 |
'black' => array( 0, 0, 0), |
---|
510 |
'DimGrey' => array(105, 105, 105), |
---|
511 |
'gray' => array(190, 190, 190), |
---|
512 |
'grey' => array(190, 190, 190), |
---|
513 |
'navy' => array( 0, 0, 128), |
---|
514 |
'SlateBlue' => array(106, 90, 205), |
---|
515 |
'blue' => array( 0, 0, 255), |
---|
516 |
'SkyBlue' => array(135, 206, 235), |
---|
517 |
'cyan' => array( 0, 255, 255), |
---|
518 |
'DarkGreen' => array( 0, 100, 0), |
---|
519 |
'green' => array( 0, 255, 0), |
---|
520 |
'YellowGreen' => array(154, 205, 50), |
---|
521 |
'yellow' => array(255, 255, 0), |
---|
522 |
'orange' => array(255, 165, 0), |
---|
523 |
'gold' => array(255, 215, 0), |
---|
524 |
'peru' => array(205, 133, 63), |
---|
525 |
'beige' => array(245, 245, 220), |
---|
526 |
'wheat' => array(245, 222, 179), |
---|
527 |
'tan' => array(210, 180, 140), |
---|
528 |
'brown' => array(165, 42, 42), |
---|
529 |
'salmon' => array(250, 128, 114), |
---|
530 |
'red' => array(255, 0, 0), |
---|
531 |
'pink' => array(255, 192, 203), |
---|
532 |
'maroon' => array(176, 48, 96), |
---|
533 |
'magenta' => array(255, 0, 255), |
---|
534 |
'violet' => array(238, 130, 238), |
---|
535 |
'plum' => array(221, 160, 221), |
---|
536 |
'orchid' => array(218, 112, 214), |
---|
537 |
'purple' => array(160, 32, 240), |
---|
538 |
'azure1' => array(240, 255, 255), |
---|
539 |
'aquamarine1' => array(127, 255, 212) |
---|
540 |
|
---|
541 |
TRUE; |
---|
542 |
$which_color_array === 'large') { |
---|
543 |
include("./rgb.inc.php"); |
---|
544 |
$this->rgb_array = $RGBArray; |
---|
545 |
|
---|
546 |
$this->rgb_array = array('white' => array(255, 255, 255), 'black' => array(0, 0, 0)); |
---|
547 |
|
---|
548 |
|
---|
549 |
TRUE; |
---|
550 |
|
---|
551 |
|
---|
552 |
|
---|
553 |
|
---|
554 |
|
---|
555 |
|
---|
556 |
|
---|
557 |
function SetRGBColor($color_asked) |
---|
558 |
|
---|
559 |
$color_asked)) { |
---|
560 |
$ret_val = array(0, 0, 0); |
---|
561 |
count($color_asked) == 3 ) { |
---|
562 |
$ret_val = $color_asked; |
---|
563 |
$color_asked[0] == '#') { |
---|
564 |
$ret_val = array(hexdec(substr($color_asked, 1, 2)), |
---|
565 |
hexdec(substr($color_asked, 3, 2)), |
---|
566 |
hexdec(substr($color_asked, 5, 2))); |
---|
567 |
|
---|
568 |
$this->rgb_array[$color_asked])) { |
---|
569 |
$ret_val = $this->rgb_array[$color_asked]; |
---|
570 |
|
---|
571 |
$this->PrintError("SetRGBColor(): Color '$color_asked' is not valid."); |
---|
572 |
|
---|
573 |
$ret_val; |
---|
574 |
|
---|
575 |
|
---|
576 |
|
---|
577 |
|
---|
578 |
|
---|
579 |
|
---|
580 |
function SetDataColors($which_data = NULL, $which_border = NULL) |
---|
581 |
|
---|
582 |
is_null($which_data) && is_array($this->data_colors)) { |
---|
583 |
|
---|
584 |
} else if (! is_array($which_data)) { |
---|
585 |
$this->data_colors = ($which_data) ? array($which_data) : array('blue', 'red', 'green', 'orange'); |
---|
586 |
|
---|
587 |
$this->data_colors = $which_data; |
---|
588 |
|
---|
589 |
|
---|
590 |
$i = 0; |
---|
591 |
$this->data_colors as $col) { |
---|
592 |
$ndx = $this->SetIndexColor($col); |
---|
593 |
$ndx)) |
---|
594 |
FALSE; |
---|
595 |
$this->ndx_data_colors[$i] = $ndx; |
---|
596 |
$this->ndx_data_dark_colors[$i] = $this->SetIndexDarkColor($col); |
---|
597 |
$i++; |
---|
598 |
|
---|
599 |
|
---|
600 |
|
---|
601 |
return $this->SetDataBorderColors($which_border); |
---|
602 |
|
---|
603 |
|
---|
604 |
|
---|
605 |
|
---|
606 |
|
---|
607 |
|
---|
608 |
function SetDataBorderColors($which_br = NULL) |
---|
609 |
|
---|
610 |
is_null($which_br) && is_array($this->data_border_colors)) { |
---|
611 |
|
---|
612 |
} else if (! is_array($which_br)) { |
---|
613 |
|
---|
614 |
$this->data_border_colors = ($which_br) ? array($which_br) : array('black'); |
---|
615 |
|
---|
616 |
$this->data_border_colors = $which_br; |
---|
617 |
|
---|
618 |
|
---|
619 |
$i = 0; |
---|
620 |
$this->data_border_colors as $col) { |
---|
621 |
$ndx = $this->SetIndexColor($col); |
---|
622 |
$ndx)) |
---|
623 |
FALSE; |
---|
624 |
$this->ndx_data_border_colors[$i] = $ndx; |
---|
625 |
$i++; |
---|
626 |
|
---|
627 |
TRUE; |
---|
628 |
|
---|
629 |
|
---|
630 |
|
---|
631 |
|
---|
632 |
|
---|
633 |
|
---|
634 |
function SetErrorBarColors($which_err = NULL) |
---|
635 |
|
---|
636 |
is_null($which_err) && is_array($this->error_bar_colors)) { |
---|
637 |
|
---|
638 |
} else if (! is_array($which_err)) { |
---|
639 |
$this->error_bar_colors = ($which_err) ? array($which_err) : array('black'); |
---|
640 |
|
---|
641 |
$this->error_bar_colors = $which_err; |
---|
642 |
|
---|
643 |
|
---|
644 |
$i = 0; |
---|
645 |
$this->error_bar_colors as $col) { |
---|
646 |
$ndx = $this->SetIndexColor($col); |
---|
647 |
$ndx)) |
---|
648 |
FALSE; |
---|
649 |
$this->ndx_error_bar_colors[$i] = $ndx; |
---|
650 |
$i++; |
---|
651 |
|
---|
652 |
TRUE; |
---|
653 |
|
---|
654 |
|
---|
655 |
|
---|
656 |
|
---|
657 |
|
---|
658 |
|
---|
659 |
|
---|
660 |
|
---|
661 |
|
---|
662 |
function SetDefaultDashedStyle($which_style) |
---|
663 |
|
---|
664 |
|
---|
665 |
$asked = explode('-', $which_style); |
---|
666 |
|
---|
667 |
count($asked) < 2) { |
---|
668 |
$this->PrintError("SetDefaultDashedStyle(): Wrong parameter '$which_style'."); |
---|
669 |
|
---|
670 |
|
---|
671 |
|
---|
672 |
$this->default_dashed_style = 'array( '; |
---|
673 |
|
---|
674 |
$t = 0; |
---|
675 |
$asked as $s) { |
---|
676 |
$t % 2 == 0) { |
---|
677 |
$this->default_dashed_style .= str_repeat('$which_ndxcol,', $s); |
---|
678 |
|
---|
679 |
$this->default_dashed_style .= str_repeat('IMG_COLOR_TRANSPARENT,', $s); |
---|
680 |
|
---|
681 |
$t++; |
---|
682 |
|
---|
683 |
|
---|
684 |
$this->default_dashed_style = substr($this->default_dashed_style, 0, -1); |
---|
685 |
$this->default_dashed_style .= ')'; |
---|
686 |
|
---|
687 |
TRUE; |
---|
688 |
|
---|
689 |
|
---|
690 |
|
---|
691 |
|
---|
692 |
|
---|
693 |
|
---|
694 |
|
---|
695 |
function SetDashedStyle($which_ndxcol) |
---|
696 |
|
---|
697 |
|
---|
698 |
eval ("\$style = $this->default_dashed_style;"); |
---|
699 |
imagesetstyle($this->img, $style); |
---|
700 |
|
---|
701 |
|
---|
702 |
|
---|
703 |
|
---|
704 |
|
---|
705 |
|
---|
706 |
function SetLineWidths($which_lw=NULL) |
---|
707 |
|
---|
708 |
is_null($which_lw)) { |
---|
709 |
|
---|
710 |
} else if (is_array($which_lw)) { |
---|
711 |
|
---|
712 |
$this->line_widths = $which_lw; |
---|
713 |
|
---|
714 |
$this->line_widths = array($which_lw); |
---|
715 |
|
---|
716 |
TRUE; |
---|
717 |
|
---|
718 |
|
---|
719 |
|
---|
720 |
|
---|
721 |
|
---|
722 |
function SetLineStyles($which_ls=NULL) |
---|
723 |
|
---|
724 |
is_null($which_ls)) { |
---|
725 |
|
---|
726 |
} else if ( is_array($which_ls)) { |
---|
727 |
|
---|
728 |
$this->line_styles = $which_ls; |
---|
729 |
|
---|
730 |
$this->line_styles = ($which_ls) ? array($which_ls) : array('solid'); |
---|
731 |
|
---|
732 |
TRUE; |
---|
733 |
|
---|
734 |
|
---|
735 |
|
---|
736 |
|
---|
737 |
|
---|
738 |
|
---|
739 |
|
---|
740 |
|
---|
741 |
|
---|
742 |
|
---|
743 |
|
---|
744 |
function SetLineSpacing($which_spc) |
---|
745 |
|
---|
746 |
$this->line_spacing = $which_spc; |
---|
747 |
TRUE; |
---|
748 |
|
---|
749 |
|
---|
750 |
|
---|
751 |
|
---|
752 |
|
---|
753 |
|
---|
754 |
|
---|
755 |
|
---|
756 |
function SetUseTTF($which_ttf) |
---|
757 |
|
---|
758 |
$this->use_ttf = $which_ttf; |
---|
759 |
$this->SetDefaultFonts(); |
---|
760 |
|
---|
761 |
|
---|
762 |
|
---|
763 |
|
---|
764 |
|
---|
765 |
function SetTTFPath($which_path) |
---|
766 |
|
---|
767 |
|
---|
768 |
|
---|
769 |
|
---|
770 |
if (is_dir($which_path) && is_readable($which_path)) { |
---|
771 |
$this->ttf_path = $which_path; |
---|
772 |
TRUE; |
---|
773 |
|
---|
774 |
$this->PrintError("SetTTFPath(): $which_path is not a valid path."); |
---|
775 |
|
---|
776 |
|
---|
777 |
|
---|
778 |
|
---|
779 |
|
---|
780 |
|
---|
781 |
|
---|
782 |
|
---|
783 |
function SetDefaultTTFont($which_font) |
---|
784 |
|
---|
785 |
$this->default_ttfont = $which_font; |
---|
786 |
$this->SetUseTTF(TRUE); |
---|
787 |
|
---|
788 |
|
---|
789 |
|
---|
790 |
|
---|
791 |
|
---|
792 |
function SetDefaultFonts() |
---|
793 |
|
---|
794 |
|
---|
795 |
if ($this->use_ttf) { |
---|
796 |
$this->SetFont('generic', '', 8) |
---|
797 |
$this->SetFont('title', '', 14) |
---|
798 |
$this->SetFont('legend', '', 8) |
---|
799 |
$this->SetFont('x_label', '', 6) |
---|
800 |
$this->SetFont('y_label', '', 6) |
---|
801 |
$this->SetFont('x_title', '', 10) |
---|
802 |
$this->SetFont('y_title', '', 10); |
---|
803 |
|
---|
804 |
|
---|
805 |
return $this->SetFont('generic', 2) |
---|
806 |
$this->SetFont('title', 5) |
---|
807 |
$this->SetFont('legend', 2) |
---|
808 |
$this->SetFont('x_label', 1) |
---|
809 |
$this->SetFont('y_label', 1) |
---|
810 |
$this->SetFont('x_title', 3) |
---|
811 |
$this->SetFont('y_title', 3); |
---|
812 |
|
---|
813 |
|
---|
814 |
|
---|
815 |
|
---|
816 |
|
---|
817 |
|
---|
818 |
|
---|
819 |
|
---|
820 |
|
---|
821 |
|
---|
822 |
|
---|
823 |
|
---|
824 |
|
---|
825 |
function SetFont($which_elem, $which_font, $which_size = 12) |
---|
826 |
|
---|
827 |
|
---|
828 |
if ($this->use_ttf) { |
---|
829 |
|
---|
830 |
if (empty($which_font)) |
---|
831 |
$which_font = $this->default_ttfont; |
---|
832 |
$path = $which_font; |
---|
833 |
|
---|
834 |
|
---|
835 |
if (!is_file($path) || !is_readable($path)) { |
---|
836 |
$path = $this->ttf_path . '/' . $which_font; |
---|
837 |
is_file($path) || !is_readable($path)) { |
---|
838 |
$this->PrintError("SetFont(): Can't find TrueType font $which_font"); |
---|
839 |
|
---|
840 |
|
---|
841 |
|
---|
842 |
$which_elem) { |
---|
843 |
'generic': |
---|
844 |
$this->generic_font['font'] = $path; |
---|
845 |
$this->generic_font['size'] = $which_size; |
---|
846 |
|
---|
847 |
'title': |
---|
848 |
$this->title_font['font'] = $path; |
---|
849 |
$this->title_font['size'] = $which_size; |
---|
850 |
|
---|
851 |
'legend': |
---|
852 |
$this->legend_font['font'] = $path; |
---|
853 |
$this->legend_font['size'] = $which_size; |
---|
854 |
|
---|
855 |
'x_label': |
---|
856 |
$this->x_label_font['font'] = $path; |
---|
857 |
$this->x_label_font['size'] = $which_size; |
---|
858 |
|
---|
859 |
'y_label': |
---|
860 |
$this->y_label_font['font'] = $path; |
---|
861 |
$this->y_label_font['size'] = $which_size; |
---|
862 |
|
---|
863 |
'x_title': |
---|
864 |
$this->x_title_font['font'] = $path; |
---|
865 |
$this->x_title_font['size'] = $which_size; |
---|
866 |
|
---|
867 |
'y_title': |
---|
868 |
$this->y_title_font['font'] = $path; |
---|
869 |
$this->y_title_font['size'] = $which_size; |
---|
870 |
|
---|
871 |
|
---|
872 |
$this->PrintError("SetFont(): Unknown element '$which_elem' specified."); |
---|
873 |
|
---|
874 |
TRUE; |
---|
875 |
|
---|
876 |
|
---|
877 |
|
---|
878 |
|
---|
879 |
if ($which_font > 5 || $which_font < 0) { |
---|
880 |
$this->PrintError('SetFont(): Non-TTF font size must be 1, 2, 3, 4 or 5'); |
---|
881 |
|
---|
882 |
|
---|
883 |
$which_elem) { |
---|
884 |
'generic': |
---|
885 |
$this->generic_font['font'] = $which_font; |
---|
886 |
$this->generic_font['height'] = ImageFontHeight($which_font); |
---|
887 |
$this->generic_font['width'] = ImageFontWidth($which_font); |
---|
888 |
|
---|
889 |
'title': |
---|
890 |
$this->title_font['font'] = $which_font; |
---|
891 |
$this->title_font['height'] = ImageFontHeight($which_font); |
---|
892 |
$this->title_font['width'] = ImageFontWidth($which_font); |
---|
893 |
|
---|
894 |
'legend': |
---|
895 |
$this->legend_font['font'] = $which_font; |
---|
896 |
$this->legend_font['height'] = ImageFontHeight($which_font); |
---|
897 |
$this->legend_font['width'] = ImageFontWidth($which_font); |
---|
898 |
|
---|
899 |
'x_label': |
---|
900 |
$this->x_label_font['font'] = $which_font; |
---|
901 |
$this->x_label_font['height'] = ImageFontHeight($which_font); |
---|
902 |
$this->x_label_font['width'] = ImageFontWidth($which_font); |
---|
903 |
|
---|
904 |
'y_label': |
---|
905 |
$this->y_label_font['font'] = $which_font; |
---|
906 |
$this->y_label_font['height'] = ImageFontHeight($which_font); |
---|
907 |
$this->y_label_font['width'] = ImageFontWidth($which_font); |
---|
908 |
|
---|
909 |
'x_title': |
---|
910 |
$this->x_title_font['font'] = $which_font; |
---|
911 |
$this->x_title_font['height'] = ImageFontHeight($which_font); |
---|
912 |
$this->x_title_font['width'] = ImageFontWidth($which_font); |
---|
913 |
|
---|
914 |
'y_title': |
---|
915 |
$this->y_title_font['font'] = $which_font; |
---|
916 |
$this->y_title_font['height'] = ImageFontHeight($which_font); |
---|
917 |
$this->y_title_font['width'] = ImageFontWidth($which_font); |
---|
918 |
|
---|
919 |
|
---|
920 |
$this->PrintError("SetFont(): Unknown element '$which_elem' specified."); |
---|
921 |
|
---|
922 |
TRUE; |
---|
923 |
|
---|
924 |
|
---|
925 |
|
---|
926 |
|
---|
927 |
|
---|
928 |
|
---|
929 |
|
---|
930 |
|
---|
931 |
|
---|
932 |
|
---|
933 |
|
---|
934 |
|
---|
935 |
|
---|
936 |
|
---|
937 |
|
---|
938 |
|
---|
939 |
|
---|
940 |
|
---|
941 |
|
---|
942 |
|
---|
943 |
|
---|
944 |
|
---|
945 |
|
---|
946 |
|
---|
947 |
|
---|
948 |
|
---|
949 |
|
---|
950 |
|
---|
951 |
|
---|
952 |
|
---|
953 |
|
---|
954 |
|
---|
955 |
|
---|
956 |
|
---|
957 |
|
---|
958 |
|
---|
959 |
|
---|
960 |
|
---|
961 |
|
---|
962 |
|
---|
963 |
|
---|
964 |
|
---|
965 |
|
---|
966 |
|
---|
967 |
|
---|
968 |
|
---|
969 |
|
---|
970 |
|
---|
971 |
|
---|
972 |
|
---|
973 |
|
---|
974 |
|
---|
975 |
|
---|
976 |
|
---|
977 |
|
---|
978 |
|
---|
979 |
|
---|
980 |
|
---|
981 |
|
---|
982 |
|
---|
983 |
|
---|
984 |
|
---|
985 |
|
---|
986 |
|
---|
987 |
|
---|
988 |
|
---|
989 |
|
---|
990 |
|
---|
991 |
|
---|
992 |
|
---|
993 |
|
---|
994 |
|
---|
995 |
|
---|
996 |
|
---|
997 |
|
---|
998 |
|
---|
999 |
|
---|
1000 |
|
---|
1001 |
|
---|
1002 |
|
---|
1003 |
function ProcessTextGD($draw_it, $font_number, $font_width, $font_height, $angle, $x, $y, $color, |
---|
1004 |
$text, $h_factor, $v_factor) |
---|
1005 |
|
---|
1006 |
|
---|
1007 |
|
---|
1008 |
$longest = 0; |
---|
1009 |
explode("\n", $text) as $each_line) { |
---|
1010 |
$lines[] = $line = trim($each_line); |
---|
1011 |
$line_lens[] = $line_len = strlen($line); |
---|
1012 |
$line_len > $longest) $longest = $line_len; |
---|
1013 |
|
---|
1014 |
$n_lines = count($lines); |
---|
1015 |
$spacing = $this->line_spacing * ($n_lines - 1); |
---|
1016 |
|
---|
1017 |
|
---|
1018 |
|
---|
1019 |
$total_width = $longest * $font_width; |
---|
1020 |
$total_height = $n_lines * $font_height + $spacing; |
---|
1021 |
|
---|
1022 |
$draw_it) { |
---|
1023 |
$angle < 45) return array($total_width, $total_height); |
---|
1024 |
$total_height, $total_width); |
---|
1025 |
|
---|
1026 |
|
---|
1027 |
$interline_step = $font_height + $this->line_spacing; |
---|
1028 |
|
---|
1029 |
if ($angle >= 45) { |
---|
1030 |
|
---|
1031 |
|
---|
1032 |
|
---|
1033 |
$temp = $v_factor; |
---|
1034 |
$v_factor = $h_factor; |
---|
1035 |
$h_factor = 1 - $temp; |
---|
1036 |
|
---|
1037 |
$draw_func = 'ImageStringUp'; |
---|
1038 |
|
---|
1039 |
|
---|
1040 |
$r00 = 0; $r01 = 1; |
---|
1041 |
$r10 = -1; $r11 = 0; |
---|
1042 |
|
---|
1043 |
|
---|
1044 |
|
---|
1045 |
$draw_func = 'ImageString'; |
---|
1046 |
|
---|
1047 |
|
---|
1048 |
$r00 = 1; $r01 = 0; |
---|
1049 |
$r10 = 0; $r11 = 1; |
---|
1050 |
|
---|
1051 |
|
---|
1052 |
|
---|
1053 |
$factor = (int)($total_height * $v_factor); |
---|
1054 |
$xpos = $x - $r01 * $factor; |
---|
1055 |
$ypos = $y - $r11 * $factor; |
---|
1056 |
|
---|
1057 |
|
---|
1058 |
if ($this->GetCallback('debug_textbox')) { |
---|
1059 |
$angle >= 45) { |
---|
1060 |
$bbox_width = $total_height; |
---|
1061 |
$bbox_height = $total_width; |
---|
1062 |
$px = $xpos; |
---|
1063 |
$py = $ypos - (1 - $h_factor) * $total_width; |
---|
1064 |
|
---|
1065 |
$bbox_width = $total_width; |
---|
1066 |
$bbox_height = $total_height; |
---|
1067 |
$px = $xpos - $h_factor * $total_width; |
---|
1068 |
$py = $ypos; |
---|
1069 |
|
---|
1070 |
$this->DoCallback('debug_textbox', $px, $py, $bbox_width, $bbox_height); |
---|
1071 |
|
---|
1072 |
|
---|
1073 |
$i = 0; $i < $n_lines; $i++) { |
---|
1074 |
|
---|
1075 |
$line = $lines[$i]; |
---|
1076 |
$line_len = $line_lens[$i]; |
---|
1077 |
|
---|
1078 |
|
---|
1079 |
$factor = (int)($line_len * $font_width * $h_factor); |
---|
1080 |
$x = $xpos - $r00 * $factor; |
---|
1081 |
$y = $ypos - $r10 * $factor; |
---|
1082 |
|
---|
1083 |
|
---|
1084 |
$draw_func($this->img, $font_number, $x, $y, $line, $color); |
---|
1085 |
|
---|
1086 |
|
---|
1087 |
$xpos += $r01 * $interline_step; |
---|
1088 |
$ypos += $r11 * $interline_step; |
---|
1089 |
|
---|
1090 |
TRUE; |
---|
1091 |
|
---|
1092 |
|
---|
1093 |
|
---|
1094 |
|
---|
1095 |
|
---|
1096 |
|
---|
1097 |
|
---|
1098 |
|
---|
1099 |
|
---|
1100 |
|
---|
1101 |
|
---|
1102 |
|
---|
1103 |
|
---|
1104 |
|
---|
1105 |
|
---|
1106 |
|
---|
1107 |
|
---|
1108 |
function ProcessTextTTF($draw_it, $font_file, $font_size, $angle, $x, $y, $color, |
---|
1109 |
$text, $h_factor, $v_factor) |
---|
1110 |
|
---|
1111 |
|
---|
1112 |
|
---|
1113 |
|
---|
1114 |
|
---|
1115 |
|
---|
1116 |
|
---|
1117 |
|
---|
1118 |
$total_height = 0; |
---|
1119 |
$total_width = 0; |
---|
1120 |
explode("\n", $text) as $each_line) { |
---|
1121 |
$lines[] = $line = trim($each_line); |
---|
1122 |
$bbox = ImageTTFBBox($font_size, 0, $font_file, $line); |
---|
1123 |
$height = $bbox[1] - $bbox[5]; |
---|
1124 |
$width = $bbox[2] - $bbox[0]; |
---|
1125 |
$total_height += $height; |
---|
1126 |
$width > $total_width) $total_width = $width; |
---|
1127 |
$line_widths[] = $width; |
---|
1128 |
$line_heights[] = $height; |
---|
1129 |
|
---|
1130 |
$n_lines = count($lines); |
---|
1131 |
$total_height += ($n_lines - 1) * $this->line_spacing; |
---|
1132 |
|
---|
1133 |
|
---|
1134 |
|
---|
1135 |
$theta = deg2rad($angle); |
---|
1136 |
$cos_t = cos($theta); |
---|
1137 |
$sin_t = sin($theta); |
---|
1138 |
$r00 = $cos_t; $r01 = $sin_t; |
---|
1139 |
$r10 = -$sin_t; $r11 = $cos_t; |
---|
1140 |
|
---|
1141 |
|
---|
1142 |
|
---|
1143 |
|
---|
1144 |
$b[0] = 0; $b[1] = $total_height; |
---|
1145 |
$b[2] = $total_width; $b[3] = $b[1]; |
---|
1146 |
$b[4] = $b[2]; $b[5] = 0; |
---|
1147 |
$b[6] = $b[0]; $b[7] = $b[5]; |
---|
1148 |
|
---|
1149 |
|
---|
1150 |
for ($i = 0; $i < 8; $i += 2) { |
---|
1151 |
$x_b = $b[$i]; |
---|
1152 |
$y_b = $b[$i+1]; |
---|
1153 |
$c[$i] = $x + $r00 * $x_b + $r01 * $y_b; |
---|
1154 |
$c[$i+1] = $y + $r10 * $x_b + $r11 * $y_b; |
---|
1155 |
|
---|
1156 |
|
---|
1157 |
|
---|
1158 |
|
---|
1159 |
$bbox_ref_x = $bbox_max_x = $c[0]; |
---|
1160 |
$bbox_ref_y = $bbox_max_y = $c[1]; |
---|
1161 |
$i = 2; $i < 8; $i += 2) { |
---|
1162 |
$x_b = $c[$i]; |
---|
1163 |
$x_b < $bbox_ref_x) $bbox_ref_x = $x_b; elseif ($bbox_max_x < $x_b) $bbox_max_x = $x_b; |
---|
1164 |
$y_b = $c[$i+1]; |
---|
1165 |
$y_b < $bbox_ref_y) $bbox_ref_y = $y_b; elseif ($bbox_max_y < $y_b) $bbox_max_y = $y_b; |
---|
1166 |
|
---|
1167 |
$bbox_width = $bbox_max_x - $bbox_ref_x; |
---|
1168 |
$bbox_height = $bbox_max_y - $bbox_ref_y; |
---|
1169 |
|
---|
1170 |
$draw_it) { |
---|
1171 |
|
---|
1172 |
return array((int)ceil($bbox_width), (int)ceil($bbox_height)); |
---|
1173 |
|
---|
1174 |
|
---|
1175 |
|
---|
1176 |
|
---|
1177 |
|
---|
1178 |
|
---|
1179 |
|
---|
1180 |
|
---|
1181 |
|
---|
1182 |
|
---|
1183 |
|
---|
1184 |
|
---|
1185 |
|
---|
1186 |
|
---|
1187 |
$qx = 2 * $x - $bbox_ref_x - $bbox_width * $h_factor; |
---|
1188 |
$qy = 2 * $y - $bbox_ref_y - $bbox_height * $v_factor; |
---|
1189 |
|
---|
1190 |
|
---|
1191 |
if ($this->GetCallback('debug_textbox')) { |
---|
1192 |
|
---|
1193 |
|
---|
1194 |
|
---|
1195 |
|
---|
1196 |
|
---|
1197 |
if ($sin_t > 0) { |
---|
1198 |
$cos_t > 0) { |
---|
1199 |
|
---|
1200 |
$px = $qx; $py = $qy - $total_width * $sin_t; |
---|
1201 |
|
---|
1202 |
|
---|
1203 |
$px = $qx + $total_width * $cos_t; $py = $qy - $bbox_height; |
---|
1204 |
|
---|
1205 |
|
---|
1206 |
$cos_t < 0) { |
---|
1207 |
|
---|
1208 |
$px = $qx - $bbox_width; $py = $qy + $total_height * $cos_t; |
---|
1209 |
|
---|
1210 |
|
---|
1211 |
$px = $qx + $total_height * $sin_t; $py = $qy; |
---|
1212 |
|
---|
1213 |
|
---|
1214 |
$this->DoCallback('debug_textbox', $px, $py, $bbox_width, $bbox_height); |
---|
1215 |
|
---|
1216 |
|
---|
1217 |
|
---|
1218 |
|
---|
1219 |
|
---|
1220 |
|
---|
1221 |
|
---|
1222 |
|
---|
1223 |
|
---|
1224 |
|
---|
1225 |
if ($cos_t >= $sin_t) { |
---|
1226 |
$cos_t >= -$sin_t) $line_align_factor = $h_factor; |
---|
1227 |
$line_align_factor = $v_factor; |
---|
1228 |
|
---|
1229 |
$cos_t >= -$sin_t) $line_align_factor = 1-$v_factor; |
---|
1230 |
$line_align_factor = 1-$h_factor; |
---|
1231 |
|
---|
1232 |
|
---|
1233 |
|
---|
1234 |
|
---|
1235 |
for ($i = 0; $i < $n_lines; $i++) { |
---|
1236 |
$line = $lines[$i]; |
---|
1237 |
|
---|
1238 |
$height = $line_heights[$i]; |
---|
1239 |
$width = $line_widths[$i]; |
---|
1240 |
|
---|
1241 |
|
---|
1242 |
|
---|
1243 |
|
---|
1244 |
|
---|
1245 |
|
---|
1246 |
|
---|
1247 |
|
---|
1248 |
$width_factor = ($total_width - $width) * $line_align_factor; |
---|
1249 |
$rx = $qx + $r00 * $width_factor + $r01 * $height; |
---|
1250 |
$ry = $qy + $r10 * $width_factor + $r11 * $height; |
---|
1251 |
|
---|
1252 |
|
---|
1253 |
ImageTTFText($this->img, $font_size, $angle, $rx, $ry, $color, $font_file, $line); |
---|
1254 |
|
---|
1255 |
|
---|
1256 |
|
---|
1257 |
$interline_step = $this->line_spacing + $height; |
---|
1258 |
$qx += $r01 * $interline_step; |
---|
1259 |
$qy += $r11 * $interline_step; |
---|
1260 |
|
---|
1261 |
True; |
---|
1262 |
|
---|
1263 |
|
---|
1264 |
|
---|
1265 |
|
---|
1266 |
|
---|
1267 |
|
---|
1268 |
|
---|
1269 |
|
---|
1270 |
|
---|
1271 |
|
---|
1272 |
|
---|
1273 |
|
---|
1274 |
|
---|
1275 |
|
---|
1276 |
|
---|
1277 |
|
---|
1278 |
function ProcessText($draw_it, $font, $angle, $x, $y, $color, $text, $halign, $valign) |
---|
1279 |
|
---|
1280 |
|
---|
1281 |
if ($text === '') { |
---|
1282 |
$draw_it) return TRUE; |
---|
1283 |
0, 0); |
---|
1284 |
|
---|
1285 |
|
---|
1286 |
|
---|
1287 |
if ($valign == 'top') $v_factor = 0; |
---|
1288 |
$valign == 'center') $v_factor = 0.5; |
---|
1289 |
$v_factor = 1.0; |
---|
1290 |
if ($halign == 'left') $h_factor = 0; |
---|
1291 |
$halign == 'center') $h_factor = 0.5; |
---|
1292 |
$h_factor = 1.0; |
---|
1293 |
|
---|
1294 |
if ($this->use_ttf) { |
---|
1295 |
$this->ProcessTextTTF($draw_it, $font['font'], $font['size'], |
---|
1296 |
$angle, $x, $y, $color, $text, $h_factor, $v_factor); |
---|
1297 |
|
---|
1298 |
|
---|
1299 |
$this->ProcessTextGD($draw_it, $font['font'], $font['width'], $font['height'], |
---|
1300 |
$angle, $x, $y, $color, $text, $h_factor, $v_factor); |
---|
1301 |
|
---|
1302 |
|
---|
1303 |
|
---|
1304 |
|
---|
1305 |
|
---|
1306 |
|
---|
1307 |
|
---|
1308 |
|
---|
1309 |
|
---|
1310 |
|
---|
1311 |
|
---|
1312 |
|
---|
1313 |
|
---|
1314 |
function DrawText($which_font, $which_angle, $which_xpos, $which_ypos, $which_color, $which_text, |
---|
1315 |
$which_halign = 'left', $which_valign = 'bottom') |
---|
1316 |
|
---|
1317 |
$this->ProcessText(True, |
---|
1318 |
$which_font, $which_angle, $which_xpos, $which_ypos, |
---|
1319 |
$which_color, $which_text, $which_halign, $which_valign); |
---|
1320 |
|
---|
1321 |
|
---|
1322 |
|
---|
1323 |
|
---|
1324 |
|
---|
1325 |
|
---|
1326 |
|
---|
1327 |
|
---|
1328 |
|
---|
1329 |
|
---|
1330 |
|
---|
1331 |
|
---|
1332 |
|
---|
1333 |
function SizeText($which_font, $which_angle, $which_text) |
---|
1334 |
|
---|
1335 |
|
---|
1336 |
return $this->ProcessText(False, |
---|
1337 |
$which_font, $which_angle, 0, 0, 1, $which_text, '', ''); |
---|
1338 |
|
---|
1339 |
|
---|
1340 |
|
---|
1341 |
|
---|
1342 |
|
---|
1343 |
|
---|
1344 |
|
---|
1345 |
|
---|
1346 |
|
---|
1347 |
|
---|
1348 |
function SetFileFormat($format) |
---|
1349 |
|
---|
1350 |
$asked = $this->CheckOption($format, 'jpg, png, gif, wbmp', __FUNCTION__); |
---|
1351 |
$asked) return False; |
---|
1352 |
$asked) { |
---|
1353 |
'jpg': |
---|
1354 |
$format_test = IMG_JPG; |
---|
1355 |
|
---|
1356 |
'png': |
---|
1357 |
$format_test = IMG_PNG; |
---|
1358 |
|
---|
1359 |
'gif': |
---|
1360 |
$format_test = IMG_GIF; |
---|
1361 |
|
---|
1362 |
'wbmp': |
---|
1363 |
$format_test = IMG_WBMP; |
---|
1364 |
|
---|
1365 |
|
---|
1366 |
imagetypes() & $format_test)) { |
---|
1367 |
$this->PrintError("SetFileFormat(): File format '$format' not supported"); |
---|
1368 |
|
---|
1369 |
$this->file_format = $asked; |
---|
1370 |
TRUE; |
---|
1371 |
|
---|
1372 |
|
---|
1373 |
|
---|
1374 |
|
---|
1375 |
|
---|
1376 |
|
---|
1377 |
|
---|
1378 |
|
---|
1379 |
|
---|
1380 |
function SetBgImage($input_file, $mode='centeredtile') |
---|
1381 |
|
---|
1382 |
$this->bgmode = $this->CheckOption($mode, 'tile, centeredtile, scale', __FUNCTION__); |
---|
1383 |
$this->bgimg = $input_file; |
---|
1384 |
$this->bgmode; |
---|
1385 |
|
---|
1386 |
|
---|
1387 |
|
---|
1388 |
|
---|
1389 |
|
---|
1390 |
|
---|
1391 |
|
---|
1392 |
|
---|
1393 |
function SetPlotAreaBgImage($input_file, $mode='tile') |
---|
1394 |
|
---|
1395 |
$this->plotbgmode = $this->CheckOption($mode, 'tile, centeredtile, scale', __FUNCTION__); |
---|
1396 |
$this->plotbgimg = $input_file; |
---|
1397 |
$this->plotbgmode; |
---|
1398 |
|
---|
1399 |
|
---|
1400 |
|
---|
1401 |
|
---|
1402 |
|
---|
1403 |
|
---|
1404 |
function SetOutputFile($which_output_file) |
---|
1405 |
|
---|
1406 |
$this->output_file = $which_output_file; |
---|
1407 |
TRUE; |
---|
1408 |
|
---|
1409 |
|
---|
1410 |
|
---|
1411 |
|
---|
1412 |
|
---|
1413 |
|
---|
1414 |
function SetIsInline($which_ii) |
---|
1415 |
|
---|
1416 |
$this->is_inline = (bool)$which_ii; |
---|
1417 |
TRUE; |
---|
1418 |
|
---|
1419 |
|
---|
1420 |
|
---|
1421 |
|
---|
1422 |
|
---|
1423 |
|
---|
1424 |
function PrintImage() |
---|
1425 |
|
---|
1426 |
|
---|
1427 |
if ( (! $this->browser_cache) && (! $this->is_inline)) { |
---|
1428 |
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
---|
1429 |
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT'); |
---|
1430 |
header('Cache-Control: no-cache, must-revalidate'); |
---|
1431 |
header('Pragma: no-cache'); |
---|
1432 |
|
---|
1433 |
|
---|
1434 |
$this->file_format) { |
---|
1435 |
'png': |
---|
1436 |
$this->is_inline) { |
---|
1437 |
Header('Content-type: image/png'); |
---|
1438 |
|
---|
1439 |
$this->is_inline && $this->output_file != '') { |
---|
1440 |
ImagePng($this->img, $this->output_file); |
---|
1441 |
|
---|
1442 |
ImagePng($this->img); |
---|
1443 |
|
---|
1444 |
|
---|
1445 |
'jpg': |
---|
1446 |
$this->is_inline) { |
---|
1447 |
Header('Content-type: image/jpeg'); |
---|
1448 |
|
---|
1449 |
$this->is_inline && $this->output_file != '') { |
---|
1450 |
ImageJPEG($this->img, $this->output_file); |
---|
1451 |
|
---|
1452 |
ImageJPEG($this->img); |
---|
1453 |
|
---|
1454 |
|
---|
1455 |
'gif': |
---|
1456 |
$this->is_inline) { |
---|
1457 |
Header('Content-type: image/gif'); |
---|
1458 |
|
---|
1459 |
$this->is_inline && $this->output_file != '') { |
---|
1460 |
ImageGIF($this->img, $this->output_file); |
---|
1461 |
|
---|
1462 |
ImageGIF($this->img); |
---|
1463 |
|
---|
1464 |
|
---|
1465 |
|
---|
1466 |
'wbmp': |
---|
1467 |
if (! $this->is_inline) { |
---|
1468 |
Header('Content-type: image/wbmp'); |
---|
1469 |
|
---|
1470 |
$this->is_inline && $this->output_file != '') { |
---|
1471 |
ImageWBMP($this->img, $this->output_file); |
---|
1472 |
|
---|
1473 |
ImageWBMP($this->img); |
---|
1474 |
|
---|
1475 |
|
---|
1476 |
|
---|
1477 |
|
---|
1478 |
$this->PrintError('PrintImage(): Please select an image type!'); |
---|
1479 |
|
---|
1480 |
TRUE; |
---|
1481 |
|
---|
1482 |
|
---|
1483 |
|
---|
1484 |
|
---|
1485 |
|
---|
1486 |
|
---|
1487 |
|
---|
1488 |
|
---|
1489 |
|
---|
1490 |
|
---|
1491 |
|
---|
1492 |
|
---|
1493 |
|
---|
1494 |
|
---|
1495 |
|
---|
1496 |
|
---|
1497 |
|
---|
1498 |
|
---|
1499 |
|
---|
1500 |
|
---|
1501 |
|
---|
1502 |
|
---|
1503 |
|
---|
1504 |
|
---|
1505 |
|
---|
1506 |
function PrintError($error_message) |
---|
1507 |
|
---|
1508 |
|
---|
1509 |
if (isset($this->in_error)) return FALSE; |
---|
1510 |
$this->in_error = TRUE; |
---|
1511 |
|
---|
1512 |
|
---|
1513 |
if (!empty($this->img)) { |
---|
1514 |
$ypos = $this->image_height/2; |
---|
1515 |
$xpos = $this->image_width/2; |
---|
1516 |
$bgcolor = ImageColorResolve($this->img, 255, 255, 255); |
---|
1517 |
$fgcolor = ImageColorResolve($this->img, 0, 0, 0); |
---|
1518 |
ImageFilledRectangle($this->img, 0, 0, $this->image_width, $this->image_height, $bgcolor); |
---|
1519 |
|
---|
1520 |
|
---|
1521 |
$this->SetUseTTF(FALSE); |
---|
1522 |
|
---|
1523 |
$this->DrawText($this->generic_font, 0, $xpos, $ypos, $fgcolor, |
---|
1524 |
wordwrap($error_message), 'center', 'center'); |
---|
1525 |
|
---|
1526 |
$this->PrintImage(); |
---|
1527 |
$this->is_inline) { |
---|
1528 |
Header('HTTP/1.0 500 Internal Server Error'); |
---|
1529 |
|
---|
1530 |
trigger_error($error_message, E_USER_ERROR); |
---|
1531 |
$this->in_error); |
---|
1532 |
FALSE; |
---|
1533 |
} |
---|
1534 |
|
---|
1535 |
|
---|
1536 |
|
---|
1537 |
|
---|
1538 |
|
---|
1539 |
|
---|
1540 |
|
---|
1541 |
function DrawError($error_message, $where_x = NULL, $where_y = NULL) |
---|
1542 |
|
---|
1543 |
$this->PrintError($error_message); |
---|
1544 |
|
---|
1545 |
|
---|
1546 |
|
---|
1547 |
|
---|
1548 |
|
---|
1549 |
|
---|
1550 |
|
---|
1551 |
|
---|
1552 |
|
---|
1553 |
|
---|
1554 |
function SetXDataLabelPos($which_xdlp) |
---|
1555 |
|
---|
1556 |
$which_xdlp = $this->CheckOption($which_xdlp, 'plotdown, plotup, both, xaxis, all, none', |
---|
1557 |
__FUNCTION__); |
---|
1558 |
$which_xdlp) return FALSE; |
---|
1559 |
$this->x_data_label_pos = $which_xdlp; |
---|
1560 |
$this->x_data_label_pos != 'none') |
---|
1561 |
$this->x_tick_label_pos = 'none'; |
---|
1562 |
|
---|
1563 |
TRUE; |
---|
1564 |
|
---|
1565 |
|
---|
1566 |
|
---|
1567 |
|
---|
1568 |
|
---|
1569 |
|
---|
1570 |
|
---|
1571 |
function SetYDataLabelPos($which_ydlp, $which_distance_from_point=0) |
---|
1572 |
|
---|
1573 |
$which_ydlp = $this->CheckOption($which_ydlp, 'plotleft, plotright, both, yaxis, all, plotin, none', |
---|
1574 |
__FUNCTION__); |
---|
1575 |
$which_ydlp) return FALSE; |
---|
1576 |
$this->y_data_label_pos = $which_ydlp; |
---|
1577 |
|
---|
1578 |
|
---|
1579 |
if ( ($which_ydlp == 'plotleft') || ($which_ydlp == 'plotright') || |
---|
1580 |
$which_ydlp == 'both') || ($which_ydlp == 'yaxis') ) { |
---|
1581 |
|
---|
1582 |
|
---|
1583 |
$this->SetYTickLabelPos($which_ydlp); |
---|
1584 |
|
---|
1585 |
$which_ydlp != 'none') { |
---|
1586 |
|
---|
1587 |
$this->y_data_label_pos = 'plotin'; |
---|
1588 |
|
---|
1589 |
|
---|
1590 |
TRUE; |
---|
1591 |
|
---|
1592 |
|
---|
1593 |
|
---|
1594 |
|
---|
1595 |
|
---|
1596 |
|
---|
1597 |
function SetXTickLabelPos($which_xtlp) |
---|
1598 |
|
---|
1599 |
$which_xtlp = $this->CheckOption($which_xtlp, 'plotdown, plotup, both, xaxis, all, none', |
---|
1600 |
__FUNCTION__); |
---|
1601 |
$which_xtlp) return FALSE; |
---|
1602 |
$this->x_tick_label_pos = $which_xtlp; |
---|
1603 |
$which_xtlp != 'none') |
---|
1604 |
$this->x_data_label_pos = 'none'; |
---|
1605 |
|
---|
1606 |
TRUE; |
---|
1607 |
|
---|
1608 |
|
---|
1609 |
|
---|
1610 |
|
---|
1611 |
|
---|
1612 |
function SetYTickLabelPos($which_ytlp) |
---|
1613 |
|
---|
1614 |
$this->y_tick_label_pos = $this->CheckOption($which_ytlp, 'plotleft, plotright, both, yaxis, all, none', |
---|
1615 |
__FUNCTION__); |
---|
1616 |
$this->y_tick_label_pos; |
---|
1617 |
|
---|
1618 |
|
---|
1619 |
|
---|
1620 |
|
---|
1621 |
|
---|
1622 |
|
---|
1623 |
function SetXLabelType($which_xlt) |
---|
1624 |
|
---|
1625 |
$this->x_label_type = $this->CheckOption($which_xlt, 'data, time, title', __FUNCTION__); |
---|
1626 |
$this->x_label_type; |
---|
1627 |
|
---|
1628 |
|
---|
1629 |
|
---|
1630 |
|
---|
1631 |
|
---|
1632 |
function SetYLabelType($which_ylt) |
---|
1633 |
|
---|
1634 |
$this->y_label_type = $this->CheckOption($which_ylt, 'data, time', __FUNCTION__); |
---|
1635 |
$this->y_label_type; |
---|
1636 |
|
---|
1637 |
|
---|
1638 |
SetXTimeFormat($which_xtf) |
---|
1639 |
|
---|
1640 |
$this->x_time_format = $which_xtf; |
---|
1641 |
TRUE; |
---|
1642 |
|
---|
1643 |
|
---|
1644 |
SetYTimeFormat($which_ytf) |
---|
1645 |
|
---|
1646 |
$this->y_time_format = $which_ytf; |
---|
1647 |
TRUE; |
---|
1648 |
|
---|
1649 |
|
---|
1650 |
SetNumberFormat($decimal_point, $thousands_sep) |
---|
1651 |
|
---|
1652 |
$this->decimal_point = $decimal_point; |
---|
1653 |
$this->thousands_sep = $thousands_sep; |
---|
1654 |
TRUE; |
---|
1655 |
|
---|
1656 |
|
---|
1657 |
|
---|
1658 |
SetXLabelAngle($which_xla) |
---|
1659 |
|
---|
1660 |
$this->x_label_angle = $which_xla; |
---|
1661 |
TRUE; |
---|
1662 |
|
---|
1663 |
|
---|
1664 |
SetYLabelAngle($which_yla) |
---|
1665 |
|
---|
1666 |
$this->y_label_angle = $which_yla; |
---|
1667 |
TRUE; |
---|
1668 |
|
---|
1669 |
|
---|
1670 |
|
---|
1671 |
|
---|
1672 |
|
---|
1673 |
|
---|
1674 |
|
---|
1675 |
|
---|
1676 |
|
---|
1677 |
|
---|
1678 |
|
---|
1679 |
|
---|
1680 |
|
---|
1681 |
|
---|
1682 |
|
---|
1683 |
function CheckOption($which_opt, $which_acc, $which_func) |
---|
1684 |
|
---|
1685 |
$asked = strtolower(trim($which_opt)); |
---|
1686 |
|
---|
1687 |
|
---|
1688 |
if (strpos(", $which_acc,", ", $asked,") !== False) |
---|
1689 |
$asked; |
---|
1690 |
|
---|
1691 |
$this->PrintError("$which_func(): '$which_opt' not in available choices: '$which_acc'."); |
---|
1692 |
NULL; |
---|
1693 |
|
---|
1694 |
|
---|
1695 |
|
---|
1696 |
|
---|
1697 |
|
---|
1698 |
|
---|
1699 |
function SetBrowserCache($which_browser_cache) |
---|
1700 |
|
---|
1701 |
$this->browser_cache = $which_browser_cache; |
---|
1702 |
TRUE; |
---|
1703 |
|
---|
1704 |
|
---|
1705 |
|
---|
1706 |
|
---|
1707 |
|
---|
1708 |
function SetPrintImage($which_pi) |
---|
1709 |
|
---|
1710 |
$this->print_image = $which_pi; |
---|
1711 |
TRUE; |
---|
1712 |
|
---|
1713 |
|
---|
1714 |
|
---|
1715 |
|
---|
1716 |
|
---|
1717 |
function SetLegend($which_leg) |
---|
1718 |
|
---|
1719 |
is_array($which_leg)) { |
---|
1720 |
$this->legend = $which_leg; |
---|
1721 |
is_null($which_leg)) { |
---|
1722 |
$this->legend[] = $which_leg; |
---|
1723 |
|
---|
1724 |
$this->PrintError("SetLegend(): argument must not be null."); |
---|
1725 |
|
---|
1726 |
TRUE; |
---|
1727 |
|
---|
1728 |
|
---|
1729 |
|
---|
1730 |
|
---|
1731 |
|
---|
1732 |
|
---|
1733 |
function SetLegendPixels($which_x, $which_y) |
---|
1734 |
|
---|
1735 |
$this->legend_x_pos = $which_x; |
---|
1736 |
$this->legend_y_pos = $which_y; |
---|
1737 |
|
---|
1738 |
unset($this->legend_xy_world); |
---|
1739 |
|
---|
1740 |
TRUE; |
---|
1741 |
|
---|
1742 |
|
---|
1743 |
|
---|
1744 |
|
---|
1745 |
|
---|
1746 |
|
---|
1747 |
|
---|
1748 |
|
---|
1749 |
|
---|
1750 |
function SetLegendWorld($which_x, $which_y) |
---|
1751 |
|
---|
1752 |
$this->legend_x_pos = $which_x; |
---|
1753 |
$this->legend_y_pos = $which_y; |
---|
1754 |
$this->legend_xy_world = True; |
---|
1755 |
|
---|
1756 |
TRUE; |
---|
1757 |
|
---|
1758 |
|
---|
1759 |
|
---|
1760 |
|
---|
1761 |
|
---|
1762 |
|
---|
1763 |
|
---|
1764 |
|
---|
1765 |
|
---|
1766 |
function SetLegendStyle($text_align, $colorbox_align = '', $style = '') |
---|
1767 |
|
---|
1768 |
$this->legend_text_align = $this->CheckOption($text_align, 'left, right', __FUNCTION__); |
---|
1769 |
$colorbox_align)) |
---|
1770 |
$this->legend_colorbox_align = $this->legend_text_align; |
---|
1771 |
|
---|
1772 |
$this->legend_colorbox_align = $this->CheckOption($colorbox_align, 'left, right, none', __FUNCTION__); |
---|
1773 |
$this->legend_text_align && (boolean)$this->legend_colorbox_align); |
---|
1774 |
|
---|
1775 |
|
---|
1776 |
|
---|
1777 |
|
---|
1778 |
|
---|
1779 |
function SetPlotBorderType($pbt) |
---|
1780 |
|
---|
1781 |
$this->plot_border_type = $this->CheckOption($pbt, 'left, sides, none, full', __FUNCTION__); |
---|
1782 |
$this->plot_border_type; |
---|
1783 |
|
---|
1784 |
|
---|
1785 |
|
---|
1786 |
|
---|
1787 |
|
---|
1788 |
function SetImageBorderType($sibt) |
---|
1789 |
|
---|
1790 |
$this->image_border_type = $this->CheckOption($sibt, 'raised, plain', __FUNCTION__); |
---|
1791 |
$this->image_border_type; |
---|
1792 |
|
---|
1793 |
|
---|
1794 |
|
---|
1795 |
|
---|
1796 |
|
---|
1797 |
|
---|
1798 |
function SetDrawPlotAreaBackground($dpab) |
---|
1799 |
|
---|
1800 |
$this->draw_plot_area_background = (bool)$dpab; |
---|
1801 |
TRUE; |
---|
1802 |
|
---|
1803 |
|
---|
1804 |
|
---|
1805 |
|
---|
1806 |
|
---|
1807 |
|
---|
1808 |
function SetDrawYGrid($dyg) |
---|
1809 |
|
---|
1810 |
$this->draw_y_grid = (bool)$dyg; |
---|
1811 |
TRUE; |
---|
1812 |
|
---|
1813 |
|
---|
1814 |
|
---|
1815 |
|
---|
1816 |
|
---|
1817 |
|
---|
1818 |
function SetDrawXGrid($dxg) |
---|
1819 |
|
---|
1820 |
$this->draw_x_grid = (bool)$dxg; |
---|
1821 |
TRUE; |
---|
1822 |
|
---|
1823 |
|
---|
1824 |
|
---|
1825 |
|
---|
1826 |
|
---|
1827 |
|
---|
1828 |
function SetDrawDashedGrid($ddg) |
---|
1829 |
|
---|
1830 |
$this->dashed_grid = (bool)$ddg; |
---|
1831 |
TRUE; |
---|
1832 |
|
---|
1833 |
|
---|
1834 |
|
---|
1835 |
|
---|
1836 |
|
---|
1837 |
|
---|
1838 |
function SetDrawXDataLabelLines($dxdl) |
---|
1839 |
|
---|
1840 |
$this->draw_x_data_label_lines = (bool)$dxdl; |
---|
1841 |
TRUE; |
---|
1842 |
|
---|
1843 |
|
---|
1844 |
|
---|
1845 |
|
---|
1846 |
|
---|
1847 |
|
---|
1848 |
|
---|
1849 |
function SetDrawYDataLabelLines($dydl) |
---|
1850 |
|
---|
1851 |
$this->draw_y_data_label_lines = $dydl; |
---|
1852 |
TRUE; |
---|
1853 |
|
---|
1854 |
|
---|
1855 |
|
---|
1856 |
|
---|
1857 |
|
---|
1858 |
|
---|
1859 |
function SetTitle($which_title) |
---|
1860 |
|
---|
1861 |
$this->title_txt = $which_title; |
---|
1862 |
TRUE; |
---|
1863 |
|
---|
1864 |
|
---|
1865 |
|
---|
1866 |
|
---|
1867 |
|
---|
1868 |
function SetXTitle($which_xtitle, $which_xpos = 'plotdown') |
---|
1869 |
|
---|
1870 |
$which_xtitle == '') |
---|
1871 |
$which_xpos = 'none'; |
---|
1872 |
|
---|
1873 |
$this->x_title_pos = $this->CheckOption($which_xpos, 'plotdown, plotup, both, none', __FUNCTION__); |
---|
1874 |
$this->x_title_pos) return FALSE; |
---|
1875 |
$this->x_title_txt = $which_xtitle; |
---|
1876 |
TRUE; |
---|
1877 |
|
---|
1878 |
|
---|
1879 |
|
---|
1880 |
|
---|
1881 |
|
---|
1882 |
|
---|
1883 |
function SetYTitle($which_ytitle, $which_ypos = 'plotleft') |
---|
1884 |
|
---|
1885 |
$which_ytitle == '') |
---|
1886 |
$which_ypos = 'none'; |
---|
1887 |
|
---|
1888 |
$this->y_title_pos = $this->CheckOption($which_ypos, 'plotleft, plotright, both, none', __FUNCTION__); |
---|
1889 |
$this->y_title_pos) return FALSE; |
---|
1890 |
$this->y_title_txt = $which_ytitle; |
---|
1891 |
TRUE; |
---|
1892 |
|
---|
1893 |
|
---|
1894 |
|
---|
1895 |
|
---|
1896 |
|
---|
1897 |
|
---|
1898 |
function SetShading($which_s) |
---|
1899 |
|
---|
1900 |
$this->shading = (int)$which_s; |
---|
1901 |
TRUE; |
---|
1902 |
|
---|
1903 |
|
---|
1904 |
SetPlotType($which_pt) |
---|
1905 |
|
---|
1906 |
$this->plot_type = $this->CheckOption($which_pt, |
---|
1907 |
'bars, stackedbars, lines, linepoints, area, points, pie, thinbarline, squared', |
---|
1908 |
__FUNCTION__); |
---|
1909 |
$this->plot_type; |
---|
1910 |
|
---|
1911 |
|
---|
1912 |
|
---|
1913 |
|
---|
1914 |
|
---|
1915 |
|
---|
1916 |
function SetYAxisPosition($pos) |
---|
1917 |
|
---|
1918 |
$this->y_axis_position = (int)$pos; |
---|
1919 |
TRUE; |
---|
1920 |
|
---|
1921 |
|
---|
1922 |
|
---|
1923 |
|
---|
1924 |
|
---|
1925 |
|
---|
1926 |
function SetXAxisPosition($pos) |
---|
1927 |
|
---|
1928 |
$this->x_axis_position = (int)$pos; |
---|
1929 |
TRUE; |
---|
1930 |
|
---|
1931 |
|
---|
1932 |
|
---|
1933 |
SetXScaleType($which_xst) |
---|
1934 |
|
---|
1935 |
$this->xscale_type = $this->CheckOption($which_xst, 'linear, log', __FUNCTION__); |
---|
1936 |
$this->xscale_type; |
---|
1937 |
|
---|
1938 |
|
---|
1939 |
SetYScaleType($which_yst) |
---|
1940 |
|
---|
1941 |
$this->yscale_type = $this->CheckOption($which_yst, 'linear, log', __FUNCTION__); |
---|
1942 |
$this->yscale_type; |
---|
1943 |
|
---|
1944 |
|
---|
1945 |
SetPrecisionX($which_prec) |
---|
1946 |
|
---|
1947 |
$this->x_precision = $which_prec; |
---|
1948 |
$this->SetXLabelType('data'); |
---|
1949 |
TRUE; |
---|
1950 |
|
---|
1951 |
|
---|
1952 |
SetPrecisionY($which_prec) |
---|
1953 |
|
---|
1954 |
$this->y_precision = $which_prec; |
---|
1955 |
$this->SetYLabelType('data'); |
---|
1956 |
TRUE; |
---|
1957 |
|
---|
1958 |
|
---|
1959 |
SetErrorBarLineWidth($which_seblw) |
---|
1960 |
|
---|
1961 |
$this->error_bar_line_width = $which_seblw; |
---|
1962 |
TRUE; |
---|
1963 |
|
---|
1964 |
|
---|
1965 |
SetLabelScalePosition($which_blp) |
---|
1966 |
|
---|
1967 |
|
---|
1968 |
$this->label_scale_position = $which_blp; |
---|
1969 |
TRUE; |
---|
1970 |
|
---|
1971 |
|
---|
1972 |
SetErrorBarSize($which_ebs) |
---|
1973 |
|
---|
1974 |
|
---|
1975 |
$this->error_bar_size = $which_ebs; |
---|
1976 |
TRUE; |
---|
1977 |
|
---|
1978 |
|
---|
1979 |
|
---|
1980 |
|
---|
1981 |
|
---|
1982 |
function SetErrorBarShape($which_ebs) |
---|
1983 |
|
---|
1984 |
$this->error_bar_shape = $this->CheckOption($which_ebs, 'tee, line', __FUNCTION__); |
---|
1985 |
$this->error_bar_shape; |
---|
1986 |
|
---|
1987 |
|
---|
1988 |
|
---|
1989 |
|
---|
1990 |
|
---|
1991 |
|
---|
1992 |
|
---|
1993 |
function SetPointShapes($which_pt) |
---|
1994 |
|
---|
1995 |
is_null($which_pt)) { |
---|
1996 |
|
---|
1997 |
} else if (is_array($which_pt)) { |
---|
1998 |
|
---|
1999 |
$this->point_shapes = $which_pt; |
---|
2000 |
|
---|
2001 |
|
---|
2002 |
$this->point_shapes = array($which_pt); |
---|
2003 |
|
---|
2004 |
|
---|
2005 |
$this->point_shapes as $shape) |
---|
2006 |
|
---|
2007 |
$this->CheckOption($shape, |
---|
2008 |
'halfline, line, plus, cross, rect, circle, dot, diamond, triangle, trianglemid, none', |
---|
2009 |
__FUNCTION__)) |
---|
2010 |
FALSE; |
---|
2011 |
|
---|
2012 |
|
---|
2013 |
|
---|
2014 |
$ps = count($this->point_sizes); |
---|
2015 |
$pt = count($this->point_shapes); |
---|
2016 |
|
---|
2017 |
$ps < $pt) { |
---|
2018 |
$this->pad_array($this->point_sizes, $pt); |
---|
2019 |
$pt > $ps) { |
---|
2020 |
$this->pad_array($this->point_shapes, $ps); |
---|
2021 |
|
---|
2022 |
TRUE; |
---|
2023 |
|
---|
2024 |
|
---|
2025 |
|
---|
2026 |
|
---|
2027 |
|
---|
2028 |
|
---|
2029 |
|
---|
2030 |
function SetPointSizes($which_ps) |
---|
2031 |
|
---|
2032 |
is_null($which_ps)) { |
---|
2033 |
|
---|
2034 |
} else if (is_array($which_ps)) { |
---|
2035 |
|
---|
2036 |
$this->point_sizes = $which_ps; |
---|
2037 |
|
---|
2038 |
|
---|
2039 |
$this->point_sizes = array($which_ps); |
---|
2040 |
|
---|
2041 |
|
---|
2042 |
|
---|
2043 |
$ps = count($this->point_sizes); |
---|
2044 |
$pt = count($this->point_shapes); |
---|
2045 |
|
---|
2046 |
$ps < $pt) { |
---|
2047 |
$this->pad_array($this->point_sizes, $pt); |
---|
2048 |
$pt > $ps) { |
---|
2049 |
$this->pad_array($this->point_shapes, $ps); |
---|
2050 |
|
---|
2051 |
|
---|
2052 |
|
---|
2053 |
for ($i = 0; $i < $pt; $i++) { |
---|
2054 |
$this->point_shapes[$i] == 'diamond' or $this->point_shapes[$i] == 'triangle') { |
---|
2055 |
$this->point_sizes[$i] % 2 != 0) { |
---|
2056 |
$this->point_sizes[$i]++; |
---|
2057 |
|
---|
2058 |
|
---|
2059 |
|
---|
2060 |
TRUE; |
---|
2061 |
|
---|
2062 |
|
---|
2063 |
|
---|
2064 |
|
---|
2065 |
|
---|
2066 |
|
---|
2067 |
|
---|
2068 |
function SetDrawBrokenLines($bl) |
---|
2069 |
|
---|
2070 |
$this->draw_broken_lines = (bool)$bl; |
---|
2071 |
TRUE; |
---|
2072 |
|
---|
2073 |
|
---|
2074 |
|
---|
2075 |
|
---|
2076 |
|
---|
2077 |
|
---|
2078 |
|
---|
2079 |
|
---|
2080 |
|
---|
2081 |
function SetDataType($which_dt) |
---|
2082 |
|
---|
2083 |
|
---|
2084 |
if ($which_dt == 'text-linear') { $which_dt = 'text-data'; } |
---|
2085 |
$which_dt == 'linear-linear') { $which_dt = 'data-data'; } |
---|
2086 |
$which_dt == 'linear-linear-error') { $which_dt = 'data-data-error'; } |
---|
2087 |
$which_dt == 'text-data-pie') { $which_dt = 'text-data-single'; } |
---|
2088 |
|
---|
2089 |
|
---|
2090 |
$this->data_type = $this->CheckOption($which_dt, 'text-data, text-data-single, '. |
---|
2091 |
'data-data, data-data-error', __FUNCTION__); |
---|
2092 |
$this->data_type; |
---|
2093 |
|
---|
2094 |
|
---|
2095 |
|
---|
2096 |
|
---|
2097 |
|
---|
2098 |
|
---|
2099 |
|
---|
2100 |
function SetDataValues(&$which_dv) |
---|
2101 |
|
---|
2102 |
$this->num_data_rows = count($which_dv); |
---|
2103 |
$this->total_records = 0; |
---|
2104 |
$this->records_per_group = 1; |
---|
2105 |
$i = 0, $recs = 0; $i < $this->num_data_rows; $i++) { |
---|
2106 |
|
---|
2107 |
$this->data[$i] = array_values($which_dv[$i]); |
---|
2108 |
|
---|
2109 |
|
---|
2110 |
$recs = count($this->data[$i]); |
---|
2111 |
$this->total_records += $recs; |
---|
2112 |
|
---|
2113 |
$recs > $this->records_per_group) |
---|
2114 |
$this->records_per_group = $recs; |
---|
2115 |
|
---|
2116 |
$this->num_recs[$i] = $recs; |
---|
2117 |
|
---|
2118 |
TRUE; |
---|
2119 |
|
---|
2120 |
|
---|
2121 |
|
---|
2122 |
|
---|
2123 |
|
---|
2124 |
|
---|
2125 |
|
---|
2126 |
function PadArrays() |
---|
2127 |
|
---|
2128 |
$this->pad_array($this->line_widths, $this->records_per_group); |
---|
2129 |
$this->pad_array($this->line_styles, $this->records_per_group); |
---|
2130 |
|
---|
2131 |
$this->pad_array($this->data_colors, $this->records_per_group); |
---|
2132 |
$this->pad_array($this->data_border_colors, $this->records_per_group); |
---|
2133 |
$this->pad_array($this->error_bar_colors, $this->records_per_group); |
---|
2134 |
|
---|
2135 |
$this->SetDataColors(); |
---|
2136 |
$this->SetDataBorderColors(); |
---|
2137 |
$this->SetErrorBarColors(); |
---|
2138 |
|
---|
2139 |
TRUE; |
---|
2140 |
|
---|
2141 |
|
---|
2142 |
|
---|
2143 |
|
---|
2144 |
|
---|
2145 |
|
---|
2146 |
|
---|
2147 |
|
---|
2148 |
|
---|
2149 |
|
---|
2150 |
function pad_array(&$arr, $size) |
---|
2151 |
|
---|
2152 |
is_array($arr)) { |
---|
2153 |
$arr = array($arr); |
---|
2154 |
|
---|
2155 |
$n = count($arr); |
---|
2156 |
$base = 0; |
---|
2157 |
$n < $size) $arr[$n++] = $arr[$base++]; |
---|
2158 |
|
---|
2159 |
|
---|
2160 |
|
---|
2161 |
|
---|
2162 |
|
---|
2163 |
|
---|
2164 |
|
---|
2165 |
function number_format($number, $decimals=0) |
---|
2166 |
|
---|
2167 |
$this->decimal_point) || !isset($this->thousands_sep)) { |
---|
2168 |
|
---|
2169 |
@setlocale(LC_ALL, ''); |
---|
2170 |
|
---|
2171 |
$locale = @localeconv(); |
---|
2172 |
$locale) && isset($locale['decimal_point']) && |
---|
2173 |
$locale['thousands_sep'])) { |
---|
2174 |
$this->decimal_point = $locale['decimal_point']; |
---|
2175 |
$this->thousands_sep = $locale['thousands_sep']; |
---|
2176 |
|
---|
2177 |
|
---|
2178 |
$this->decimal_point = '.'; |
---|
2179 |
$this->thousands_sep = ','; |
---|
2180 |
|
---|
2181 |
|
---|
2182 |
number_format($number, $decimals, $this->decimal_point, $this->thousands_sep); |
---|
2183 |
|
---|
2184 |
|
---|
2185 |
|
---|
2186 |
|
---|
2187 |
|
---|
2188 |
|
---|
2189 |
|
---|
2190 |
|
---|
2191 |
|
---|
2192 |
|
---|
2193 |
|
---|
2194 |
function SetCallback($reason, $function, $arg = NULL) |
---|
2195 |
|
---|
2196 |
|
---|
2197 |
if (!array_key_exists($reason, $this->callbacks)) |
---|
2198 |
False; |
---|
2199 |
$this->callbacks[$reason] = array($function, $arg); |
---|
2200 |
True; |
---|
2201 |
|
---|
2202 |
|
---|
2203 |
|
---|
2204 |
|
---|
2205 |
|
---|
2206 |
|
---|
2207 |
|
---|
2208 |
|
---|
2209 |
|
---|
2210 |
|
---|
2211 |
function GetCallback($reason) |
---|
2212 |
|
---|
2213 |
$this->callbacks[$reason])) |
---|
2214 |
$this->callbacks[$reason][0]; |
---|
2215 |
False; |
---|
2216 |
|
---|
2217 |
|
---|
2218 |
|
---|
2219 |
|
---|
2220 |
|
---|
2221 |
|
---|
2222 |
|
---|
2223 |
|
---|
2224 |
function RemoveCallback($reason) |
---|
2225 |
|
---|
2226 |
array_key_exists($reason, $this->callbacks)) |
---|
2227 |
False; |
---|
2228 |
$this->callbacks[$reason] = NULL; |
---|
2229 |
True; |
---|
2230 |
|
---|
2231 |
|
---|
2232 |
|
---|
2233 |
|
---|
2234 |
|
---|
2235 |
|
---|
2236 |
|
---|
2237 |
|
---|
2238 |
|
---|
2239 |
|
---|
2240 |
|
---|
2241 |
function DoCallback() |
---|
2242 |
{ |
---|
2243 |
$args = func_get_args(); |
---|
2244 |
$reason = $args[0]; |
---|
2245 |
$this->callbacks[$reason])) |
---|
2246 |
|
---|
2247 |
$function, $args[0]) = $this->callbacks[$reason]; |
---|
2248 |
array_unshift($args, $this->img); |
---|
2249 |
|
---|
2250 |
call_user_func_array($function, $args); |
---|
2251 |
|
---|
2252 |
|
---|
2253 |
|
---|
2254 |
|
---|
2255 |
|
---|
2256 |
|
---|
2257 |
|
---|
2258 |
|
---|
2259 |
|
---|
2260 |
|
---|
2261 |
|
---|
2262 |
|
---|
2263 |
|
---|
2264 |
|
---|
2265 |
|
---|
2266 |
function FindDataLimits() |
---|
2267 |
|
---|
2268 |
|
---|
2269 |
switch ($this->data_type) { |
---|
2270 |
'text-data': |
---|
2271 |
'text-data-single': |
---|
2272 |
$minx = 0; |
---|
2273 |
$maxx = $this->num_data_rows - 1 ; |
---|
2274 |
$miny = $this->data[0][1]; |
---|
2275 |
$maxy = $miny; |
---|
2276 |
|
---|
2277 |
|
---|
2278 |
$minx = $this->data[0][1]; |
---|
2279 |
$maxx = $minx; |
---|
2280 |
$miny = $this->data[0][2]; |
---|
2281 |
$maxy = $miny; |
---|
2282 |
|
---|
2283 |
|
---|
2284 |
|
---|
2285 |
$mine = 0; |
---|
2286 |
$maxe = 0; |
---|
2287 |
|
---|
2288 |
if ($this->plot_type == 'stackedbars') { |
---|
2289 |
$maxmaxy = $minminy = 0; |
---|
2290 |
|
---|
2291 |
$minminy = $miny; |
---|
2292 |
$maxmaxy = $maxy; |
---|
2293 |
|
---|
2294 |
|
---|
2295 |
|
---|
2296 |
for ($i=0; $i < $this->num_data_rows; $i++) { |
---|
2297 |
$j = 1; |
---|
2298 |
|
---|
2299 |
switch ($this->data_type) { |
---|
2300 |
'text-data': |
---|
2301 |
case 'text-data-single': |
---|
2302 |
|
---|
2303 |
$maxy = (double)$this->data[$i][$j++]; |
---|
2304 |
$this->plot_type == 'stackedbars') { |
---|
2305 |
$miny = 0; |
---|
2306 |
|
---|
2307 |
$miny = $maxy; |
---|
2308 |
|
---|
2309 |
$j < $this->num_recs[$i]; $j++) { |
---|
2310 |
$val = (double)$this->data[$i][$j]; |
---|
2311 |
$this->plot_type == 'stackedbars') { |
---|
2312 |
$maxy += abs($val); |
---|
2313 |
} else { |
---|
2314 |
$val > $maxy) $maxy = $val; |
---|
2315 |
$val < $miny) $miny = $val; |
---|
2316 |
|
---|
2317 |
|
---|
2318 |
|
---|
2319 |
'data-data': |
---|
2320 |
|
---|
2321 |
$val = (double)$this->data[$i][$j++]; |
---|
2322 |
$val > $maxx) $maxx = $val; |
---|
2323 |
$val < $minx) $minx = $val; |
---|
2324 |
|
---|
2325 |
$miny = $maxy = (double)$this->data[$i][$j++]; |
---|
2326 |
|
---|
2327 |
for (; $j < $this->num_recs[$i]; $j++) { |
---|
2328 |
$val = (double)$this->data[$i][$j]; |
---|
2329 |
$val > $maxy) $maxy = $val; |
---|
2330 |
$val < $miny) $miny = $val; |
---|
2331 |
|
---|
2332 |
|
---|
2333 |
'data-data-error': |
---|
2334 |
|
---|
2335 |
$val = (double)$this->data[$i][$j++]; |
---|
2336 |
$val > $maxx) $maxx = $val; |
---|
2337 |
$val < $minx) $minx = $val; |
---|
2338 |
|
---|
2339 |
$miny = $maxy = (double)$this->data[$i][$j]; |
---|
2340 |
|
---|
2341 |
for (; $j < $this->num_recs[$i];) { |
---|
2342 |
|
---|
2343 |
$val = (double)$this->data[$i][$j++]; |
---|
2344 |
$val > $maxy) $maxy = $val; |
---|
2345 |
$val < $miny) $miny = $val; |
---|
2346 |
|
---|
2347 |
$val = (double)$this->data[$i][$j++]; |
---|
2348 |
$val > $maxe) $maxe = $val; |
---|
2349 |
|
---|
2350 |
$val = (double)$this->data[$i][$j++]; |
---|
2351 |
$val > $mine) $mine = $val; |
---|
2352 |
|
---|
2353 |
$maxy = $maxy + $maxe; |
---|
2354 |
$miny = $miny - $mine; |
---|
2355 |
break; |
---|
2356 |
|
---|
2357 |
$this->PrintError("FindDataLimits(): Unknown data type '$this->data_type'."); |
---|
2358 |
|
---|
2359 |
|
---|
2360 |
$this->data_miny[$i] = $miny; |
---|
2361 |
$this->data_maxy[$i] = $maxy; |
---|
2362 |
|
---|
2363 |
$miny < $minminy) $minminy = $miny; |
---|
2364 |
if ($maxy > $maxmaxy) $maxmaxy = $maxy; |
---|
2365 |
} |
---|
2366 |
|
---|
2367 |
$this->min_x = $minx; |
---|
2368 |
$this->max_x = $maxx; |
---|
2369 |
$this->min_y = $minminy; |
---|
2370 |
$this->max_y = $maxmaxy; |
---|
2371 |
|
---|
2372 |
$this->GetCallback('debug_scale')) { |
---|
2373 |
$this->DoCallback('debug_scale', __FUNCTION__, array( |
---|
2374 |
'min_x' => $this->min_x, 'min_y' => $this->min_y, |
---|
2375 |
'max_x' => $this->max_x, 'max_y' => $this->max_y)); |
---|
2376 |
|
---|
2377 |
TRUE; |
---|
2378 |
|
---|
2379 |
|
---|
2380 |
|
---|
2381 |
|
---|
2382 |
|
---|
2383 |
|
---|
2384 |
|
---|
2385 |
|
---|
2386 |
|
---|
2387 |
|
---|
2388 |
|
---|
2389 |
|
---|
2390 |
|
---|
2391 |
|
---|
2392 |
|
---|
2393 |
|
---|
2394 |
|
---|
2395 |
|
---|
2396 |
|
---|
2397 |
|
---|
2398 |
|
---|
2399 |
|
---|
2400 |
|
---|
2401 |
|
---|
2402 |
|
---|
2403 |
|
---|
2404 |
|
---|
2405 |
|
---|
2406 |
|
---|
2407 |
|
---|
2408 |
|
---|
2409 |
|
---|
2410 |
|
---|
2411 |
|
---|
2412 |
|
---|
2413 |
|
---|
2414 |
|
---|
2415 |
|
---|
2416 |
|
---|
2417 |
|
---|
2418 |
|
---|
2419 |
function CalcMargins($maximize) |
---|
2420 |
|
---|
2421 |
|
---|
2422 |
$gap = $this->safe_margin; |
---|
2423 |
|
---|
2424 |
|
---|
2425 |
|
---|
2426 |
|
---|
2427 |
$min_margin = 3 * $gap; |
---|
2428 |
|
---|
2429 |
|
---|
2430 |
list($unused, $title_height) = $this->SizeText($this->title_font, 0, $this->title_txt); |
---|
2431 |
$unused, $x_title_height) = $this->SizeText($this->x_title_font, 0, $this->x_title_txt); |
---|
2432 |
$y_title_width, $unused) = $this->SizeText($this->y_title_font, 90, $this->y_title_txt); |
---|
2433 |
|
---|
2434 |
|
---|
2435 |
if ($maximize) { |
---|
2436 |
$this->plot_margins_set) { |
---|
2437 |
$this->x_left_margin = $gap; |
---|
2438 |
$this->x_right_margin = $gap; |
---|
2439 |
$this->y_top_margin = $gap; |
---|
2440 |
$this->y_bot_margin = $gap; |
---|
2441 |
$title_height > 0) |
---|
2442 |
$this->y_top_margin += $title_height + $gap; |
---|
2443 |
|
---|
2444 |
TRUE; |
---|
2445 |
|
---|
2446 |
|
---|
2447 |
|
---|
2448 |
$x_tick_label_pos = $this->x_tick_label_pos; |
---|
2449 |
$x_data_label_pos = $this->x_data_label_pos; |
---|
2450 |
$x_tick_pos = $this->x_tick_pos; |
---|
2451 |
$x_tick_len = $this->x_tick_length; |
---|
2452 |
$y_tick_label_pos = $this->y_tick_label_pos; |
---|
2453 |
$y_tick_pos = $this->y_tick_pos; |
---|
2454 |
$y_tick_len = $this->y_tick_length; |
---|
2455 |
|
---|
2456 |
|
---|
2457 |
|
---|
2458 |
|
---|
2459 |
|
---|
2460 |
if ($x_data_label_pos == 'none') { |
---|
2461 |
$x_label_height = 0; |
---|
2462 |
|
---|
2463 |
$x_label_height = $this->CalcMaxDataLabelSize(); |
---|
2464 |
|
---|
2465 |
$x_tick_label_pos != 'none' && |
---|
2466 |
$height = $this->CalcMaxTickLabelSize('x')) > $x_label_height) { |
---|
2467 |
$x_label_height = $height; |
---|
2468 |
|
---|
2469 |
|
---|
2470 |
|
---|
2471 |
if ($y_tick_label_pos == 'none') |
---|
2472 |
$y_label_width = 0; |
---|
2473 |
|
---|
2474 |
$y_label_width = $this->CalcMaxTickLabelSize('y'); |
---|
2475 |
|
---|
2476 |
|
---|
2477 |
|
---|
2478 |
|
---|
2479 |
|
---|
2480 |
if ($this->x_axis_position <= $this->plot_min_y) |
---|
2481 |
$x_axis_pos = 'bottom'; |
---|
2482 |
$this->x_axis_position >= $this->plot_max_y) |
---|
2483 |
$x_axis_pos = 'top'; |
---|
2484 |
|
---|
2485 |
$x_axis_pos = 'none'; |
---|
2486 |
|
---|
2487 |
$this->y_axis_position <= $this->plot_min_x) |
---|
2488 |
$y_axis_pos = 'left'; |
---|
2489 |
$this->y_axis_position >= $this->plot_max_x) |
---|
2490 |
$y_axis_pos = 'right'; |
---|
2491 |
|
---|
2492 |
$y_axis_pos = 'none'; |
---|
2493 |
|
---|
2494 |
|
---|
2495 |
|
---|
2496 |
$top_margin = $gap; |
---|
2497 |
$bot_margin = $gap; |
---|
2498 |
$this->x_title_top_offset = $gap; |
---|
2499 |
$this->x_title_bot_offset = $gap; |
---|
2500 |
|
---|
2501 |
$title_height > 0) |
---|
2502 |
$top_margin += $title_height + $gap; |
---|
2503 |
|
---|
2504 |
$x_title_height > 0) { |
---|
2505 |
$pos = $this->x_title_pos; |
---|
2506 |
$pos == 'plotup' || $pos == 'both') |
---|
2507 |
$top_margin += $x_title_height + $gap; |
---|
2508 |
$pos == 'plotdown' || $pos == 'both') |
---|
2509 |
$bot_margin += $x_title_height + $gap; |
---|
2510 |
|
---|
2511 |
|
---|
2512 |
$x_tick_label_pos == 'plotup' || $x_tick_label_pos == 'both' |
---|
2513 |
|| $x_data_label_pos == 'plotup' || $x_data_label_pos == 'both' |
---|
2514 |
|| ($x_tick_label_pos == 'xaxis' && $x_axis_pos == 'top')) { |
---|
2515 |
|
---|
2516 |
$top_margin += $x_label_height + $gap; |
---|
2517 |
$this->x_title_top_offset += $x_label_height + $gap; |
---|
2518 |
|
---|
2519 |
$x_tick_label_pos == 'plotdown' || $x_tick_label_pos == 'both' |
---|
2520 |
|| $x_data_label_pos == 'plotdown' || $x_data_label_pos == 'both' |
---|
2521 |
|| ($x_tick_label_pos == 'xaxis' && $x_axis_pos == 'bottom')) { |
---|
2522 |
|
---|
2523 |
$bot_margin += $x_label_height + $gap; |
---|
2524 |
$this->x_title_bot_offset += $x_label_height + $gap; |
---|
2525 |
|
---|
2526 |
$x_tick_pos == 'plotup' || $x_tick_pos == 'both' |
---|
2527 |
|| ($x_tick_pos == 'xaxis' && $x_axis_pos == 'top')) { |
---|
2528 |
|
---|
2529 |
$top_margin += $x_tick_len; |
---|
2530 |
$this->x_label_top_offset = $x_tick_len + $gap; |
---|
2531 |
$this->x_title_top_offset += $x_tick_len; |
---|
2532 |
|
---|
2533 |
|
---|
2534 |
$this->x_label_top_offset = $gap; |
---|
2535 |
|
---|
2536 |
$x_tick_pos == 'plotdown' || $x_tick_pos == 'both' |
---|
2537 |
|| ($x_tick_pos == 'xaxis' && $x_axis_pos == 'bottom')) { |
---|
2538 |
|
---|
2539 |
$bot_margin += $x_tick_len; |
---|
2540 |
$this->x_label_bot_offset = $x_tick_len + $gap; |
---|
2541 |
$this->x_title_bot_offset += $x_tick_len; |
---|
2542 |
|
---|
2543 |
|
---|
2544 |
$this->x_label_bot_offset = $gap; |
---|
2545 |
|
---|
2546 |
|
---|
2547 |
if ($x_tick_pos == 'xaxis') { |
---|
2548 |
$this->x_label_axis_offset = $x_tick_len + $gap; |
---|
2549 |
|
---|
2550 |
$this->x_label_axis_offset = $gap; |
---|
2551 |
|
---|
2552 |
|
---|
2553 |
|
---|
2554 |
|
---|
2555 |
$left_margin = $gap; |
---|
2556 |
$right_margin = $gap; |
---|
2557 |
$this->y_title_left_offset = $gap; |
---|
2558 |
$this->y_title_right_offset = $gap; |
---|
2559 |
|
---|
2560 |
$y_title_width > 0) { |
---|
2561 |
$pos = $this->y_title_pos; |
---|
2562 |
$pos == 'plotleft' || $pos == 'both') |
---|
2563 |
$left_margin += $y_title_width + $gap; |
---|
2564 |
$pos == 'plotright' || $pos == 'both') |
---|
2565 |
$right_margin += $y_title_width + $gap; |
---|
2566 |
|
---|
2567 |
|
---|
2568 |
$y_tick_label_pos == 'plotleft' || $y_tick_label_pos == 'both' |
---|
2569 |
|| ($y_tick_label_pos == 'yaxis' && $y_axis_pos == 'left')) { |
---|
2570 |
|
---|
2571 |
$left_margin += $y_label_width + $gap; |
---|
2572 |
$this->y_title_left_offset += $y_label_width + $gap; |
---|
2573 |
|
---|
2574 |
$y_tick_label_pos == 'plotright' || $y_tick_label_pos == 'both' |
---|
2575 |
|| ($y_tick_label_pos == 'yaxis' && $y_axis_pos == 'right')) { |
---|
2576 |
|
---|
2577 |
$right_margin += $y_label_width + $gap; |
---|
2578 |
$this->y_title_right_offset += $y_label_width + $gap; |
---|
2579 |
|
---|
2580 |
$y_tick_pos == 'plotleft' || $y_tick_pos == 'both' |
---|
2581 |
|| ($y_tick_pos == 'yaxis' && $y_axis_pos == 'left')) { |
---|
2582 |
|
---|
2583 |
$left_margin += $y_tick_len; |
---|
2584 |
$this->y_label_left_offset = $y_tick_len + $gap; |
---|
2585 |
$this->y_title_left_offset += $y_tick_len; |
---|
2586 |
|
---|
2587 |
|
---|
2588 |
$this->y_label_left_offset = $gap; |
---|
2589 |
|
---|
2590 |
$y_tick_pos == 'plotright' || $y_tick_pos == 'both' |
---|
2591 |
|| ($y_tick_pos == 'yaxis' && $y_axis_pos == 'right')) { |
---|
2592 |
|
---|
2593 |
$right_margin += $y_tick_len; |
---|
2594 |
$this->y_label_right_offset = $y_tick_len + $gap; |
---|
2595 |
$this->y_title_right_offset += $y_tick_len; |
---|
2596 |
|
---|
2597 |
|
---|
2598 |
$this->y_label_right_offset = $gap; |
---|
2599 |
|
---|
2600 |
|
---|
2601 |
|
---|
2602 |
if ($x_tick_pos == 'yaxis') { |
---|
2603 |
$this->y_label_axis_offset = $y_tick_len + $gap; |
---|
2604 |
|
---|
2605 |
$this->y_label_axis_offset = $gap; |
---|
2606 |
|
---|
2607 |
|
---|
2608 |
|
---|
2609 |
|
---|
2610 |
if (!$this->plot_margins_set) { |
---|
2611 |
$this->y_top_margin = max($min_margin, $top_margin); |
---|
2612 |
$this->y_bot_margin = max($min_margin, $bot_margin); |
---|
2613 |
$this->x_left_margin = max($min_margin, $left_margin); |
---|
2614 |
$this->x_right_margin = max($min_margin, $right_margin); |
---|
2615 |
|
---|
2616 |
|
---|
2617 |
$this->GetCallback('debug_scale')) { |
---|
2618 |
|
---|
2619 |
$this->DoCallback('debug_scale', __FUNCTION__, array( |
---|
2620 |
'x_label_height' => $x_label_height, |
---|
2621 |
'y_label_width' => $y_label_width, |
---|
2622 |
'x_tick_len' => $x_tick_len, |
---|
2623 |
'y_tick_len' => $y_tick_len, |
---|
2624 |
'x_left_margin' => $this->x_left_margin, |
---|
2625 |
'x_right_margin' => $this->x_right_margin, |
---|
2626 |
'y_top_margin' => $this->y_top_margin, |
---|
2627 |
'y_bot_margin' => $this->y_bot_margin, |
---|
2628 |
'x_label_top_offset' => $this->x_label_top_offset, |
---|
2629 |
'x_label_bot_offset' => $this->x_label_bot_offset, |
---|
2630 |
'y_label_left_offset' => $this->y_label_left_offset, |
---|
2631 |
'y_label_right_offset' => $this->y_label_right_offset, |
---|
2632 |
'x_title_top_offset' => $this->x_title_top_offset, |
---|
2633 |
'x_title_bot_offset' => $this->x_title_bot_offset, |
---|
2634 |
'y_title_left_offset' => $this->y_title_left_offset, |
---|
2635 |
'y_title_right_offset' => $this->y_title_right_offset)); |
---|
2636 |
|
---|
2637 |
|
---|
2638 |
TRUE; |
---|
2639 |
|
---|
2640 |
|
---|
2641 |
|
---|
2642 |
|
---|
2643 |
|
---|
2644 |
|
---|
2645 |
|
---|
2646 |
|
---|
2647 |
function CalcPlotAreaPixels() |
---|
2648 |
|
---|
2649 |
$this->plot_area = array($this->x_left_margin, $this->y_top_margin, |
---|
2650 |
$this->image_width - $this->x_right_margin, |
---|
2651 |
$this->image_height - $this->y_bot_margin); |
---|
2652 |
$this->plot_area_width = $this->plot_area[2] - $this->plot_area[0]; |
---|
2653 |
$this->plot_area_height = $this->plot_area[3] - $this->plot_area[1]; |
---|
2654 |
|
---|
2655 |
$this->DoCallback('debug_scale', __FUNCTION__, $this->plot_area); |
---|
2656 |
TRUE; |
---|
2657 |
|
---|
2658 |
|
---|
2659 |
|
---|
2660 |
|
---|
2661 |
|
---|
2662 |
|
---|
2663 |
|
---|
2664 |
|
---|
2665 |
function SetMarginsPixels($which_lm, $which_rm, $which_tm, $which_bm) |
---|
2666 |
|
---|
2667 |
$this->x_left_margin = $which_lm; |
---|
2668 |
$this->x_right_margin = $which_rm; |
---|
2669 |
$this->y_top_margin = $which_tm; |
---|
2670 |
$this->y_bot_margin = $which_bm; |
---|
2671 |
|
---|
2672 |
$this->plot_margins_set = TRUE; |
---|
2673 |
|
---|
2674 |
TRUE; |
---|
2675 |
|
---|
2676 |
|
---|
2677 |
|
---|
2678 |
|
---|
2679 |
|
---|
2680 |
|
---|
2681 |
|
---|
2682 |
|
---|
2683 |
|
---|
2684 |
|
---|
2685 |
|
---|
2686 |
|
---|
2687 |
function SetPlotAreaPixels($x1, $y1, $x2, $y2) |
---|
2688 |
|
---|
2689 |
$this->x_left_margin = $x1; |
---|
2690 |
$this->x_right_margin = $this->image_width - $x2; |
---|
2691 |
$this->y_top_margin = $y1; |
---|
2692 |
$this->y_bot_margin = $this->image_height - $y2; |
---|
2693 |
|
---|
2694 |
$this->plot_margins_set = TRUE; |
---|
2695 |
|
---|
2696 |
TRUE; |
---|
2697 |
|
---|
2698 |
|
---|
2699 |
|
---|
2700 |
|
---|
2701 |
|
---|
2702 |
|
---|
2703 |
|
---|
2704 |
|
---|
2705 |
|
---|
2706 |
|
---|
2707 |
function CalcPlotAreaWorld() |
---|
2708 |
|
---|
2709 |
$this->plot_min_x) && $this->plot_min_x !== '') |
---|
2710 |
$xmin = $this->plot_min_x; |
---|
2711 |
$this->data_type == 'text-data') |
---|
2712 |
$xmin = 0; |
---|
2713 |
|
---|
2714 |
$xmin = $this->min_x; |
---|
2715 |
|
---|
2716 |
$this->plot_max_x) && $this->plot_max_x !== '') |
---|
2717 |
$xmax = $this->plot_max_x; |
---|
2718 |
$this->data_type == 'text-data') |
---|
2719 |
$xmax = $this->max_x + 1; |
---|
2720 |
|
---|
2721 |
$xmax = $this->max_x; |
---|
2722 |
|
---|
2723 |
|
---|
2724 |
|
---|
2725 |
if (!isset($this->plot_min_y) || $this->plot_min_y === '') |
---|
2726 |
$ymin = floor($this->min_y - abs($this->min_y) * 0.1); |
---|
2727 |
|
---|
2728 |
$ymin = $this->plot_min_y; |
---|
2729 |
|
---|
2730 |
$this->plot_max_y) || $this->plot_max_y === '') |
---|
2731 |
$ymax = ceil($this->max_y + abs($this->max_y) * 0.1); |
---|
2732 |
|
---|
2733 |
$ymax = $this->plot_max_y; |
---|
2734 |
|
---|
2735 |
|
---|
2736 |
|
---|
2737 |
if ($ymin == $ymax) |
---|
2738 |
$ymax += 1; |
---|
2739 |
|
---|
2740 |
$this->yscale_type == 'log') { |
---|
2741 |
$ymin <= 0) { |
---|
2742 |
$ymin = 1; |
---|
2743 |
|
---|
2744 |
$ymax <= 0) { |
---|
2745 |
|
---|
2746 |
return $this->PrintError('SetPlotAreaWorld(): Log plots need data greater than 0'); |
---|
2747 |
|
---|
2748 |
|
---|
2749 |
|
---|
2750 |
$ymax <= $ymin) { |
---|
2751 |
$this->PrintError('SetPlotAreaWorld(): Error in data - max not greater than min'); |
---|
2752 |
|
---|
2753 |
|
---|
2754 |
$this->plot_min_x = $xmin; |
---|
2755 |
$this->plot_max_x = $xmax; |
---|
2756 |
$this->plot_min_y = $ymin; |
---|
2757 |
$this->plot_max_y = $ymax; |
---|
2758 |
$this->GetCallback('debug_scale')) { |
---|
2759 |
$this->DoCallback('debug_scale', __FUNCTION__, array( |
---|
2760 |
'plot_min_x' => $this->plot_min_x, 'plot_min_y' => $this->plot_min_y, |
---|
2761 |
'plot_max_x' => $this->plot_max_x, 'plot_max_y' => $this->plot_max_y)); |
---|
2762 |
|
---|
2763 |
|
---|
2764 |
TRUE; |
---|
2765 |
|
---|
2766 |
|
---|
2767 |
|
---|
2768 |
|
---|
2769 |
|
---|
2770 |
|
---|
2771 |
|
---|
2772 |
function SetPlotAreaWorld($xmin=NULL, $ymin=NULL, $xmax=NULL, $ymax=NULL) |
---|
2773 |
|
---|
2774 |
$this->plot_min_x = $xmin; |
---|
2775 |
$this->plot_max_x = $xmax; |
---|
2776 |
$this->plot_min_y = $ymin; |
---|
2777 |
$this->plot_max_y = $ymax; |
---|
2778 |
TRUE; |
---|
2779 |
|
---|
2780 |
|
---|
2781 |
|
---|
2782 |
|
---|
2783 |
|
---|
2784 |
|
---|
2785 |
function CalcBarWidths() |
---|
2786 |
|
---|
2787 |
|
---|
2788 |
$group_width = $this->plot_area_width / $this->num_data_rows; |
---|
2789 |
|
---|
2790 |
|
---|
2791 |
|
---|
2792 |
|
---|
2793 |
|
---|
2794 |
if ($this->plot_type == 'stackedbars') { |
---|
2795 |
$num_spots = 1 + $this->bar_extra_space; |
---|
2796 |
|
---|
2797 |
$num_spots = $this->records_per_group - 1 + $this->bar_extra_space; |
---|
2798 |
|
---|
2799 |
|
---|
2800 |
|
---|
2801 |
|
---|
2802 |
|
---|
2803 |
|
---|
2804 |
|
---|
2805 |
$this->record_bar_width = $this->group_frac_width * $group_width / $num_spots; |
---|
2806 |
|
---|
2807 |
|
---|
2808 |
|
---|
2809 |
|
---|
2810 |
|
---|
2811 |
|
---|
2812 |
|
---|
2813 |
$this->actual_bar_width = $this->record_bar_width * $this->bar_width_adjust; |
---|
2814 |
|
---|
2815 |
$this->bar_adjust_gap = ($this->record_bar_width - $this->actual_bar_width) / 2; |
---|
2816 |
|
---|
2817 |
TRUE; |
---|
2818 |
|
---|
2819 |
|
---|
2820 |
|
---|
2821 |
|
---|
2822 |
|
---|
2823 |
|
---|
2824 |
|
---|
2825 |
|
---|
2826 |
|
---|
2827 |
|
---|
2828 |
|
---|
2829 |
|
---|
2830 |
|
---|
2831 |
|
---|
2832 |
function CalcAxisPositions() |
---|
2833 |
|
---|
2834 |
|
---|
2835 |
|
---|
2836 |
if ($this->y_axis_position === '') |
---|
2837 |
$this->y_axis_position = $this->plot_min_x; |
---|
2838 |
|
---|
2839 |
$this->y_axis_position = min(max($this->plot_min_x, $this->y_axis_position), $this->plot_max_x); |
---|
2840 |
|
---|
2841 |
|
---|
2842 |
|
---|
2843 |
|
---|
2844 |
if ($this->x_axis_position === '') { |
---|
2845 |
$this->yscale_type == 'log') |
---|
2846 |
$this->x_axis_position = 1; |
---|
2847 |
$this->plot_min_y <= 0 && 0 <= $this->plot_max_y) |
---|
2848 |
$this->x_axis_position = 0; |
---|
2849 |
|
---|
2850 |
$this->x_axis_position = $this->plot_min_y; |
---|
2851 |
|
---|
2852 |
$this->x_axis_position = min(max($this->plot_min_y, $this->x_axis_position), $this->plot_max_y); |
---|
2853 |
|
---|
2854 |
$this->GetCallback('debug_scale')) { |
---|
2855 |
$this->DoCallback('debug_scale', __FUNCTION__, array( |
---|
2856 |
'x_axis_position' => $this->x_axis_position, |
---|
2857 |
'y_axis_position' => $this->y_axis_position)); |
---|
2858 |
|
---|
2859 |
|
---|
2860 |
TRUE; |
---|
2861 |
|
---|
2862 |
|
---|
2863 |
|
---|
2864 |
|
---|
2865 |
|
---|
2866 |
function CalcTranslation() |
---|
2867 |
|
---|
2868 |
$this->plot_max_x - $this->plot_min_x == 0) { |
---|
2869 |
$this->xscale = 0; |
---|
2870 |
|
---|
2871 |
$this->xscale_type == 'log') { |
---|
2872 |
$this->xscale = ($this->plot_area_width)/(log10($this->plot_max_x) - log10($this->plot_min_x)); |
---|
2873 |
|
---|
2874 |
$this->xscale = ($this->plot_area_width)/($this->plot_max_x - $this->plot_min_x); |
---|
2875 |
|
---|
2876 |
|
---|
2877 |
|
---|
2878 |
$this->plot_max_y - $this->plot_min_y == 0) { |
---|
2879 |
$this->yscale = 0; |
---|
2880 |
|
---|
2881 |
$this->yscale_type == 'log') { |
---|
2882 |
$this->yscale = ($this->plot_area_height)/(log10($this->plot_max_y) - log10($this->plot_min_y)); |
---|
2883 |
|
---|
2884 |
$this->yscale = ($this->plot_area_height)/($this->plot_max_y - $this->plot_min_y); |
---|
2885 |
|
---|
2886 |
|
---|
2887 |
|
---|
2888 |
if ($this->xscale_type == 'log') { |
---|
2889 |
$this->plot_origin_x = $this->plot_area[0] - ($this->xscale * log10($this->plot_min_x) ); |
---|
2890 |
|
---|
2891 |
$this->plot_origin_x = $this->plot_area[0] - ($this->xscale * $this->plot_min_x); |
---|
2892 |
|
---|
2893 |
$this->yscale_type == 'log') { |
---|
2894 |
$this->plot_origin_y = $this->plot_area[3] + ($this->yscale * log10($this->plot_min_y)); |
---|
2895 |
|
---|
2896 |
$this->plot_origin_y = $this->plot_area[3] + ($this->yscale * $this->plot_min_y); |
---|
2897 |
|
---|
2898 |
|
---|
2899 |
|
---|
2900 |
$this->y_axis_x_pixels = $this->xtr($this->y_axis_position); |
---|
2901 |
$this->x_axis_y_pixels = $this->ytr($this->x_axis_position); |
---|
2902 |
|
---|
2903 |
$this->GetCallback('debug_scale')) { |
---|
2904 |
$this->DoCallback('debug_scale', __FUNCTION__, array( |
---|
2905 |
'xscale' => $this->xscale, 'yscale' => $this->yscale, |
---|
2906 |
'plot_origin_x' => $this->plot_origin_x, 'plot_origin_y' => $this->plot_origin_y, |
---|
2907 |
'y_axis_x_pixels' => $this->y_axis_x_pixels, |
---|
2908 |
'x_axis_y_pixels' => $this->x_axis_y_pixels)); |
---|
2909 |
|
---|
2910 |
|
---|
2911 |
TRUE; |
---|
2912 |
|
---|
2913 |
|
---|
2914 |
|
---|
2915 |
|
---|
2916 |
|
---|
2917 |
|
---|
2918 |
|
---|
2919 |
function xtr($x_world) |
---|
2920 |
|
---|
2921 |
$this->xscale_type == 'log') { |
---|
2922 |
$x_pixels = $this->plot_origin_x + log10($x_world) * $this->xscale ; |
---|
2923 |
|
---|
2924 |
$x_pixels = $this->plot_origin_x + $x_world * $this->xscale ; |
---|
2925 |
|
---|
2926 |
round($x_pixels); |
---|
2927 |
|
---|
2928 |
|
---|
2929 |
|
---|
2930 |
|
---|
2931 |
|
---|
2932 |
|
---|
2933 |
|
---|
2934 |
function ytr($y_world) |
---|
2935 |
|
---|
2936 |
$this->yscale_type == 'log') { |
---|
2937 |
|
---|
2938 |
$y_pixels = $this->plot_origin_y - log10($y_world) * $this->yscale ; |
---|
2939 |
|
---|
2940 |
$y_pixels = $this->plot_origin_y - $y_world * $this->yscale ; |
---|
2941 |
|
---|
2942 |
round($y_pixels); |
---|
2943 |
|
---|
2944 |
|
---|
2945 |
|
---|
2946 |
|
---|
2947 |
|
---|
2948 |
|
---|
2949 |
|
---|
2950 |
|
---|
2951 |
|
---|
2952 |
|
---|
2953 |
|
---|
2954 |
|
---|
2955 |
|
---|
2956 |
|
---|
2957 |
function CalcTicks($which) |
---|
2958 |
|
---|
2959 |
$which == 'x') { |
---|
2960 |
$num_ticks = $this->num_x_ticks; |
---|
2961 |
$tick_inc = $this->x_tick_inc; |
---|
2962 |
$data_max = $this->plot_max_x; |
---|
2963 |
$data_min = $this->plot_min_x; |
---|
2964 |
$skip_lo = $this->skip_left_tick; |
---|
2965 |
$skip_hi = $this->skip_right_tick; |
---|
2966 |
$which == 'y') { |
---|
2967 |
$num_ticks = $this->num_y_ticks; |
---|
2968 |
$tick_inc = $this->y_tick_inc; |
---|
2969 |
$data_max = $this->plot_max_y; |
---|
2970 |
$data_min = $this->plot_min_y; |
---|
2971 |
$skip_lo = $this->skip_bottom_tick; |
---|
2972 |
$skip_hi = $this->skip_top_tick; |
---|
2973 |
|
---|
2974 |
$this->PrintError("CalcTicks: Invalid usage ($which)"); |
---|
2975 |
|
---|
2976 |
|
---|
2977 |
$tick_inc)) { |
---|
2978 |
$tick_step = $tick_inc; |
---|
2979 |
$num_ticks)) { |
---|
2980 |
$tick_step = ($data_max - $data_min) / $num_ticks; |
---|
2981 |
|
---|
2982 |
$tick_step = ($data_max - $data_min) / 10; |
---|
2983 |
|
---|
2984 |
|
---|
2985 |
|
---|
2986 |
|
---|
2987 |
|
---|
2988 |
$tick_start = (double)$data_min; |
---|
2989 |
$tick_end = (double)$data_max + ($data_max - $data_min) / 10000.0; |
---|
2990 |
|
---|
2991 |
$skip_lo) |
---|
2992 |
$tick_start += $tick_step; |
---|
2993 |
|
---|
2994 |
$skip_hi) |
---|
2995 |
$tick_end -= $tick_step; |
---|
2996 |
|
---|
2997 |
$tick_start, $tick_end, $tick_step); |
---|
2998 |
|
---|
2999 |
|
---|
3000 |
|
---|
3001 |
|
---|
3002 |
|
---|
3003 |
|
---|
3004 |
|
---|
3005 |
|
---|
3006 |
|
---|
3007 |
|
---|
3008 |
|
---|
3009 |
function CalcMaxTickLabelSize($which) |
---|
3010 |
|
---|
3011 |
$tick_val, $tick_end, $tick_step) = $this->CalcTicks($which); |
---|
3012 |
|
---|
3013 |
$which == 'x') { |
---|
3014 |
$font = $this->x_label_font; |
---|
3015 |
$angle = $this->x_label_angle; |
---|
3016 |
$which == 'y') { |
---|
3017 |
$font = $this->y_label_font; |
---|
3018 |
$angle = $this->y_label_angle; |
---|
3019 |
|
---|
3020 |
$this->PrintError("CalcMaxTickLabelSize: Invalid usage ($which)"); |
---|
3021 |
|
---|
3022 |
|
---|
3023 |
$max_width = 0; |
---|
3024 |
$max_height = 0; |
---|
3025 |
|
---|
3026 |
|
---|
3027 |
while ($tick_val <= $tick_end) { |
---|
3028 |
$tick_label = $this->FormatLabel($which, $tick_val); |
---|
3029 |
$width, $height) = $this->SizeText($font, $angle, $tick_label); |
---|
3030 |
$width > $max_width) $max_width = $width; |
---|
3031 |
$height > $max_height) $max_height = $height; |
---|
3032 |
$tick_val += $tick_step; |
---|
3033 |
|
---|
3034 |
$this->GetCallback('debug_scale')) { |
---|
3035 |
$this->DoCallback('debug_scale', __FUNCTION__, array( |
---|
3036 |
'which' => $which, 'height' => $max_height, 'width' => $max_width)); |
---|
3037 |
|
---|
3038 |
|
---|
3039 |
$which == 'x') |
---|
3040 |
$max_height; |
---|
3041 |
$max_width; |
---|
3042 |
|
---|
3043 |
|
---|
3044 |
|
---|
3045 |
|
---|
3046 |
|
---|
3047 |
|
---|
3048 |
|
---|
3049 |
function CalcMaxDataLabelSize() |
---|
3050 |
|
---|
3051 |
$font = $this->x_label_font; |
---|
3052 |
$angle = $this->x_label_angle; |
---|
3053 |
$max_width = 0; |
---|
3054 |
$max_height = 0; |
---|
3055 |
|
---|
3056 |
|
---|
3057 |
for ($i = 0; $i < $this->num_data_rows; $i++) { |
---|
3058 |
$label = $this->FormatLabel('x', $this->data[$i][0]); |
---|
3059 |
$width, $height) = $this->SizeText($font, $angle, $label); |
---|
3060 |
$width > $max_width) $max_width = $width; |
---|
3061 |
$height > $max_height) $max_height = $height; |
---|
3062 |
|
---|
3063 |
$this->GetCallback('debug_scale')) { |
---|
3064 |
$this->DoCallback('debug_scale', __FUNCTION__, array( |
---|
3065 |
'height' => $max_height, 'width' => $max_width)); |
---|
3066 |
|
---|
3067 |
|
---|
3068 |
$max_height; |
---|
3069 |
|
---|
3070 |
|
---|
3071 |
|
---|
3072 |
|
---|
3073 |
|
---|
3074 |
|
---|
3075 |
|
---|
3076 |
|
---|
3077 |
function FormatLabel($which_pos, $which_lab) |
---|
3078 |
|
---|
3079 |
$lab = $which_lab; |
---|
3080 |
if ($lab !== '') { |
---|
3081 |
if ($which_pos == 'x') { |
---|
3082 |
$this->x_label_type) { |
---|
3083 |
'title': |
---|
3084 |
$lab = @ $this->data[$which_lab][0]; |
---|
3085 |
|
---|
3086 |
'data': |
---|
3087 |
$lab = $this->number_format($which_lab, $this->x_precision).$this->data_units_text; |
---|
3088 |
|
---|
3089 |
'time': |
---|
3090 |
$lab = strftime($this->x_time_format, $which_lab); |
---|
3091 |
|
---|
3092 |
|
---|
3093 |
$which_pos == 'y') { |
---|
3094 |
$this->y_label_type) { |
---|
3095 |
'data': |
---|
3096 |
$lab = $this->number_format($which_lab, $this->y_precision).$this->data_units_text; |
---|
3097 |
|
---|
3098 |
'time': |
---|
3099 |
$lab = strftime($this->y_time_format, $which_lab); |
---|
3100 |
|
---|
3101 |
|
---|
3102 |
|
---|
3103 |
|
---|
3104 |
$lab; |
---|
3105 |
|
---|
3106 |
|
---|
3107 |
|
---|
3108 |
|
---|
3109 |
|
---|
3110 |
|
---|
3111 |
|
---|
3112 |
|
---|
3113 |
|
---|
3114 |
|
---|
3115 |
|
---|
3116 |
function SetXTickIncrement($which_ti='') |
---|
3117 |
|
---|
3118 |
$this->x_tick_inc = $which_ti; |
---|
3119 |
$which_ti)) { |
---|
3120 |
$this->num_x_ticks = ''; |
---|
3121 |
} |
---|
3122 |
TRUE; |
---|
3123 |
|
---|
3124 |
|
---|
3125 |
|
---|
3126 |
|
---|
3127 |
|
---|
3128 |
function SetYTickIncrement($which_ti='') |
---|
3129 |
|
---|
3130 |
$this->y_tick_inc = $which_ti; |
---|
3131 |
$which_ti)) { |
---|
3132 |
$this->num_y_ticks = ''; |
---|
3133 |
} |
---|
3134 |
TRUE; |
---|
3135 |
|
---|
3136 |
|
---|
3137 |
|
---|
3138 |
SetNumXTicks($which_nt) |
---|
3139 |
|
---|
3140 |
$this->num_x_ticks = $which_nt; |
---|
3141 |
$which_nt)) { |
---|
3142 |
$this->x_tick_inc = ''; |
---|
3143 |
} |
---|
3144 |
TRUE; |
---|
3145 |
|
---|
3146 |
|
---|
3147 |
SetNumYTicks($which_nt) |
---|
3148 |
|
---|
3149 |
$this->num_y_ticks = $which_nt; |
---|
3150 |
$which_nt)) { |
---|
3151 |
$this->y_tick_inc = ''; |
---|
3152 |
} |
---|
3153 |
TRUE; |
---|
3154 |
|
---|
3155 |
|
---|
3156 |
|
---|
3157 |
|
---|
3158 |
|
---|
3159 |
function SetYTickPos($which_tp) |
---|
3160 |
|
---|
3161 |
$this->y_tick_pos = $this->CheckOption($which_tp, 'plotleft, plotright, both, yaxis, none', __FUNCTION__); |
---|
3162 |
$this->y_tick_pos; |
---|
3163 |
|
---|
3164 |
|
---|
3165 |
|
---|
3166 |
|
---|
3167 |
function SetXTickPos($which_tp) |
---|
3168 |
|
---|
3169 |
$this->x_tick_pos = $this->CheckOption($which_tp, 'plotdown, plotup, both, xaxis, none', __FUNCTION__); |
---|
3170 |
$this->x_tick_pos; |
---|
3171 |
|
---|
3172 |
|
---|
3173 |
|
---|
3174 |
|
---|
3175 |
|
---|
3176 |
function SetSkipTopTick($skip) |
---|
3177 |
|
---|
3178 |
$this->skip_top_tick = (bool)$skip; |
---|
3179 |
TRUE; |
---|
3180 |
|
---|
3181 |
|
---|
3182 |
|
---|
3183 |
|
---|
3184 |
|
---|
3185 |
function SetSkipBottomTick($skip) |
---|
3186 |
|
---|
3187 |
$this->skip_bottom_tick = (bool)$skip; |
---|
3188 |
TRUE; |
---|
3189 |
|
---|
3190 |
|
---|
3191 |
|
---|
3192 |
|
---|
3193 |
|
---|
3194 |
function SetSkipLeftTick($skip) |
---|
3195 |
|
---|
3196 |
$this->skip_left_tick = (bool)$skip; |
---|
3197 |
TRUE; |
---|
3198 |
|
---|
3199 |
|
---|
3200 |
|
---|
3201 |
|
---|
3202 |
|
---|
3203 |
function SetSkipRightTick($skip) |
---|
3204 |
|
---|
3205 |
$this->skip_right_tick = (bool)$skip; |
---|
3206 |
TRUE; |
---|
3207 |
|
---|
3208 |
|
---|
3209 |
SetXTickLength($which_xln) |
---|
3210 |
|
---|
3211 |
$this->x_tick_length = $which_xln; |
---|
3212 |
TRUE; |
---|
3213 |
|
---|
3214 |
|
---|
3215 |
SetYTickLength($which_yln) |
---|
3216 |
|
---|
3217 |
$this->y_tick_length = $which_yln; |
---|
3218 |
TRUE; |
---|
3219 |
|
---|
3220 |
|
---|
3221 |
SetXTickCrossing($which_xc) |
---|
3222 |
|
---|
3223 |
$this->x_tick_cross = $which_xc; |
---|
3224 |
TRUE; |
---|
3225 |
|
---|
3226 |
|
---|
3227 |
SetYTickCrossing($which_yc) |
---|
3228 |
|
---|
3229 |
$this->y_tick_cross = $which_yc; |
---|
3230 |
TRUE; |
---|
3231 |
|
---|
3232 |
|
---|
3233 |
|
---|
3234 |
|
---|
3235 |
|
---|
3236 |
|
---|
3237 |
|
---|
3238 |
|
---|
3239 |
|
---|
3240 |
|
---|
3241 |
function DrawBackground() |
---|
3242 |
|
---|
3243 |
|
---|
3244 |
if (! $this->background_done) { |
---|
3245 |
$this->bgimg)) { |
---|
3246 |
$this->tile_img($this->bgimg, 0, 0, $this->image_width, $this->image_height, $this->bgmode); |
---|
3247 |
|
---|
3248 |
ImageFilledRectangle($this->img, 0, 0, $this->image_width, $this->image_height, |
---|
3249 |
$this->ndx_bg_color); |
---|
3250 |
|
---|
3251 |
$this->background_done = TRUE; |
---|
3252 |
|
---|
3253 |
TRUE; |
---|
3254 |
|
---|
3255 |
|
---|
3256 |
|
---|
3257 |
|
---|
3258 |
|
---|
3259 |
|
---|
3260 |
function DrawPlotAreaBackground() |
---|
3261 |
|
---|
3262 |
$this->plotbgimg)) { |
---|
3263 |
$this->tile_img($this->plotbgimg, $this->plot_area[0], $this->plot_area[1], |
---|
3264 |
$this->plot_area_width, $this->plot_area_height, $this->plotbgmode); |
---|
3265 |
|
---|
3266 |
|
---|
3267 |
$this->draw_plot_area_background) { |
---|
3268 |
ImageFilledRectangle($this->img, $this->plot_area[0], $this->plot_area[1], |
---|
3269 |
$this->plot_area[2], $this->plot_area[3], $this->ndx_plot_bg_color); |
---|
3270 |
|
---|
3271 |
|
---|
3272 |
|
---|
3273 |
TRUE; |
---|
3274 |
|
---|
3275 |
|
---|
3276 |
|
---|
3277 |
|
---|
3278 |
|
---|
3279 |
|
---|
3280 |
|
---|
3281 |
|
---|
3282 |
|
---|
3283 |
|
---|
3284 |
|
---|
3285 |
|
---|
3286 |
|
---|
3287 |
function tile_img($file, $xorig, $yorig, $width, $height, $mode) |
---|
3288 |
|
---|
3289 |
$im = $this->GetImage($file, $tile_width, $tile_height); |
---|
3290 |
$im) |
---|
3291 |
FALSE; |
---|
3292 |
|
---|
3293 |
if ($mode == 'scale') { |
---|
3294 |
imagecopyresized($this->img, $im, $xorig, $yorig, 0, 0, $width, $height, $tile_width, $tile_height); |
---|
3295 |
TRUE; |
---|
3296 |
$mode == 'centeredtile') { |
---|
3297 |
$x0 = - floor($tile_width/2); |
---|
3298 |
$y0 = - floor($tile_height/2); |
---|
3299 |
$mode = 'tile') { |
---|
3300 |
$x0 = 0; |
---|
3301 |
$y0 = 0; |
---|
3302 |
|
---|
3303 |
|
---|
3304 |
|
---|
3305 |
|
---|
3306 |
|
---|
3307 |
$tmp = ImageCreate($width, $height); |
---|
3308 |
$tmp) |
---|
3309 |
$this->PrintError('tile_img(): Could not create image resource.'); |
---|
3310 |
|
---|
3311 |
$x = $x0; $x < $width; $x += $tile_width) |
---|
3312 |
$y = $y0; $y < $height; $y += $tile_height) |
---|
3313 |
imagecopy($tmp, $im, $x, $y, 0, 0, $tile_width, $tile_height); |
---|
3314 |
|
---|
3315 |
|
---|
3316 |
imagecopy($this->img, $tmp, $xorig, $yorig, 0,0, $width, $height); |
---|
3317 |
|
---|
3318 |
|
---|
3319 |
imagedestroy($tmp); |
---|
3320 |
imagedestroy($im); |
---|
3321 |
|
---|
3322 |
TRUE; |
---|
3323 |
|
---|
3324 |
|
---|
3325 |
|
---|
3326 |
|
---|
3327 |
|
---|
3328 |
|
---|
3329 |
function DrawImageBorder() |
---|
3330 |
|
---|
3331 |
$this->image_border_type) { |
---|
3332 |
'raised': |
---|
3333 |
ImageLine($this->img, 0, 0, $this->image_width-1, 0, $this->ndx_i_border); |
---|
3334 |
ImageLine($this->img, 1, 1, $this->image_width-2, 1, $this->ndx_i_border); |
---|
3335 |
ImageLine($this->img, 0, 0, 0, $this->image_height-1, $this->ndx_i_border); |
---|
3336 |
ImageLine($this->img, 1, 1, 1, $this->image_height-2, $this->ndx_i_border); |
---|
3337 |
ImageLine($this->img, $this->image_width-1, 0, $this->image_width-1, |
---|
3338 |
$this->image_height-1, $this->ndx_i_border_dark); |
---|
3339 |
ImageLine($this->img, 0, $this->image_height-1, $this->image_width-1, |
---|
3340 |
$this->image_height-1, $this->ndx_i_border_dark); |
---|
3341 |
ImageLine($this->img, $this->image_width-2, 1, $this->image_width-2, |
---|
3342 |
$this->image_height-2, $this->ndx_i_border_dark); |
---|
3343 |
ImageLine($this->img, 1, $this->image_height-2, $this->image_width-2, |
---|
3344 |
$this->image_height-2, $this->ndx_i_border_dark); |
---|
3345 |
|
---|
3346 |
'plain': |
---|
3347 |
ImageLine($this->img, 0, 0, $this->image_width-1, 0, $this->ndx_i_border_dark); |
---|
3348 |
ImageLine($this->img, $this->image_width-1, 0, $this->image_width-1, |
---|
3349 |
$this->image_height-1, $this->ndx_i_border_dark); |
---|
3350 |
ImageLine($this->img, $this->image_width-1, $this->image_height-1, 0, $this->image_height-1, |
---|
3351 |
$this->ndx_i_border_dark); |
---|
3352 |
ImageLine($this->img, 0, 0, 0, $this->image_height-1, $this->ndx_i_border_dark); |
---|
3353 |
|
---|
3354 |
'none': |
---|
3355 |
|
---|
3356 |
|
---|
3357 |
$this->PrintError("DrawImageBorder(): unknown image_border_type: '$this->image_border_type'"); |
---|
3358 |
|
---|
3359 |
TRUE; |
---|
3360 |
|
---|
3361 |
|
---|
3362 |
|
---|
3363 |
|
---|
3364 |
|
---|
3365 |
|
---|
3366 |
function DrawTitle() |
---|
3367 |
|
---|
3368 |
|
---|
3369 |
|
---|
3370 |
|
---|
3371 |
|
---|
3372 |
$xpos = $this->image_width / 2; |
---|
3373 |
|
---|
3374 |
|
---|
3375 |
$ypos = $this->safe_margin; |
---|
3376 |
|
---|
3377 |
$this->DrawText($this->title_font, 0, $xpos, $ypos, |
---|
3378 |
$this->ndx_title_color, $this->title_txt, 'center', 'top'); |
---|
3379 |
|
---|
3380 |
TRUE; |
---|
3381 |
|
---|
3382 |
|
---|
3383 |
|
---|
3384 |
|
---|
3385 |
|
---|
3386 |
|
---|
3387 |
|
---|
3388 |
function DrawXTitle() |
---|
3389 |
|
---|
3390 |
$this->x_title_pos == 'none') |
---|
3391 |
TRUE; |
---|
3392 |
|
---|
3393 |
|
---|
3394 |
$xpos = ($this->plot_area[2] + $this->plot_area[0]) / 2; |
---|
3395 |
|
---|
3396 |
|
---|
3397 |
if ($this->x_title_pos == 'plotup' || $this->x_title_pos == 'both') { |
---|
3398 |
$ypos = $this->plot_area[1] - $this->x_title_top_offset; |
---|
3399 |
$this->DrawText($this->x_title_font, 0, $xpos, $ypos, $this->ndx_title_color, |
---|
3400 |
$this->x_title_txt, 'center', 'bottom'); |
---|
3401 |
|
---|
3402 |
|
---|
3403 |
if ($this->x_title_pos == 'plotdown' || $this->x_title_pos == 'both') { |
---|
3404 |
$ypos = $this->plot_area[3] + $this->x_title_bot_offset; |
---|
3405 |
$this->DrawText($this->x_title_font, 0, $xpos, $ypos, $this->ndx_title_color, |
---|
3406 |
$this->x_title_txt, 'center', 'top'); |
---|
3407 |
|
---|
3408 |
TRUE; |
---|
3409 |
|
---|
3410 |
|
---|
3411 |
|
---|
3412 |
|
---|
3413 |
|
---|
3414 |
function DrawYTitle() |
---|
3415 |
|
---|
3416 |
$this->y_title_pos == 'none') |
---|
3417 |
TRUE; |
---|
3418 |
|
---|
3419 |
|
---|
3420 |
$ypos = ($this->plot_area[3] + $this->plot_area[1]) / 2; |
---|
3421 |
|
---|
3422 |
$this->y_title_pos == 'plotleft' || $this->y_title_pos == 'both') { |
---|
3423 |
$xpos = $this->plot_area[0] - $this->y_title_left_offset; |
---|
3424 |
$this->DrawText($this->y_title_font, 90, $xpos, $ypos, $this->ndx_title_color, |
---|
3425 |
$this->y_title_txt, 'right', 'center'); |
---|
3426 |
|
---|
3427 |
$this->y_title_pos == 'plotright' || $this->y_title_pos == 'both') { |
---|
3428 |
$xpos = $this->plot_area[2] + $this->y_title_right_offset; |
---|
3429 |
$this->DrawText($this->y_title_font, 90, $xpos, $ypos, $this->ndx_title_color, |
---|
3430 |
$this->y_title_txt, 'left', 'center'); |
---|
3431 |
|
---|
3432 |
|
---|
3433 |
TRUE; |
---|
3434 |
|
---|
3435 |
|
---|
3436 |
|
---|
3437 |
|
---|
3438 |
|
---|
3439 |
|
---|
3440 |
function DrawYAxis() |
---|
3441 |
|
---|
3442 |
|
---|
3443 |
$this->DrawYTicks(); |
---|
3444 |
|
---|
3445 |
|
---|
3446 |
ImageLine($this->img, $this->y_axis_x_pixels, $this->plot_area[1], |
---|
3447 |
$this->y_axis_x_pixels, $this->plot_area[3], $this->ndx_grid_color); |
---|
3448 |
|
---|
3449 |
TRUE; |
---|
3450 |
|
---|
3451 |
|
---|
3452 |
|
---|
3453 |
|
---|
3454 |
|
---|
3455 |
function DrawXAxis() |
---|
3456 |
|
---|
3457 |
|
---|
3458 |
$this->DrawXTicks(); |
---|
3459 |
|
---|
3460 |
|
---|
3461 |
|
---|
3462 |
|
---|
3463 |
|
---|
3464 |
|
---|
3465 |
|
---|
3466 |
|
---|
3467 |
|
---|
3468 |
|
---|
3469 |
|
---|
3470 |
ImageLine($this->img, $this->plot_area[0]+1, $this->x_axis_y_pixels, |
---|
3471 |
$this->plot_area[2]-1, $this->x_axis_y_pixels, $this->ndx_grid_color); |
---|
3472 |
|
---|
3473 |
TRUE; |
---|
3474 |
|
---|
3475 |
|
---|
3476 |
|
---|
3477 |
|
---|
3478 |
|
---|
3479 |
function DrawYTick($which_ylab, $which_ypix) |
---|
3480 |
|
---|
3481 |
|
---|
3482 |
if ($this->y_tick_pos == 'yaxis') { |
---|
3483 |
ImageLine($this->img, $this->y_axis_x_pixels - $this->y_tick_length, $which_ypix, |
---|
3484 |
$this->y_axis_x_pixels + $this->y_tick_cross, $which_ypix, $this->ndx_tick_color); |
---|
3485 |
|
---|
3486 |
|
---|
3487 |
|
---|
3488 |
if (($this->y_tick_pos == 'plotleft') || ($this->y_tick_pos == 'both') ) { |
---|
3489 |
ImageLine($this->img, $this->plot_area[0] - $this->y_tick_length, $which_ypix, |
---|
3490 |
$this->plot_area[0] + $this->y_tick_cross, $which_ypix, $this->ndx_tick_color); |
---|
3491 |
|
---|
3492 |
|
---|
3493 |
|
---|
3494 |
if (($this->y_tick_pos == 'plotright') || ($this->y_tick_pos == 'both') ) { |
---|
3495 |
ImageLine($this->img, $this->plot_area[2] + $this->y_tick_length, $which_ypix, |
---|
3496 |
$this->plot_area[2] - $this->y_tick_cross, $which_ypix, $this->ndx_tick_color); |
---|
3497 |
|
---|
3498 |
|
---|
3499 |
|
---|
3500 |
if ($this->y_tick_label_pos == 'yaxis') { |
---|
3501 |
$this->DrawText($this->y_label_font, $this->y_label_angle, |
---|
3502 |
$this->y_axis_x_pixels - $this->y_label_axis_offset, $which_ypix, |
---|
3503 |
$this->ndx_text_color, $which_ylab, 'right', 'center'); |
---|
3504 |
|
---|
3505 |
|
---|
3506 |
|
---|
3507 |
if ($this->y_tick_label_pos == 'plotleft' || $this->y_tick_label_pos == 'both') { |
---|
3508 |
$this->DrawText($this->y_label_font, $this->y_label_angle, |
---|
3509 |
$this->plot_area[0] - $this->y_label_left_offset, $which_ypix, |
---|
3510 |
$this->ndx_text_color, $which_ylab, 'right', 'center'); |
---|
3511 |
|
---|
3512 |
|
---|
3513 |
if ($this->y_tick_label_pos == 'plotright' || $this->y_tick_label_pos == 'both') { |
---|
3514 |
$this->DrawText($this->y_label_font, $this->y_label_angle, |
---|
3515 |
$this->plot_area[2] + $this->y_label_right_offset, $which_ypix, |
---|
3516 |
$this->ndx_text_color, $which_ylab, 'left', 'center'); |
---|
3517 |
|
---|
3518 |
TRUE; |
---|
3519 |
|
---|
3520 |
|
---|
3521 |
|
---|
3522 |
|
---|
3523 |
|
---|
3524 |
|
---|
3525 |
|
---|
3526 |
|
---|
3527 |
|
---|
3528 |
function DrawYTicks() |
---|
3529 |
|
---|
3530 |
|
---|
3531 |
if ($this->dashed_grid) { |
---|
3532 |
$this->SetDashedStyle($this->ndx_light_grid_color); |
---|
3533 |
$style = IMG_COLOR_STYLED; |
---|
3534 |
|
---|
3535 |
$style = $this->ndx_light_grid_color; |
---|
3536 |
|
---|
3537 |
|
---|
3538 |
|
---|
3539 |
list($y_tmp, $y_end, $delta_y) = $this->CalcTicks('y'); |
---|
3540 |
|
---|
3541 |
$y_tmp <= $y_end; $y_tmp += $delta_y) { |
---|
3542 |
$ylab = $this->FormatLabel('y', $y_tmp); |
---|
3543 |
$y_pixels = $this->ytr($y_tmp); |
---|
3544 |
|
---|
3545 |
|
---|
3546 |
if ($this->draw_y_grid) { |
---|
3547 |
ImageLine($this->img, $this->plot_area[0]+1, $y_pixels, $this->plot_area[2]-1, $y_pixels, $style); |
---|
3548 |
|
---|
3549 |
|
---|
3550 |
|
---|
3551 |
$this->DrawYTick($ylab, $y_pixels); |
---|
3552 |
|
---|
3553 |
TRUE; |
---|
3554 |
|
---|
3555 |
|
---|
3556 |
|
---|
3557 |
|
---|
3558 |
|
---|
3559 |
function DrawXTick($which_xlab, $which_xpix) |
---|
3560 |
|
---|
3561 |
|
---|
3562 |
if ($this->x_tick_pos == 'xaxis') { |
---|
3563 |
ImageLine($this->img, $which_xpix, $this->x_axis_y_pixels - $this->x_tick_cross, |
---|
3564 |
$which_xpix, $this->x_axis_y_pixels + $this->x_tick_length, $this->ndx_tick_color); |
---|
3565 |
|
---|
3566 |
|
---|
3567 |
|
---|
3568 |
if ($this->x_tick_pos == 'plotup' || $this->x_tick_pos == 'both') { |
---|
3569 |
ImageLine($this->img, $which_xpix, $this->plot_area[1] - $this->x_tick_length, |
---|
3570 |
$which_xpix, $this->plot_area[1] + $this->x_tick_cross, $this->ndx_tick_color); |
---|
3571 |
|
---|
3572 |
|
---|
3573 |
|
---|
3574 |
if ($this->x_tick_pos == 'plotdown' || $this->x_tick_pos == 'both') { |
---|
3575 |
ImageLine($this->img, $which_xpix, $this->plot_area[3] + $this->x_tick_length, |
---|
3576 |
$which_xpix, $this->plot_area[3] - $this->x_tick_cross, $this->ndx_tick_color); |
---|
3577 |
|
---|
3578 |
|
---|
3579 |
|
---|
3580 |
if ($this->x_tick_label_pos == 'xaxis') { |
---|
3581 |
$this->DrawText($this->x_label_font, $this->x_label_angle, |
---|
3582 |
$which_xpix, $this->x_axis_y_pixels + $this->x_label_axis_offset, |
---|
3583 |
$this->ndx_text_color, $which_xlab, 'center', 'top'); |
---|
3584 |
|
---|
3585 |
|
---|
3586 |
|
---|
3587 |
if ($this->x_tick_label_pos == 'plotup' || $this->x_tick_label_pos == 'both') { |
---|
3588 |
$this->DrawText($this->x_label_font, $this->x_label_angle, |
---|
3589 |
$which_xpix, $this->plot_area[1] - $this->x_label_top_offset, |
---|
3590 |
$this->ndx_text_color, $which_xlab, 'center', 'bottom'); |
---|
3591 |
|
---|
3592 |
|
---|
3593 |
|
---|
3594 |
if ($this->x_tick_label_pos == 'plotdown' || $this->x_tick_label_pos == 'both') { |
---|
3595 |
$this->DrawText($this->x_label_font, $this->x_label_angle, |
---|
3596 |
$which_xpix, $this->plot_area[3] + $this->x_label_bot_offset, |
---|
3597 |
$this->ndx_text_color, $which_xlab, 'center', 'top'); |
---|
3598 |
|
---|
3599 |
TRUE; |
---|
3600 |
|
---|
3601 |
|
---|
3602 |
|
---|
3603 |
|
---|
3604 |
|
---|
3605 |
|
---|
3606 |
|
---|
3607 |
|
---|
3608 |
|
---|
3609 |
function DrawXTicks() |
---|
3610 |
|
---|
3611 |
|
---|
3612 |
if ($this->dashed_grid) { |
---|
3613 |
$this->SetDashedStyle($this->ndx_light_grid_color); |
---|
3614 |
$style = IMG_COLOR_STYLED; |
---|
3615 |
|
---|
3616 |
$style = $this->ndx_light_grid_color; |
---|
3617 |
|
---|
3618 |
|
---|
3619 |
|
---|
3620 |
list($x_tmp, $x_end, $delta_x) = $this->CalcTicks('x'); |
---|
3621 |
|
---|
3622 |
$x_tmp <= $x_end; $x_tmp += $delta_x) { |
---|
3623 |
$xlab = $this->FormatLabel('x', $x_tmp); |
---|
3624 |
$x_pixels = $this->xtr($x_tmp); |
---|
3625 |
|
---|
3626 |
|
---|
3627 |
if ($this->draw_x_grid) { |
---|
3628 |
ImageLine($this->img, $x_pixels, $this->plot_area[1], $x_pixels, $this->plot_area[3], $style); |
---|
3629 |
|
---|
3630 |
|
---|
3631 |
|
---|
3632 |
$this->DrawXTick($xlab, $x_pixels); |
---|
3633 |
|
---|
3634 |
TRUE; |
---|
3635 |
|
---|
3636 |
|
---|
3637 |
|
---|
3638 |
|
---|
3639 |
|
---|
3640 |
|
---|
3641 |
function DrawPlotBorder() |
---|
3642 |
|
---|
3643 |
$this->plot_border_type) { |
---|
3644 |
'left': |
---|
3645 |
case 'plotleft': |
---|
3646 |
ImageLine($this->img, $this->plot_area[0], $this->ytr($this->plot_min_y), |
---|
3647 |
$this->plot_area[0], $this->ytr($this->plot_max_y), $this->ndx_grid_color); |
---|
3648 |
|
---|
3649 |
'right': |
---|
3650 |
'plotright': |
---|
3651 |
ImageLine($this->img, $this->plot_area[2], $this->ytr($this->plot_min_y), |
---|
3652 |
$this->plot_area[2], $this->ytr($this->plot_max_y), $this->ndx_grid_color); |
---|
3653 |
|
---|
3654 |
'both': |
---|
3655 |
'sides': |
---|
3656 |
ImageLine($this->img, $this->plot_area[0], $this->ytr($this->plot_min_y), |
---|
3657 |
$this->plot_area[0], $this->ytr($this->plot_max_y), $this->ndx_grid_color); |
---|
3658 |
ImageLine($this->img, $this->plot_area[2], $this->ytr($this->plot_min_y), |
---|
3659 |
$this->plot_area[2], $this->ytr($this->plot_max_y), $this->ndx_grid_color); |
---|
3660 |
|
---|
3661 |
'none': |
---|
3662 |
|
---|
3663 |
break; |
---|
3664 |
'full': |
---|
3665 |
|
---|
3666 |
ImageRectangle($this->img, $this->plot_area[0], $this->ytr($this->plot_min_y), |
---|
3667 |
$this->plot_area[2], $this->ytr($this->plot_max_y), $this->ndx_grid_color); |
---|
3668 |
|
---|
3669 |
|
---|
3670 |
TRUE; |
---|
3671 |
|
---|
3672 |
|
---|
3673 |
|
---|
3674 |
|
---|
3675 |
|
---|
3676 |
|
---|
3677 |
|
---|
3678 |
function DrawDataLabel($which_font, $which_angle, $x_world, $y_world, $which_color, $which_text, |
---|
3679 |
$which_halign = 'center', $which_valign = 'bottom', $x_adjustment=0, $y_adjustment=0) |
---|
3680 |
|
---|
3681 |
$data_label = $this->FormatLabel('y', $which_text); |
---|
3682 |
|
---|
3683 |
|
---|
3684 |
if ( empty($which_font) ) |
---|
3685 |
$which_font = $this->x_label_font; |
---|
3686 |
|
---|
3687 |
$which_angle = empty($which_angle)?'0':$this->x_label_angle; |
---|
3688 |
|
---|
3689 |
$which_color) ) |
---|
3690 |
$which_color = $this->ndx_title_color; |
---|
3691 |
|
---|
3692 |
$x_pixels = $this->xtr($x_world) + $x_adjustment; |
---|
3693 |
$y_pixels = $this->ytr($y_world) + $y_adjustment; |
---|
3694 |
|
---|
3695 |
$this->DrawText($which_font, $which_angle, $x_pixels, $y_pixels, |
---|
3696 |
$which_color, $data_label, $which_halign, $which_valign); |
---|
3697 |
|
---|
3698 |
TRUE; |
---|
3699 |
|
---|
3700 |
|
---|
3701 |
|
---|
3702 |
|
---|
3703 |
|
---|
3704 |
|
---|
3705 |
|
---|
3706 |
|
---|
3707 |
|
---|
3708 |
|
---|
3709 |
function DrawXDataLabel($xlab, $xpos, $row=FALSE) |
---|
3710 |
|
---|
3711 |
|
---|
3712 |
|
---|
3713 |
|
---|
3714 |
|
---|
3715 |
$xlab = $this->FormatLabel('x', $xlab); |
---|
3716 |
|
---|
3717 |
|
---|
3718 |
if ($this->x_data_label_pos == 'plotdown' || $this->x_data_label_pos == 'both') |
---|
3719 |
$this->DrawText($this->x_label_font, $this->x_label_angle, |
---|
3720 |
$xpos, $this->plot_area[3] + $this->x_label_bot_offset, |
---|
3721 |
$this->ndx_text_color, $xlab, 'center', 'top'); |
---|
3722 |
|
---|
3723 |
|
---|
3724 |
if ($this->x_data_label_pos == 'plotup' || $this->x_data_label_pos == 'both') |
---|
3725 |
$this->DrawText($this->x_label_font, $this->x_label_angle, |
---|
3726 |
$xpos, $this->plot_area[1] - $this->x_label_top_offset, |
---|
3727 |
$this->ndx_text_color, $xlab, 'center', 'bottom'); |
---|
3728 |
|
---|
3729 |
|
---|
3730 |
if ($row !== FALSE && $this->draw_x_data_label_lines) |
---|
3731 |
$this->DrawXDataLine($xpos, $row); |
---|
3732 |
TRUE; |
---|
3733 |
|
---|
3734 |
|
---|
3735 |
|
---|
3736 |
|
---|
3737 |
|
---|
3738 |
|
---|
3739 |
|
---|
3740 |
|
---|
3741 |
|
---|
3742 |
|
---|
3743 |
function DrawXDataLine($xpos, $row) |
---|
3744 |
|
---|
3745 |
|
---|
3746 |
if($this->dashed_grid) { |
---|
3747 |
$this->SetDashedStyle($this->ndx_light_grid_color); |
---|
3748 |
$style = IMG_COLOR_STYLED; |
---|
3749 |
|
---|
3750 |
$style = $this->ndx_light_grid_color; |
---|
3751 |
|
---|
3752 |
|
---|
3753 |
|
---|
3754 |
if ($this->x_data_label_pos == 'both') { |
---|
3755 |
ImageLine($this->img, $xpos, $this->plot_area[3], $xpos, $this->plot_area[1], $style); |
---|
3756 |
|
---|
3757 |
|
---|
3758 |
else if ($this->x_data_label_pos == 'plotdown') { |
---|
3759 |
$ypos = $this->ytr($this->data_maxy[$row]); |
---|
3760 |
ImageLine($this->img, $xpos, $ypos, $xpos, $this->plot_area[3], $style); |
---|
3761 |
|
---|
3762 |
|
---|
3763 |
else if ($this->x_data_label_pos == 'plotup') { |
---|
3764 |
$ypos = $this->ytr($this->data_miny[$row]); |
---|
3765 |
ImageLine($this->img, $xpos, $this->plot_area[1], $xpos, $ypos, $style); |
---|
3766 |
|
---|
3767 |
TRUE; |
---|
3768 |
|
---|
3769 |
|
---|
3770 |
|
---|
3771 |
|
---|
3772 |
|
---|
3773 |
|
---|
3774 |
|
---|
3775 |
|
---|
3776 |
function DrawLegend() |
---|
3777 |
|
---|
3778 |
|
---|
3779 |
$max_width = 0; |
---|
3780 |
$this->legend as $line) { |
---|
3781 |
$width, $unused) = $this->SizeText($this->legend_font, 0, $line); |
---|
3782 |
$width > $max_width) $max_width = $width; |
---|
3783 |
|
---|
3784 |
|
---|
3785 |
|
---|
3786 |
list($char_w, $char_h) = $this->SizeText($this->legend_font, 0, '8'); |
---|
3787 |
|
---|
3788 |
|
---|
3789 |
$text_align = isset($this->legend_text_align) ? $this->legend_text_align : 'right'; |
---|
3790 |
$colorbox_align = isset($this->legend_colorbox_align) ? $this->legend_colorbox_align : 'right'; |
---|
3791 |
|
---|
3792 |
|
---|
3793 |
$v_margin = $char_h/2; |
---|
3794 |
$dot_height = $char_h + $this->line_spacing; |
---|
3795 |
|
---|
3796 |
|
---|
3797 |
if ($colorbox_align != 'none') { |
---|
3798 |
$width = $max_width + 4 * $char_w; |
---|
3799 |
$draw_colorbox = True; |
---|
3800 |
|
---|
3801 |
$width = $max_width + 2 * $char_w; |
---|
3802 |
$draw_colorbox = False; |
---|
3803 |
|
---|
3804 |
|
---|
3805 |
|
---|
3806 |
|
---|
3807 |
if ( !isset($this->legend_x_pos) || !isset($this->legend_y_pos)) { |
---|
3808 |
|
---|
3809 |
$box_start_x = $this->plot_area[2] - $width - $this->safe_margin; |
---|
3810 |
$box_start_y = $this->plot_area[1] + $this->safe_margin; |
---|
3811 |
$this->legend_xy_world)) { |
---|
3812 |
|
---|
3813 |
$box_start_x = $this->xtr($this->legend_x_pos); |
---|
3814 |
$box_start_y = $this->ytr($this->legend_y_pos); |
---|
3815 |
$this->legend_xy_world); |
---|
3816 |
|
---|
3817 |
|
---|
3818 |
$box_start_x = $this->legend_x_pos; |
---|
3819 |
$box_start_y = $this->legend_y_pos; |
---|
3820 |
|
---|
3821 |
|
---|
3822 |
|
---|
3823 |
$box_end_y = $box_start_y + $dot_height*(count($this->legend)) + 2*$v_margin; |
---|
3824 |
$box_end_x = $box_start_x + $width; |
---|
3825 |
|
---|
3826 |
|
---|
3827 |
ImageFilledRectangle($this->img, $box_start_x, $box_start_y, $box_end_x, $box_end_y, $this->ndx_bg_color); |
---|
3828 |
ImageRectangle($this->img, $box_start_x, $box_start_y, $box_end_x, $box_end_y, $this->ndx_grid_color); |
---|
3829 |
|
---|
3830 |
$color_index = 0; |
---|
3831 |
$max_color_index = count($this->ndx_data_colors) - 1; |
---|
3832 |
|
---|
3833 |
|
---|
3834 |
if (!$draw_colorbox) { |
---|
3835 |
$text_align == 'left') |
---|
3836 |
$x_pos = $box_start_x + $char_w; |
---|
3837 |
|
---|
3838 |
$x_pos = $box_end_x - $char_w; |
---|
3839 |
$colorbox_align == 'left') { |
---|
3840 |
$dot_left_x = $box_start_x + $char_w; |
---|
3841 |
$dot_right_x = $dot_left_x + $char_w; |
---|
3842 |
$text_align == 'left') |
---|
3843 |
$x_pos = $dot_left_x + 2 * $char_w; |
---|
3844 |
|
---|
3845 |
$x_pos = $box_end_x - $char_w; |
---|
3846 |
|
---|
3847 |
$dot_left_x = $box_end_x - 2 * $char_w; |
---|
3848 |
$dot_right_x = $dot_left_x + $char_w; |
---|
3849 |
$text_align == 'left') |
---|
3850 |
$x_pos = $box_start_x + $char_w; |
---|
3851 |
|
---|
3852 |
$x_pos = $dot_left_x - $char_w; |
---|
3853 |
|
---|
3854 |
|
---|
3855 |
|
---|
3856 |
|
---|
3857 |
$y_pos = $box_start_y + $v_margin + $dot_height; |
---|
3858 |
|
---|
3859 |
$this->legend as $leg) { |
---|
3860 |
|
---|
3861 |
$this->DrawText($this->legend_font, 0, $x_pos, $y_pos, |
---|
3862 |
$this->ndx_text_color, $leg, $text_align, 'bottom'); |
---|
3863 |
$draw_colorbox) { |
---|
3864 |
|
---|
3865 |
$y1 = $y_pos - $dot_height + 1; |
---|
3866 |
$y2 = $y_pos - 1; |
---|
3867 |
ImageFilledRectangle($this->img, $dot_left_x, $y1, $dot_right_x, $y2, |
---|
3868 |
$this->ndx_data_colors[$color_index]); |
---|
3869 |
|
---|
3870 |
ImageRectangle($this->img, $dot_left_x, $y1, $dot_right_x, $y2, |
---|
3871 |
$this->ndx_text_color); |
---|
3872 |
|
---|
3873 |
$y_pos += $dot_height; |
---|
3874 |
|
---|
3875 |
$color_index++; |
---|
3876 |
$color_index > $max_color_index) |
---|
3877 |
$color_index = 0; |
---|
3878 |
|
---|
3879 |
TRUE; |
---|
3880 |
|
---|
3881 |
|
---|
3882 |
|
---|
3883 |
|
---|
3884 |
|
---|
3885 |
|
---|
3886 |
function DrawAxisLegend() |
---|
3887 |
|
---|
3888 |
|
---|
3889 |
|
---|
3890 |
|
---|
3891 |
|
---|
3892 |
} |
---|
3893 |
|
---|
3894 |
|
---|
3895 |
|
---|
3896 |
|
---|
3897 |
|
---|
3898 |
|
---|
3899 |
|
---|
3900 |
|
---|
3901 |
|
---|
3902 |
|
---|
3903 |
|
---|
3904 |
|
---|
3905 |
|
---|
3906 |
|
---|
3907 |
|
---|
3908 |
|
---|
3909 |
function DrawPieChart() |
---|
3910 |
|
---|
3911 |
$xpos = $this->plot_area[0] + $this->plot_area_width/2; |
---|
3912 |
$ypos = $this->plot_area[1] + $this->plot_area_height/2; |
---|
3913 |
$diameter = min($this->plot_area_width, $this->plot_area_height); |
---|
3914 |
$radius = $diameter/2; |
---|
3915 |
|
---|
3916 |
|
---|
3917 |
if ($this->data_type === 'text-data') { |
---|
3918 |
$i = 0; $i < $this->num_data_rows; $i++) { |
---|
3919 |
$j = 1; $j < $this->num_recs[$i]; $j++) { |
---|
3920 |
@ $sumarr[$j] += abs($this->data[$i][$j]); |
---|
3921 |
} |
---|
3922 |
|
---|
3923 |
|
---|
3924 |
|
---|
3925 |
else if ($this->data_type == 'text-data-single') { |
---|
3926 |
$i = 0; $i < $this->num_data_rows; $i++) { |
---|
3927 |
$legend[$i] = $this->data[$i][0]; |
---|
3928 |
$sumarr[$i] = $this->data[$i][1]; |
---|
3929 |
|
---|
3930 |
|
---|
3931 |
$this->data_type == 'data-data') { |
---|
3932 |
$i = 0; $i < $this->num_data_rows; $i++) { |
---|
3933 |
$j = 2; $j < $this->num_recs[$i]; $j++) { |
---|
3934 |
$sumarr[$j] += abs($this->data[$i][$j]); |
---|
3935 |
|
---|
3936 |
|
---|
3937 |
|
---|
3938 |
|
---|
3939 |
$this->PrintError("DrawPieChart(): Data type '$this->data_type' not supported."); |
---|
3940 |
|
---|
3941 |
|
---|
3942 |
$total = array_sum($sumarr); |
---|
3943 |
|
---|
3944 |
$total == 0) { |
---|
3945 |
$this->PrintError('DrawPieChart(): Empty data set'); |
---|
3946 |
|
---|
3947 |
|
---|
3948 |
$this->shading) { |
---|
3949 |
$diam2 = $diameter / 2; |
---|
3950 |
|
---|
3951 |
$diam2 = $diameter; |
---|
3952 |
|
---|
3953 |
$max_data_colors = count ($this->data_colors); |
---|
3954 |
|
---|
3955 |
$h = $this->shading; $h >= 0; $h--) { |
---|
3956 |
$color_index = 0; |
---|
3957 |
$start_angle = 0; |
---|
3958 |
$end_angle = 0; |
---|
3959 |
$sumarr as $val) { |
---|
3960 |
|
---|
3961 |
if ($h == 0) |
---|
3962 |
$slicecol = $this->ndx_data_colors[$color_index]; |
---|
3963 |
|
---|
3964 |
$slicecol = $this->ndx_data_dark_colors[$color_index]; |
---|
3965 |
|
---|
3966 |
$label_txt = $this->number_format(($val / $total * 100), $this->y_precision) . '%'; |
---|
3967 |
$val = 360 * ($val / $total); |
---|
3968 |
|
---|
3969 |
|
---|
3970 |
|
---|
3971 |
|
---|
3972 |
|
---|
3973 |
|
---|
3974 |
|
---|
3975 |
|
---|
3976 |
|
---|
3977 |
|
---|
3978 |
$start_angle = $end_angle; |
---|
3979 |
$end_angle += $val; |
---|
3980 |
|
---|
3981 |
|
---|
3982 |
$arc_start_angle = (int)(360 - $start_angle); |
---|
3983 |
$arc_end_angle = (int)(360 - $end_angle); |
---|
3984 |
|
---|
3985 |
$arc_start_angle > $arc_end_angle) { |
---|
3986 |
$mid_angle = deg2rad($end_angle - ($val / 2)); |
---|
3987 |
|
---|
3988 |
|
---|
3989 |
ImageFilledArc($this->img, $xpos, $ypos+$h, $diameter, $diam2, |
---|
3990 |
$arc_end_angle, $arc_start_angle, |
---|
3991 |
$slicecol, IMG_ARC_PIE); |
---|
3992 |
|
---|
3993 |
|
---|
3994 |
if ($h == 0) { |
---|
3995 |
|
---|
3996 |
if (! $this->shading) |
---|
3997 |
ImageFilledArc($this->img, $xpos, $ypos+$h, $diameter, $diam2, |
---|
3998 |
$arc_end_angle, $arc_start_angle, |
---|
3999 |
$this->ndx_grid_color, IMG_ARC_PIE | IMG_ARC_EDGED |IMG_ARC_NOFILL); |
---|
4000 |
|
---|
4001 |
|
---|
4002 |
|
---|
4003 |
|
---|
4004 |
$label_x = $xpos + ($diameter * 1.2 * cos($mid_angle)) * $this->label_scale_position; |
---|
4005 |
$label_y = $ypos+$h - ($diam2 * 1.2 * sin($mid_angle)) * $this->label_scale_position; |
---|
4006 |
|
---|
4007 |
$this->DrawText($this->generic_font, 0, $label_x, $label_y, $this->ndx_grid_color, |
---|
4008 |
$label_txt, 'center', 'center'); |
---|
4009 |
|
---|
4010 |
|
---|
4011 |
$color_index >= $max_data_colors) |
---|
4012 |
$color_index = 0; |
---|
4013 |
|
---|
4014 |
} |
---|
4015 |
return TRUE; |
---|
4016 |
|
---|
4017 |
|
---|
4018 |
|
---|
4019 |
|
---|
4020 |
|
---|
4021 |
|
---|
4022 |
|
---|
4023 |
function DrawDotsError() |
---|
4024 |
|
---|
4025 |
$this->data_type != 'data-data-error') { |
---|
4026 |
$this->PrintError("DrawDotsError(): Data type '$this->data_type' not supported."); |
---|
4027 |
|
---|
4028 |
|
---|
4029 |
|
---|
4030 |
$do_labels = ($this->plot_type != 'linepoints'); |
---|
4031 |
|
---|
4032 |
$row = 0, $cnt = 0; $row < $this->num_data_rows; $row++) { |
---|
4033 |
$record = 1; |
---|
4034 |
|
---|
4035 |
$x_now = $this->data[$row][$record++]; |
---|
4036 |
|
---|
4037 |
$x_now_pixels = $this->xtr($x_now); |
---|
4038 |
|
---|
4039 |
|
---|
4040 |
if ($this->x_data_label_pos != 'none' && $do_labels) |
---|
4041 |
$this->DrawXDataLabel($this->data[$row][0], $x_now_pixels, $row); |
---|
4042 |
|
---|
4043 |
|
---|
4044 |
for ($idx = 0; $record < $this->num_recs[$row]; $idx++) { |
---|
4045 |
|
---|
4046 |
$y_now = $this->data[$row][$record++]; |
---|
4047 |
$this->DrawDot($x_now, $y_now, $idx, $this->ndx_data_colors[$idx]); |
---|
4048 |
|
---|
4049 |
|
---|
4050 |
$val = $this->data[$row][$record++]; |
---|
4051 |
$this->DrawYErrorBar($x_now, $y_now, $val, $this->error_bar_shape, |
---|
4052 |
$this->ndx_error_bar_colors[$idx]); |
---|
4053 |
|
---|
4054 |
$val = $this->data[$row][$record++]; |
---|
4055 |
$this->DrawYErrorBar($x_now, $y_now, -$val, $this->error_bar_shape, |
---|
4056 |
$this->ndx_error_bar_colors[$idx]); |
---|
4057 |
|
---|
4058 |
|
---|
4059 |
TRUE; |
---|
4060 |
|
---|
4061 |
|
---|
4062 |
|
---|
4063 |
|
---|
4064 |
|
---|
4065 |
|
---|
4066 |
|
---|
4067 |
|
---|
4068 |
function DrawDots() |
---|
4069 |
|
---|
4070 |
$this->CheckOption($this->data_type, 'text-data, data-data', __FUNCTION__)) |
---|
4071 |
FALSE; |
---|
4072 |
|
---|
4073 |
|
---|
4074 |
$do_labels = ($this->plot_type != 'linepoints'); |
---|
4075 |
|
---|
4076 |
$row = 0, $cnt = 0; $row < $this->num_data_rows; $row++) { |
---|
4077 |
$rec = 1; |
---|
4078 |
|
---|
4079 |
|
---|
4080 |
if ($this->data_type == 'data-data') |
---|
4081 |
$x_now = $this->data[$row][$rec++]; |
---|
4082 |
else |
---|
4083 |
$x_now = 0.5 + $cnt++; |
---|
4084 |
|
---|
4085 |
$x_now_pixels = $this->xtr($x_now); |
---|
4086 |
|
---|
4087 |
|
---|
4088 |
if ($this->x_data_label_pos != 'none' && $do_labels) |
---|
4089 |
$this->DrawXDataLabel($this->data[$row][0], $x_now_pixels, $row); |
---|
4090 |
|
---|
4091 |
|
---|
4092 |
for($idx = 0;$rec < $this->num_recs[$row]; $rec++, $idx++) { |
---|
4093 |
is_numeric($this->data[$row][$rec])) { |
---|
4094 |
$this->DrawDot($x_now, $this->data[$row][$rec], |
---|
4095 |
$idx, $this->ndx_data_colors[$idx]); |
---|
4096 |
|
---|
4097 |
|
---|
4098 |
|
---|
4099 |
TRUE; |
---|
4100 |
|
---|
4101 |
|
---|
4102 |
|
---|
4103 |
|
---|
4104 |
|
---|
4105 |
|
---|
4106 |
function DrawThinBarLines() |
---|
4107 |
|
---|
4108 |
$this->CheckOption($this->data_type, 'text-data, data-data', __FUNCTION__)) |
---|
4109 |
FALSE; |
---|
4110 |
|
---|
4111 |
$row = 0, $cnt = 0; $row < $this->num_data_rows; $row++) { |
---|
4112 |
$rec = 1; |
---|
4113 |
|
---|
4114 |
|
---|
4115 |
if ($this->data_type == 'data-data') |
---|
4116 |
$x_now = $this->data[$row][$rec++]; |
---|
4117 |
else |
---|
4118 |
$x_now = 0.5 + $cnt++; |
---|
4119 |
|
---|
4120 |
$x_now_pixels = $this->xtr($x_now); |
---|
4121 |
|
---|
4122 |
|
---|
4123 |
if ($this->x_data_label_pos != 'none') |
---|
4124 |
$this->DrawXDataLabel($this->data[$row][0], $x_now_pixels); |
---|
4125 |
|
---|
4126 |
|
---|
4127 |
for($idx = 0;$rec < $this->num_recs[$row]; $rec++, $idx++) { |
---|
4128 |
is_numeric($this->data[$row][$rec])) { |
---|
4129 |
ImageSetThickness($this->img, $this->line_widths[$idx]); |
---|
4130 |
|
---|
4131 |
ImageLine($this->img, $x_now_pixels, $this->x_axis_y_pixels, $x_now_pixels, |
---|
4132 |
$this->ytr($this->data[$row][$rec]), $this->ndx_data_colors[$idx]); |
---|
4133 |
|
---|
4134 |
|
---|
4135 |
|
---|
4136 |
|
---|
4137 |
ImageSetThickness($this->img, 1); |
---|
4138 |
TRUE; |
---|
4139 |
|
---|
4140 |
|
---|
4141 |
|
---|
4142 |
|
---|
4143 |
|
---|
4144 |
function DrawYErrorBar($x_world, $y_world, $error_height, $error_bar_type, $color) |
---|
4145 |
|
---|
4146 |
|
---|
4147 |
|
---|
4148 |
|
---|
4149 |
|
---|
4150 |
|
---|
4151 |
|
---|
4152 |
|
---|
4153 |
|
---|
4154 |
$x1 = $this->xtr($x_world); |
---|
4155 |
$y1 = $this->ytr($y_world); |
---|
4156 |
$y2 = $this->ytr($y_world+$error_height) ; |
---|
4157 |
|
---|
4158 |
ImageSetThickness($this->img, $this->error_bar_line_width); |
---|
4159 |
ImageLine($this->img, $x1, $y1 , $x1, $y2, $color); |
---|
4160 |
|
---|
4161 |
$error_bar_type) { |
---|
4162 |
'line': |
---|
4163 |
|
---|
4164 |
'tee': |
---|
4165 |
ImageLine($this->img, $x1-$this->error_bar_size, $y2, $x1+$this->error_bar_size, $y2, $color); |
---|
4166 |
|
---|
4167 |
|
---|
4168 |
ImageLine($this->img, $x1-$this->error_bar_size, $y2, $x1+$this->error_bar_size, $y2, $color); |
---|
4169 |
|
---|
4170 |
|
---|
4171 |
|
---|
4172 |
ImageSetThickness($this->img, 1); |
---|
4173 |
TRUE; |
---|
4174 |
|
---|
4175 |
|
---|
4176 |
|
---|
4177 |
|
---|
4178 |
|
---|
4179 |
|
---|
4180 |
|
---|
4181 |
function DrawDot($x_world, $y_world, $record, $color) |
---|
4182 |
|
---|
4183 |
|
---|
4184 |
$record = $record % count ($this->point_shapes); |
---|
4185 |
|
---|
4186 |
$half_point = $this->point_sizes[$record] / 2; |
---|
4187 |
|
---|
4188 |
$x_mid = $this->xtr($x_world); |
---|
4189 |
$y_mid = $this->ytr($y_world); |
---|
4190 |
|
---|
4191 |
$x1 = $x_mid - $half_point; |
---|
4192 |
$x2 = $x_mid + $half_point; |
---|
4193 |
$y1 = $y_mid - $half_point; |
---|
4194 |
$y2 = $y_mid + $half_point; |
---|
4195 |
|
---|
4196 |
$this->point_shapes[$record]) { |
---|
4197 |
'halfline': |
---|
4198 |
ImageLine($this->img, $x1, $y_mid, $x_mid, $y_mid, $color); |
---|
4199 |
|
---|
4200 |
'line': |
---|
4201 |
ImageLine($this->img, $x1, $y_mid, $x2, $y_mid, $color); |
---|
4202 |
|
---|
4203 |
'plus': |
---|
4204 |
ImageLine($this->img, $x1, $y_mid, $x2, $y_mid, $color); |
---|
4205 |
ImageLine($this->img, $x_mid, $y1, $x_mid, $y2, $color); |
---|
4206 |
|
---|
4207 |
'cross': |
---|
4208 |
ImageLine($this->img, $x1, $y1, $x2, $y2, $color); |
---|
4209 |
ImageLine($this->img, $x1, $y2, $x2, $y1, $color); |
---|
4210 |
|
---|
4211 |
'rect': |
---|
4212 |
ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $color); |
---|
4213 |
|
---|
4214 |
'circle': |
---|
4215 |
ImageArc($this->img, $x_mid, $y_mid, $this->point_sizes[$record], $this->point_sizes[$record], |
---|
4216 |
0, 360, $color); |
---|
4217 |
|
---|
4218 |
'dot': |
---|
4219 |
ImageFilledArc($this->img, $x_mid, $y_mid, $this->point_sizes[$record], |
---|
4220 |
$this->point_sizes[$record], 0, 360, $color, IMG_ARC_PIE); |
---|
4221 |
|
---|
4222 |
'diamond': |
---|
4223 |
$arrpoints = array( $x1, $y_mid, $x_mid, $y1, $x2, $y_mid, $x_mid, $y2); |
---|
4224 |
ImageFilledPolygon($this->img, $arrpoints, 4, $color); |
---|
4225 |
|
---|
4226 |
'triangle': |
---|
4227 |
$arrpoints = array( $x1, $y_mid, $x2, $y_mid, $x_mid, $y2); |
---|
4228 |
ImageFilledPolygon($this->img, $arrpoints, 3, $color); |
---|
4229 |
|
---|
4230 |
'trianglemid': |
---|
4231 |
$arrpoints = array( $x1, $y1, $x2, $y1, $x_mid, $y_mid); |
---|
4232 |
ImageFilledPolygon($this->img, $arrpoints, 3, $color); |
---|
4233 |
|
---|
4234 |
'none': |
---|
4235 |
|
---|
4236 |
|
---|
4237 |
ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $color); |
---|
4238 |
|
---|
4239 |
|
---|
4240 |
TRUE; |
---|
4241 |
|
---|
4242 |
|
---|
4243 |
|
---|
4244 |
|
---|
4245 |
|
---|
4246 |
|
---|
4247 |
|
---|
4248 |
|
---|
4249 |
|
---|
4250 |
|
---|
4251 |
|
---|
4252 |
|
---|
4253 |
|
---|
4254 |
function DrawArea() |
---|
4255 |
|
---|
4256 |
$incomplete_data_defaults_to_x_axis = FALSE; |
---|
4257 |
|
---|
4258 |
for ($row = 0, $cnt = 0; $row < $this->num_data_rows; $row++) { |
---|
4259 |
$rec = 1; |
---|
4260 |
|
---|
4261 |
if ($this->data_type == 'data-data') |
---|
4262 |
$x_now = $this->data[$row][$rec++]; |
---|
4263 |
else |
---|
4264 |
$x_now = 0.5 + $cnt++; |
---|
4265 |
|
---|
4266 |
$x_now_pixels = $this->xtr($x_now); |
---|
4267 |
|
---|
4268 |
|
---|
4269 |
if ($this->x_data_label_pos != 'none') |
---|
4270 |
$this->DrawXDataLabel($this->data[$row][0], $x_now_pixels); |
---|
4271 |
|
---|
4272 |
|
---|
4273 |
|
---|
4274 |
for($idx = 0; $rec < $this->num_recs[$row]; $rec++, $idx++) { |
---|
4275 |
is_numeric($this->data[$row][$rec])) { |
---|
4276 |
$y_now_pixels = $this->ytr($this->data[$row][$rec]); |
---|
4277 |
|
---|
4278 |
$posarr[$idx][] = $x_now_pixels; |
---|
4279 |
$posarr[$idx][] = $y_now_pixels; |
---|
4280 |
|
---|
4281 |
$num_points[$idx] = isset($num_points[$idx]) ? $num_points[$idx]+1 : 1; |
---|
4282 |
|
---|
4283 |
|
---|
4284 |
else { |
---|
4285 |
$incomplete_data_defaults_to_x_axis)) { |
---|
4286 |
$posarr[$idx][] = $x_now_pixels; |
---|
4287 |
$posarr[$idx][] = $this->x_axis_y_pixels; |
---|
4288 |
$num_points[$idx] = isset($num_points[$idx]) ? $num_points[$idx]+1 : 1; |
---|
4289 |
|
---|
4290 |
|
---|
4291 |
|
---|
4292 |
|
---|
4293 |
|
---|
4294 |
$end = count($posarr); |
---|
4295 |
$i = 0; $i < $end; $i++) { |
---|
4296 |
|
---|
4297 |
$x = $posarr[$i][0]; |
---|
4298 |
array_unshift($posarr[$i], $x, $this->x_axis_y_pixels); |
---|
4299 |
|
---|
4300 |
|
---|
4301 |
$x = $posarr[$i][count($posarr[$i])-2]; |
---|
4302 |
array_push($posarr[$i], $x, $this->x_axis_y_pixels); |
---|
4303 |
|
---|
4304 |
$num_points[$i] += 2; |
---|
4305 |
|
---|
4306 |
|
---|
4307 |
ImageFilledPolygon($this->img, $posarr[$i], $num_points[$i], $this->ndx_data_colors[$i]); |
---|
4308 |
|
---|
4309 |
TRUE; |
---|
4310 |
|
---|
4311 |
|
---|
4312 |
|
---|
4313 |
|
---|
4314 |
|
---|
4315 |
|
---|
4316 |
|
---|
4317 |
|
---|
4318 |
|
---|
4319 |
function DrawLines() |
---|
4320 |
|
---|
4321 |
|
---|
4322 |
|
---|
4323 |
|
---|
4324 |
$start_lines = array_fill(0, $this->records_per_group, FALSE); |
---|
4325 |
|
---|
4326 |
$this->data_type == 'text-data') { |
---|
4327 |
$lastx[0] = $this->xtr(0); |
---|
4328 |
$lasty[0] = $this->xtr(0); |
---|
4329 |
|
---|
4330 |
|
---|
4331 |
$row = 0, $cnt = 0; $row < $this->num_data_rows; $row++) { |
---|
4332 |
$record = 1; |
---|
4333 |
|
---|
4334 |
if ($this->data_type == 'data-data') |
---|
4335 |
$x_now = $this->data[$row][$record++]; |
---|
4336 |
else |
---|
4337 |
$x_now = 0.5 + $cnt++; |
---|
4338 |
|
---|
4339 |
$x_now_pixels = $this->xtr($x_now); |
---|
4340 |
|
---|
4341 |
if ($this->x_data_label_pos != 'none') |
---|
4342 |
$this->DrawXDataLabel($this->data[$row][0], $x_now_pixels, $row); |
---|
4343 |
|
---|
4344 |
$idx = 0; $record < $this->num_recs[$row]; $record++, $idx++) { |
---|
4345 |
$line_style = $this->line_styles[$idx]) == 'none') |
---|
4346 |
|
---|
4347 |
if (is_numeric($this->data[$row][$record])) { |
---|
4348 |
$y_now_pixels = $this->ytr($this->data[$row][$record]); |
---|
4349 |
|
---|
4350 |
$start_lines[$idx] == TRUE) { |
---|
4351 |
|
---|
4352 |
ImageSetThickness($this->img, $this->line_widths[$idx]); |
---|
4353 |
|
---|
4354 |
$line_style == 'dashed') { |
---|
4355 |
$this->SetDashedStyle($this->ndx_data_colors[$idx]); |
---|
4356 |
ImageLine($this->img, $x_now_pixels, $y_now_pixels, $lastx[$idx], $lasty[$idx], |
---|
4357 |
IMG_COLOR_STYLED); |
---|
4358 |
|
---|
4359 |
ImageLine($this->img, $x_now_pixels, $y_now_pixels, $lastx[$idx], $lasty[$idx], |
---|
4360 |
$this->ndx_data_colors[$idx]); |
---|
4361 |
|
---|
4362 |
|
---|
4363 |
|
---|
4364 |
$lasty[$idx] = $y_now_pixels; |
---|
4365 |
$lastx[$idx] = $x_now_pixels; |
---|
4366 |
$start_lines[$idx] = TRUE; |
---|
4367 |
|
---|
4368 |
|
---|
4369 |
else if ($this->draw_broken_lines) { |
---|
4370 |
$start_lines[$idx] = FALSE; |
---|
4371 |
|
---|
4372 |
|
---|
4373 |
} |
---|
4374 |
|
---|
4375 |
ImageSetThickness($this->img, 1); |
---|
4376 |
return TRUE; |
---|
4377 |
|
---|
4378 |
|
---|
4379 |
|
---|
4380 |
|
---|
4381 |
|
---|
4382 |
|
---|
4383 |
|
---|
4384 |
function DrawLinesError() |
---|
4385 |
|
---|
4386 |
$this->data_type != 'data-data-error') { |
---|
4387 |
$this->PrintError("DrawLinesError(): Data type '$this->data_type' not supported."); |
---|
4388 |
|
---|
4389 |
|
---|
4390 |
$start_lines = array_fill(0, $this->records_per_group, FALSE); |
---|
4391 |
|
---|
4392 |
$row = 0, $cnt = 0; $row < $this->num_data_rows; $row++) { |
---|
4393 |
$record = 1; |
---|
4394 |
|
---|
4395 |
$x_now = $this->data[$row][$record++]; |
---|
4396 |
|
---|
4397 |
$x_now_pixels = $this->xtr($x_now); |
---|
4398 |
|
---|
4399 |
|
---|
4400 |
if ($this->x_data_label_pos != 'none') |
---|
4401 |
$this->DrawXDataLabel($this->data[$row][0], $x_now_pixels, $row); |
---|
4402 |
|
---|
4403 |
|
---|
4404 |
for ($idx = 0; $record < $this->num_recs[$row]; $idx++) { |
---|
4405 |
$line_style = $this->line_styles[$idx]) == 'none') |
---|
4406 |
|
---|
4407 |
|
---|
4408 |
$y_now = $this->data[$row][$record++]; |
---|
4409 |
$y_now_pixels = $this->ytr($y_now); |
---|
4410 |
|
---|
4411 |
$start_lines[$idx] == TRUE) { |
---|
4412 |
ImageSetThickness($this->img, $this->line_widths[$idx]); |
---|
4413 |
|
---|
4414 |
$line_style == 'dashed') { |
---|
4415 |
$this->SetDashedStyle($this->ndx_data_colors[$idx]); |
---|
4416 |
ImageLine($this->img, $x_now_pixels, $y_now_pixels, $lastx[$idx], $lasty[$idx], |
---|
4417 |
IMG_COLOR_STYLED); |
---|
4418 |
|
---|
4419 |
ImageLine($this->img, $x_now_pixels, $y_now_pixels, $lastx[$idx], $lasty[$idx], |
---|
4420 |
$this->ndx_data_colors[$idx]); |
---|
4421 |
|
---|
4422 |
|
---|
4423 |
|
---|
4424 |
|
---|
4425 |
$val = $this->data[$row][$record++]; |
---|
4426 |
$this->DrawYErrorBar($x_now, $y_now, $val, $this->error_bar_shape, |
---|
4427 |
$this->ndx_error_bar_colors[$idx]); |
---|
4428 |
|
---|
4429 |
|
---|
4430 |
$val = $this->data[$row][$record++]; |
---|
4431 |
$this->DrawYErrorBar($x_now, $y_now, -$val, $this->error_bar_shape, |
---|
4432 |
$this->ndx_error_bar_colors[$idx]); |
---|
4433 |
|
---|
4434 |
|
---|
4435 |
$start_lines[$idx] = TRUE; |
---|
4436 |
|
---|
4437 |
$lastx[$idx] = $x_now_pixels; |
---|
4438 |
$lasty[$idx] = $y_now_pixels; |
---|
4439 |
|
---|
4440 |
} |
---|
4441 |
|
---|
4442 |
ImageSetThickness($this->img, 1); |
---|
4443 |
return TRUE; |
---|
4444 |
|
---|
4445 |
|
---|
4446 |
|
---|
4447 |
|
---|
4448 |
|
---|
4449 |
|
---|
4450 |
|
---|
4451 |
function DrawSquared() |
---|
4452 |
|
---|
4453 |
|
---|
4454 |
|
---|
4455 |
|
---|
4456 |
$start_lines = array_fill(0, $this->records_per_group, FALSE); |
---|
4457 |
|
---|
4458 |
$this->data_type == 'text-data') { |
---|
4459 |
$lastx[0] = $this->xtr(0); |
---|
4460 |
$lasty[0] = $this->xtr(0); |
---|
4461 |
|
---|
4462 |
|
---|
4463 |
$row = 0, $cnt = 0; $row < $this->num_data_rows; $row++) { |
---|
4464 |
$record = 1; |
---|
4465 |
|
---|
4466 |
if ($this->data_type == 'data-data') |
---|
4467 |
$x_now = $this->data[$row][$record++]; |
---|
4468 |
else |
---|
4469 |
$x_now = 0.5 + $cnt++; |
---|
4470 |
|
---|
4471 |
$x_now_pixels = $this->xtr($x_now); |
---|
4472 |
|
---|
4473 |
if ($this->x_data_label_pos != 'none') |
---|
4474 |
$this->DrawXDataLabel($this->data[$row][0], $x_now_pixels); |
---|
4475 |
|
---|
4476 |
|
---|
4477 |
for ($idx = 0; $record < $this->num_recs[$row]; $record++, $idx++) { |
---|
4478 |
is_numeric($this->data[$row][$record])) { |
---|
4479 |
$y_now_pixels = $this->ytr($this->data[$row][$record]); |
---|
4480 |
|
---|
4481 |
$start_lines[$idx] == TRUE) { |
---|
4482 |
|
---|
4483 |
ImageSetThickness($this->img, $this->line_widths[$idx]); |
---|
4484 |
|
---|
4485 |
$this->line_styles[$idx] == 'dashed') { |
---|
4486 |
$this->SetDashedStyle($this->ndx_data_colors[$idx]); |
---|
4487 |
ImageLine($this->img, $lastx[$idx], $lasty[$idx], $x_now_pixels, $lasty[$idx], |
---|
4488 |
IMG_COLOR_STYLED); |
---|
4489 |
ImageLine($this->img, $x_now_pixels, $lasty[$idx], $x_now_pixels, $y_now_pixels, |
---|
4490 |
IMG_COLOR_STYLED); |
---|
4491 |
|
---|
4492 |
ImageLine($this->img, $lastx[$idx], $lasty[$idx], $x_now_pixels, $lasty[$idx], |
---|
4493 |
$this->ndx_data_colors[$idx]); |
---|
4494 |
ImageLine($this->img, $x_now_pixels, $lasty[$idx], $x_now_pixels, $y_now_pixels, |
---|
4495 |
$this->ndx_data_colors[$idx]); |
---|
4496 |
|
---|
4497 |
|
---|
4498 |
$lastx[$idx] = $x_now_pixels; |
---|
4499 |
$lasty[$idx] = $y_now_pixels; |
---|
4500 |
$start_lines[$idx] = TRUE; |
---|
4501 |
|
---|
4502 |
|
---|
4503 |
else if ($this->draw_broken_lines) { |
---|
4504 |
$start_lines[$idx] = FALSE; |
---|
4505 |
|
---|
4506 |
|
---|
4507 |
|
---|
4508 |
|
---|
4509 |
ImageSetThickness($this->img, 1); |
---|
4510 |
TRUE; |
---|
4511 |
|
---|
4512 |
|
---|
4513 |
|
---|
4514 |
|
---|
4515 |
|
---|
4516 |
|
---|
4517 |
function DrawBars() |
---|
4518 |
|
---|
4519 |
$this->data_type != 'text-data') { |
---|
4520 |
$this->PrintError('DrawBars(): Bar plots must be text-data: use function SetDataType("text-data")'); |
---|
4521 |
|
---|
4522 |
|
---|
4523 |
|
---|
4524 |
|
---|
4525 |
$x_first_bar = (($this->records_per_group - 1) * $this->record_bar_width) / 2 - $this->bar_adjust_gap; |
---|
4526 |
|
---|
4527 |
$row = 0; $row < $this->num_data_rows; $row++) { |
---|
4528 |
$record = 1; |
---|
4529 |
|
---|
4530 |
$x_now_pixels = $this->xtr(0.5 + $row); |
---|
4531 |
|
---|
4532 |
if ($this->x_data_label_pos != 'none') |
---|
4533 |
$this->DrawXDataLabel($this->data[$row][0], $x_now_pixels); |
---|
4534 |
|
---|
4535 |
|
---|
4536 |
$x1 = $x_now_pixels - $x_first_bar; |
---|
4537 |
|
---|
4538 |
|
---|
4539 |
for ($idx = 0; $record < $this->num_recs[$row]; $record++, $idx++) { |
---|
4540 |
is_numeric($this->data[$row][$record])) { |
---|
4541 |
$x2 = $x1 + $this->actual_bar_width; |
---|
4542 |
|
---|
4543 |
$this->data[$row][$record] < $this->x_axis_position) { |
---|
4544 |
$y1 = $this->x_axis_y_pixels; |
---|
4545 |
$y2 = $this->ytr($this->data[$row][$record]); |
---|
4546 |
$upgoing_bar = False; |
---|
4547 |
|
---|
4548 |
$y1 = $this->ytr($this->data[$row][$record]); |
---|
4549 |
$y2 = $this->x_axis_y_pixels; |
---|
4550 |
$upgoing_bar = True; |
---|
4551 |
|
---|
4552 |
|
---|
4553 |
|
---|
4554 |
ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $this->ndx_data_colors[$idx]); |
---|
4555 |
|
---|
4556 |
$this->shading) { |
---|
4557 |
ImageFilledPolygon($this->img, array($x1, $y1, |
---|
4558 |
$x1 + $this->shading, $y1 - $this->shading, |
---|
4559 |
$x2 + $this->shading, $y1 - $this->shading, |
---|
4560 |
$x2 + $this->shading, $y2 - $this->shading, |
---|
4561 |
$x2, $y2, |
---|
4562 |
$x2, $y1), |
---|
4563 |
6, $this->ndx_data_dark_colors[$idx]); |
---|
4564 |
|
---|
4565 |
|
---|
4566 |
else { |
---|
4567 |
ImageRectangle($this->img, $x1, $y1, $x2,$y2, $this->ndx_data_border_colors[$idx]); |
---|
4568 |
|
---|
4569 |
|
---|
4570 |
|
---|
4571 |
if ( $this->y_data_label_pos == 'plotin') { |
---|
4572 |
$upgoing_bar) { |
---|
4573 |
$v_align = 'bottom'; |
---|
4574 |
$y_offset = -5 - $this->shading; |
---|
4575 |
|
---|
4576 |
$v_align = 'top'; |
---|
4577 |
$y_offset = 2; |
---|
4578 |
|
---|
4579 |
$this->DrawDataLabel($this->y_label_font, NULL, $row+0.5, $this->data[$row][$record], '', |
---|
4580 |
$this->data[$row][$record], 'center', $v_align, |
---|
4581 |
$idx + 0.5) * $this->record_bar_width - $x_first_bar, $y_offset); |
---|
4582 |
|
---|
4583 |
|
---|
4584 |
|
---|
4585 |
|
---|
4586 |
$x1 += $this->record_bar_width; |
---|
4587 |
|
---|
4588 |
} |
---|
4589 |
return TRUE; |
---|
4590 |
|
---|
4591 |
|
---|
4592 |
|
---|
4593 |
|
---|
4594 |
|
---|
4595 |
|
---|
4596 |
|
---|
4597 |
function DrawStackedBars() |
---|
4598 |
|
---|
4599 |
$this->data_type != 'text-data') { |
---|
4600 |
$this->PrintError('DrawStackedBars(): Bar plots must be text-data: use SetDataType("text-data")'); |
---|
4601 |
|
---|
4602 |
|
---|
4603 |
|
---|
4604 |
$x_first_bar = $this->record_bar_width / 2 - $this->bar_adjust_gap; |
---|
4605 |
|
---|
4606 |
$row = 0; $row < $this->num_data_rows; $row++) { |
---|
4607 |
$record = 1; |
---|
4608 |
|
---|
4609 |
$x_now_pixels = $this->xtr(0.5 + $row); |
---|
4610 |
|
---|
4611 |
if ($this->x_data_label_pos != 'none') |
---|
4612 |
$this->DrawXDataLabel($this->data[$row][0], $x_now_pixels); |
---|
4613 |
|
---|
4614 |
|
---|
4615 |
$x1 = $x_now_pixels - $x_first_bar; |
---|
4616 |
$x2 = $x1 + $this->actual_bar_width; |
---|
4617 |
|
---|
4618 |
|
---|
4619 |
$oldv = 0; |
---|
4620 |
$idx = 0; $record < $this->num_recs[$row]; $record++, $idx++) { |
---|
4621 |
is_numeric($this->data[$row][$record])) { |
---|
4622 |
|
---|
4623 |
$y1 = $this->ytr(abs($this->data[$row][$record]) + $oldv); |
---|
4624 |
$y2 = $this->ytr($this->x_axis_position + $oldv); |
---|
4625 |
$oldv += abs($this->data[$row][$record]); |
---|
4626 |
|
---|
4627 |
|
---|
4628 |
ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $this->ndx_data_colors[$idx]); |
---|
4629 |
|
---|
4630 |
$this->shading) { |
---|
4631 |
ImageFilledPolygon($this->img, array($x1, $y1, |
---|
4632 |
$x1 + $this->shading, $y1 - $this->shading, |
---|
4633 |
$x2 + $this->shading, $y1 - $this->shading, |
---|
4634 |
$x2 + $this->shading, $y2 - $this->shading, |
---|
4635 |
$x2, $y2, |
---|
4636 |
$x2, $y1), |
---|
4637 |
6, $this->ndx_data_dark_colors[$idx]); |
---|
4638 |
|
---|
4639 |
|
---|
4640 |
else { |
---|
4641 |
ImageRectangle($this->img, $x1, $y1, $x2,$y2, $this->ndx_data_border_colors[$idx]); |
---|
4642 |
|
---|
4643 |
|
---|
4644 |
|
---|
4645 |
} |
---|
4646 |
return TRUE; |
---|
4647 |
|
---|
4648 |
|
---|
4649 |
|
---|
4650 |
|
---|
4651 |
|
---|
4652 |
|
---|
4653 |
function DrawGraph() |
---|
4654 |
|
---|
4655 |
|
---|
4656 |
if (! $this->img) { |
---|
4657 |
$this->PrintError('DrawGraph(): No image resource allocated'); |
---|
4658 |
|
---|
4659 |
$this->data) || ! is_array($this->data)) { |
---|
4660 |
$this->PrintError("DrawGraph(): No data array"); |
---|
4661 |
|
---|
4662 |
$this->total_records == 0) { |
---|
4663 |
$this->PrintError('DrawGraph(): Empty data set'); |
---|
4664 |
|
---|
4665 |
|
---|
4666 |
|
---|
4667 |
|
---|
4668 |
$draw_axes = ($this->plot_type != 'pie'); |
---|
4669 |
|
---|
4670 |
|
---|
4671 |
if (!$this->FindDataLimits()) |
---|
4672 |
FALSE; |
---|
4673 |
|
---|
4674 |
|
---|
4675 |
if (!$this->CalcPlotAreaWorld()) |
---|
4676 |
FALSE; |
---|
4677 |
|
---|
4678 |
|
---|
4679 |
$this->CalcAxisPositions(); |
---|
4680 |
|
---|
4681 |
|
---|
4682 |
|
---|
4683 |
$this->CalcMargins(!$draw_axes); |
---|
4684 |
|
---|
4685 |
|
---|
4686 |
$this->CalcPlotAreaPixels(); |
---|
4687 |
|
---|
4688 |
|
---|
4689 |
$this->CalcTranslation(); |
---|
4690 |
|
---|
4691 |
|
---|
4692 |
$this->PadArrays(); |
---|
4693 |
$this->DoCallback('draw_setup'); |
---|
4694 |
|
---|
4695 |
$this->DrawBackground(); |
---|
4696 |
$this->DrawImageBorder(); |
---|
4697 |
$this->DoCallback('draw_image_background'); |
---|
4698 |
|
---|
4699 |
$this->DrawPlotAreaBackground(); |
---|
4700 |
$this->DoCallback('draw_plotarea_background'); |
---|
4701 |
|
---|
4702 |
$this->DrawTitle(); |
---|
4703 |
$this->DrawXTitle(); |
---|
4704 |
$this->DrawYTitle(); |
---|
4705 |
$this->DoCallback('draw_titles'); |
---|
4706 |
|
---|
4707 |
$draw_axes && ! $this->grid_at_foreground) { |
---|
4708 |
$this->DrawYAxis(); |
---|
4709 |
$this->DrawXAxis(); |
---|
4710 |
$this->DoCallback('draw_axes'); |
---|
4711 |
|
---|
4712 |
|
---|
4713 |
$this->plot_type) { |
---|
4714 |
'thinbarline': |
---|
4715 |
$this->DrawThinBarLines(); |
---|
4716 |
|
---|
4717 |
'area': |
---|
4718 |
$this->DrawArea(); |
---|
4719 |
|
---|
4720 |
'squared': |
---|
4721 |
$this->DrawSquared(); |
---|
4722 |
|
---|
4723 |
'lines': |
---|
4724 |
$this->data_type == 'data-data-error') { |
---|
4725 |
$this->DrawLinesError(); |
---|
4726 |
|
---|
4727 |
$this->DrawLines(); |
---|
4728 |
|
---|
4729 |
|
---|
4730 |
'linepoints': |
---|
4731 |
$this->data_type == 'data-data-error') { |
---|
4732 |
$this->DrawLinesError(); |
---|
4733 |
$this->DrawDotsError(); |
---|
4734 |
|
---|
4735 |
$this->DrawLines(); |
---|
4736 |
$this->DrawDots(); |
---|
4737 |
|
---|
4738 |
|
---|
4739 |
'points'; |
---|
4740 |
$this->data_type == 'data-data-error') { |
---|
4741 |
$this->DrawDotsError(); |
---|
4742 |
|
---|
4743 |
$this->DrawDots(); |
---|
4744 |
|
---|
4745 |
|
---|
4746 |
'pie': |
---|
4747 |
$this->DrawPieChart(); |
---|
4748 |
|
---|
4749 |
'stackedbars': |
---|
4750 |
$this->CalcBarWidths(); |
---|
4751 |
$this->DrawStackedBars(); |
---|
4752 |
|
---|
4753 |
'bars': |
---|
4754 |
|
---|
4755 |
$this->plot_type = 'bars'; |
---|
4756 |
$this->CalcBarWidths(); |
---|
4757 |
$this->DrawBars(); |
---|
4758 |
|
---|
4759 |
|
---|
4760 |
$this->DoCallback('draw_graph'); |
---|
4761 |
|
---|
4762 |
$draw_axes && $this->grid_at_foreground) { |
---|
4763 |
$this->DrawYAxis(); |
---|
4764 |
$this->DrawXAxis(); |
---|
4765 |
$this->DoCallback('draw_axes'); |
---|
4766 |
|
---|
4767 |
|
---|
4768 |
$draw_axes) { |
---|
4769 |
$this->DrawPlotBorder(); |
---|
4770 |
$this->DoCallback('draw_border'); |
---|
4771 |
|
---|
4772 |
|
---|
4773 |
$this->legend) { |
---|
4774 |
$this->DrawLegend(); |
---|
4775 |
$this->DoCallback('draw_legend'); |
---|
4776 |
|
---|
4777 |
|
---|
4778 |
$this->print_image && !$this->PrintImage()) |
---|
4779 |
FALSE; |
---|
4780 |
|
---|
4781 |
TRUE; |
---|
4782 |
|
---|
4783 |
|
---|
4784 |
|
---|
4785 |
|
---|
4786 |
|
---|
4787 |
|
---|
4788 |
|
---|
4789 |
|
---|
4790 |
|
---|
4791 |
function SetDrawVertTicks($which_dvt) |
---|
4792 |
|
---|
4793 |
$which_dvt != 1) |
---|
4794 |
$this->SetYTickPos('none'); |
---|
4795 |
TRUE; |
---|
4796 |
|
---|
4797 |
|
---|
4798 |
|
---|
4799 |
|
---|
4800 |
|
---|
4801 |
function SetDrawHorizTicks($which_dht) |
---|
4802 |
|
---|
4803 |
$which_dht != 1) |
---|
4804 |
$this->SetXTickPos('none'); |
---|
4805 |
TRUE; |
---|
4806 |
|
---|
4807 |
|
---|
4808 |
|
---|
4809 |
|
---|
4810 |
|
---|
4811 |
function SetNumHorizTicks($n) |
---|
4812 |
|
---|
4813 |
$this->SetNumXTicks($n); |
---|
4814 |
|
---|
4815 |
|
---|
4816 |
|
---|
4817 |
|
---|
4818 |
|
---|
4819 |
function SetNumVertTicks($n) |
---|
4820 |
|
---|
4821 |
$this->SetNumYTicks($n); |
---|
4822 |
|
---|
4823 |
|
---|
4824 |
|
---|
4825 |
|
---|
4826 |
|
---|
4827 |
function SetHorizTickIncrement($inc) |
---|
4828 |
|
---|
4829 |
$this->SetXTickIncrement($inc); |
---|
4830 |
|
---|
4831 |
|
---|
4832 |
|
---|
4833 |
|
---|
4834 |
|
---|
4835 |
|
---|
4836 |
function SetVertTickIncrement($inc) |
---|
4837 |
|
---|
4838 |
$this->SetYTickIncrement($inc); |
---|
4839 |
|
---|
4840 |
|
---|
4841 |
|
---|
4842 |
|
---|
4843 |
|
---|
4844 |
function SetVertTickPosition($which_tp) |
---|
4845 |
|
---|
4846 |
$this->SetYTickPos($which_tp); |
---|
4847 |
|
---|
4848 |
|
---|
4849 |
|
---|
4850 |
|
---|
4851 |
|
---|
4852 |
function SetHorizTickPosition($which_tp) |
---|
4853 |
|
---|
4854 |
$this->SetXTickPos($which_tp); |
---|
4855 |
|
---|
4856 |
|
---|
4857 |
|
---|
4858 |
|
---|
4859 |
|
---|
4860 |
function SetTitleFontSize($which_size) |
---|
4861 |
|
---|
4862 |
$this->SetFont('title', $which_size); |
---|
4863 |
|
---|
4864 |
|
---|
4865 |
|
---|
4866 |
|
---|
4867 |
|
---|
4868 |
function SetAxisFontSize($which_size) |
---|
4869 |
|
---|
4870 |
$this->SetFont('x_label', $which_size); |
---|
4871 |
$this->SetFont('y_label', $which_size); |
---|
4872 |
|
---|
4873 |
|
---|
4874 |
|
---|
4875 |
|
---|
4876 |
|
---|
4877 |
function SetSmallFontSize($which_size) |
---|
4878 |
|
---|
4879 |
$this->SetFont('generic', $which_size); |
---|
4880 |
|
---|
4881 |
|
---|
4882 |
|
---|
4883 |
|
---|
4884 |
|
---|
4885 |
function SetXLabelFontSize($which_size) |
---|
4886 |
|
---|
4887 |
$this->SetFont('x_title', $which_size); |
---|
4888 |
|
---|
4889 |
|
---|
4890 |
|
---|
4891 |
|
---|
4892 |
|
---|
4893 |
function SetYLabelFontSize($which_size) |
---|
4894 |
|
---|
4895 |
$this->SetFont('y_title', $which_size); |
---|
4896 |
|
---|
4897 |
|
---|
4898 |
|
---|
4899 |
|
---|
4900 |
|
---|
4901 |
function SetXLabel($which_xlab) |
---|
4902 |
|
---|
4903 |
$this->SetXTitle($which_xlab); |
---|
4904 |
|
---|
4905 |
|
---|
4906 |
|
---|
4907 |
|
---|
4908 |
|
---|
4909 |
function SetYLabel($which_ylab) |
---|
4910 |
|
---|
4911 |
$this->SetYTitle($which_ylab); |
---|
4912 |
|
---|
4913 |
|
---|
4914 |
|
---|
4915 |
|
---|
4916 |
|
---|
4917 |
function SetTickLength($which_tl) |
---|
4918 |
|
---|
4919 |
$this->SetXTickLength($which_tl); |
---|
4920 |
$this->SetYTickLength($which_tl); |
---|
4921 |
TRUE; |
---|
4922 |
|
---|
4923 |
|
---|
4924 |
|
---|
4925 |
|
---|
4926 |
|
---|
4927 |
function SetYGridLabelType($which_yglt) |
---|
4928 |
|
---|
4929 |
$this->SetYLabelType($which_yglt); |
---|
4930 |
|
---|
4931 |
|
---|
4932 |
|
---|
4933 |
|
---|
4934 |
|
---|
4935 |
function SetXGridLabelType($which_xglt) |
---|
4936 |
|
---|
4937 |
$this->SetXLabelType($which_xglt); |
---|
4938 |
|
---|
4939 |
|
---|
4940 |
|
---|
4941 |
|
---|
4942 |
function SetYGridLabelPos($which_yglp) |
---|
4943 |
|
---|
4944 |
$this->SetYTickLabelPos($which_yglp); |
---|
4945 |
|
---|
4946 |
|
---|
4947 |
|
---|
4948 |
|
---|
4949 |
function SetXGridLabelPos($which_xglp) |
---|
4950 |
|
---|
4951 |
$this->SetXTickLabelPos($which_xglp); |
---|
4952 |
|
---|
4953 |
|
---|
4954 |
|
---|
4955 |
|
---|
4956 |
|
---|
4957 |
|
---|
4958 |
function SetXTitlePos($xpos) |
---|
4959 |
|
---|
4960 |
$this->x_title_pos = $xpos; |
---|
4961 |
TRUE; |
---|
4962 |
|
---|
4963 |
|
---|
4964 |
|
---|
4965 |
|
---|
4966 |
|
---|
4967 |
function SetYTitlePos($xpos) |
---|
4968 |
|
---|
4969 |
$this->y_title_pos = $xpos; |
---|
4970 |
TRUE; |
---|
4971 |
|
---|
4972 |
|
---|
4973 |
|
---|
4974 |
|
---|
4975 |
|
---|
4976 |
function SetXDataLabelAngle($which_xdla) |
---|
4977 |
|
---|
4978 |
$this->SetXLabelAngle($which_xdla); |
---|
4979 |
|
---|
4980 |
|
---|
4981 |
|
---|
4982 |
|
---|
4983 |
|
---|
4984 |
|
---|
4985 |
|
---|
4986 |
|
---|
4987 |
function SetDrawXDataLabels($which_dxdl) |
---|
4988 |
|
---|
4989 |
$which_dxdl == '1' ) |
---|
4990 |
$this->SetXDataLabelPos('plotdown'); |
---|
4991 |
|
---|
4992 |
$this->SetXDataLabelPos('none'); |
---|
4993 |
|
---|
4994 |
|
---|
4995 |
|
---|
4996 |
|
---|
4997 |
|
---|
4998 |
function SetNewPlotAreaPixels($x1, $y1, $x2, $y2) |
---|
4999 |
|
---|
5000 |
|
---|
5001 |
$this->plot_area = array($x1, $y1, $x2, $y2); |
---|
5002 |
$this->plot_area_width = $this->plot_area[2] - $this->plot_area[0]; |
---|
5003 |
$this->plot_area_height = $this->plot_area[3] - $this->plot_area[1]; |
---|
5004 |
$this->y_top_margin = $this->plot_area[1]; |
---|
5005 |
|
---|
5006 |
$this->plot_max_x)) |
---|
5007 |
$this->CalcTranslation(); |
---|
5008 |
|
---|
5009 |
TRUE; |
---|
5010 |
|
---|
5011 |
|
---|
5012 |
|
---|
5013 |
|
---|
5014 |
|
---|
5015 |
function SetColor($which_color) |
---|
5016 |
|
---|
5017 |
$this->SetRGBColor($which_color); |
---|
5018 |
TRUE; |
---|
5019 |
|
---|
5020 |
|
---|
5021 |
|
---|
5022 |
|
---|
5023 |
|
---|
5024 |
function SetLineWidth($which_lw) |
---|
5025 |
|
---|
5026 |
|
---|
5027 |
$this->SetLineWidths($which_lw); |
---|
5028 |
|
---|
5029 |
$this->error_bar_line_width) { |
---|
5030 |
$this->SetErrorBarLineWidth($which_lw); |
---|
5031 |
|
---|
5032 |
TRUE; |
---|
5033 |
|
---|
5034 |
|
---|
5035 |
|
---|
5036 |
|
---|
5037 |
|
---|
5038 |
function SetPointShape($which_pt) |
---|
5039 |
|
---|
5040 |
$this->SetPointShapes($which_pt); |
---|
5041 |
TRUE; |
---|
5042 |
|
---|
5043 |
|
---|
5044 |
|
---|
5045 |
|
---|
5046 |
|
---|
5047 |
function SetPointSize($which_ps) |
---|
5048 |
|
---|
5049 |
$this->SetPointSizes($which_ps); |
---|
5050 |
TRUE; |
---|
5051 |
|
---|
5052 |
|
---|
5053 |
|
---|