PEEL Shopping
Open source ecommerce : PEEL Shopping
open-flash-chart.php
Go to the documentation of this file.
1 <?php
2 // This file should be in UTF8 without BOM - Accents examples: éèê
3 // +----------------------------------------------------------------------+
4 // | Copyright (c) 2004-2015 Advisto SAS, service PEEL - contact@peel.fr |
5 // +----------------------------------------------------------------------+
6 // | This file is part of PEEL Shopping 8.0.0, which is subject to an |
7 // | opensource GPL license: you are allowed to customize the code |
8 // | for your own needs, but must keep your changes under GPL |
9 // | More information: https://www.peel.fr/lire/licence-gpl-70.html |
10 // +----------------------------------------------------------------------+
11 // | Author: Advisto SAS, RCS 479 205 452, France, https://www.peel.fr/ |
12 // +----------------------------------------------------------------------+
13 // $Id: open-flash-chart.php 46935 2015-09-18 08:49:48Z gboussin $
14 
15 if (!defined('IN_PEEL')) {
16  die();
17 }
18 
28 class graph
29 {
34  function graph()
35  {
36  $this->data_sets = array();
37 
38 
39  $this->data = array();
40  $this->links = array();
41  $this->width = 250;
42  $this->height = 200;
43  $this->js_path = $GLOBALS['wwwroot'].'/lib/js/';
44  $this->swf_path = '';
45  $this->x_labels = array();
46  $this->y_min = '';
47  $this->y_max = '';
48  $this->x_min = '';
49  $this->x_max = '';
50  $this->y_steps = '';
51  $this->title = '';
52  $this->title_style = '';
53  $this->occurence = 0;
54 
55  $this->x_offset = '';
56 
57  $this->x_tick_size = -1;
58 
59  $this->y2_max = '';
60  $this->y2_min = '';
61 
62  // GRID styles:
63  $this->x_axis_colour = '';
64  $this->x_axis_3d = '';
65  $this->x_grid_colour = '';
66  $this->x_axis_steps = 1;
67  $this->y_axis_colour = '';
68  $this->y_grid_colour = '';
69  $this->y2_axis_colour = '';
70 
71  // AXIS LABEL styles:
72  $this->x_label_style = '';
73  $this->y_label_style = '';
74  $this->y_label_style_right = '';
75 
76 
77  // AXIS LEGEND styles:
78  $this->x_legend = '';
79  $this->x_legend_size = 20;
80  $this->x_legend_colour = '#000000';
81 
82  $this->y_legend = '';
83  $this->y_legend_right = '';
84  //$this->y_legend_size = 20;
85  //$this->y_legend_colour = '#000000';
86 
87  $this->lines = array();
88  $this->line_default['type'] = 'line';
89  $this->line_default['values'] = '3,#87421F';
90  $this->js_line_default = 'so.addVariable("line","3,#87421F");';
91 
92  $this->bg_colour = '#FBFAFB';
93  $this->bg_image = '';
94 
95  $this->inner_bg_colour = '';
96  $this->inner_bg_colour_2 = '';
97  $this->inner_bg_angle = '';
98 
99  // PIE chart ------------
100  $this->pie = '';
101  $this->pie_values = '';
102  $this->pie_colours = '';
103  $this->pie_labels = '';
104  $this->pie_links = '';
105 
106  $this->tool_tip = '';
107 
108  // which data lines are attached to the
109  // right Y axis?
110  $this->y2_lines = array();
111 
112  // Number formatting:
113  $this->y_format='';
114  $this->num_decimals='';
115  $this->is_fixed_num_decimals_forced='';
116  $this->is_decimal_separator_comma='';
117  $this->is_thousand_separator_disabled='';
118 
119  $this->output_type = '';
120 
121  //
122  // set some default value incase the user forgets
123  // to set them, so at least they see *something*
124  // even is it is only the axis and some ticks
125  //
126  $this->set_y_min( 0 );
127  $this->set_y_max( 20 );
128  $this->set_x_axis_steps( 1 );
129  $this->y_label_steps( 5 );
130  }
131 
135  function set_unique_id()
136  {
137  $this->unique_id = uniqid(mt_rand(), true);
138  }
139 
143  function get_unique_id()
144  {
145  return ($this->unique_id);
146  }
147 
154  function set_js_path($path)
155  {
156  $this->js_path = $path;
157  }
158 
165  function set_swf_path($path)
166  {
167  $this->swf_path = $path;
168  }
169 
176  function set_output_type($type)
177  {
178  $this->output_type = $type;
179  }
180 
184  function next_line()
185  {
186  $line_num = '';
187  if( count( $this->lines ) > 0 )
188  $line_num = '_'. (count( $this->lines )+1);
189 
190  return $line_num;
191  }
192 
193  // escape commas (,)
194  function esc( $text )
195  {
196  // we replace the comma so it is not URL escaped
197  // if it is, flash just thinks it is a comma
198  // which is no good if we are splitting the
199  // string on commas.
200  $tmp = str_replace( ',', '#comma#', $text );
201  // now we urlescape all dodgy characters (like & % $ etc..)
202  return urlencode( $tmp );
203  }
204 
208  function format_output($function,$values)
209  {
210  if($this->output_type == 'js')
211  {
212  $tmp = 'so.addVariable("'. $function .'","'. $values . '");';
213  }
214  else
215  {
216  $tmp = '&'. $function .'='. $values .'&';
217  }
218 
219  return $tmp;
220  }
221 
230  function set_title( $title, $style='' )
231  {
232  $this->title = $this->esc( $title );
233  if( strlen( $style ) > 0 )
234  $this->title_style = $style;
235  }
236 
243  function set_width( $width )
244  {
245  $this->width = $width;
246  }
247 
254  function set_height( $height )
255  {
256  $this->height = $height;
257  }
258 
265  function set_base( $base='js/' )
266  {
267  $this->base = $base;
268  }
269 
270  // Number formatting:
271  function set_y_format( $val )
272  {
273  $this->y_format = $val;
274  }
275 
276  function set_num_decimals( $val )
277  {
278  $this->num_decimals = $val;
279  }
280 
282  {
283  $this->is_fixed_num_decimals_forced = $val?'true':'false';
284  }
285 
287  {
288  $this->is_decimal_separator_comma = $val?'true':'false';
289  }
290 
292  {
293  $this->is_thousand_separator_disabled = $val?'true':'false';
294  }
295 
301  function set_data( $a )
302  {
303  $this->data[] = implode(',',$a);
304  }
305 
306  // UGH, these evil functions are making me fell ill
307  function set_links( $links )
308  {
309  // TO DO escape commas:
310  $this->links[] = implode(',',$links);
311  }
312 
313  // $val is a boolean
314  function set_x_offset( $val )
315  {
316  $this->x_offset = $val?'true':'false';
317  }
318 
333  function set_tool_tip( $tip )
334  {
335  $this->tool_tip = $this->esc( $tip );
336  }
337 
344  function set_x_labels( $a )
345  {
346  $tmp = array();
347  foreach( $a as $item )
348  $tmp[] = $this->esc( $item );
349  $this->x_labels = $tmp;
350  }
351 
368  function set_x_label_style( $size, $colour='', $orientation=0, $step=-1, $grid_colour='' )
369  {
370  $this->x_label_style = $size;
371 
372  if( strlen( $colour ) > 0 )
373  $this->x_label_style .= ','. $colour;
374 
375  if( $orientation > -1 )
376  $this->x_label_style .= ','. $orientation;
377 
378  if( $step > 0 )
379  $this->x_label_style .= ','. $step;
380 
381  if( strlen( $grid_colour ) > 0 )
382  $this->x_label_style .= ','. $grid_colour;
383  }
384 
390  function set_bg_colour( $colour )
391  {
392  $this->bg_colour = $colour;
393  }
394 
404  function set_bg_image( $url, $x='center', $y='center' )
405  {
406  $this->bg_image = $url;
407  $this->bg_image_x = $x;
408  $this->bg_image_y = $y;
409  }
410 
416  function attach_to_y_right_axis( $data_number )
417  {
418  $this->y2_lines[] = $data_number;
419  }
420 
430  function set_inner_background( $col, $col2='', $angle=-1 )
431  {
432  $this->inner_bg_colour = $col;
433 
434  if( strlen($col2) > 0 )
435  $this->inner_bg_colour_2 = $col2;
436 
437  if( $angle != -1 )
438  $this->inner_bg_angle = $angle;
439  }
440 
444  function _set_y_label_style( $size, $colour )
445  {
446  $tmp = $size;
447 
448  if( strlen( $colour ) > 0 )
449  $tmp .= ','. $colour;
450  return $tmp;
451  }
452 
461  function set_y_label_style( $size, $colour='' )
462  {
463  $this->y_label_style = $this->_set_y_label_style( $size, $colour );
464  }
465 
474  function set_y_right_label_style( $size, $colour='' )
475  {
476  $this->y_label_style_right = $this->_set_y_label_style( $size, $colour );
477  }
478 
479  function set_x_max( $max )
480  {
481  $this->x_max = floatval( $max );
482  }
483 
484  function set_x_min( $min )
485  {
486  $this->x_min = floatval( $min );
487  }
488 
495  function set_y_max( $max )
496  {
497  $this->y_max = floatval( $max );
498  }
499 
506  function set_y_min( $min )
507  {
508  $this->y_min = floatval( $min );
509  }
510 
517  function set_y_right_max( $max )
518  {
519  $this->y2_max = floatval($max);
520  }
521 
528  function set_y_right_min( $min )
529  {
530  $this->y2_min = floatval($min);
531  }
532 
539  function y_label_steps( $val )
540  {
541  $this->y_steps = intval( $val );
542  }
543 
544  function title( $title, $style='' )
545  {
546  $this->title = $this->esc( $title );
547  if( strlen( $style ) > 0 )
548  $this->title_style = $style;
549  }
550 
561  function set_x_legend( $text, $size=-1, $colour='' )
562  {
563  $this->x_legend = $this->esc( $text );
564  if( $size > -1 )
565  $this->x_legend_size = $size;
566 
567  if( strlen( $colour )>0 )
568  $this->x_legend_colour = $colour;
569  }
570 
577  function set_x_tick_size( $size )
578  {
579  if( $size > 0 )
580  $this->x_tick_size = $size;
581  }
582 
589  function set_x_axis_steps( $steps )
590  {
591  if ( $steps > 0 )
592  $this->x_axis_steps = $steps;
593  }
594 
601  function set_x_axis_3d( $size )
602  {
603  if( $size > 0 )
604  $this->x_axis_3d = intval($size);
605  }
606 
610  function _set_y_legend( $text, $size, $colour )
611  {
612  $tmp = $text;
613 
614  if( $size > -1 )
615  $tmp .= ','. $size;
616 
617  if( strlen( $colour )>0 )
618  $tmp .= ','. $colour;
619 
620  return $tmp;
621  }
622 
633  function set_y_legend( $text, $size=-1, $colour='' )
634  {
635  $this->y_legend = $this->_set_y_legend( $text, $size, $colour );
636  }
637 
648  function set_y_right_legend( $text, $size=-1, $colour='' )
649  {
650  $this->y_legend_right = $this->_set_y_legend( $text, $size, $colour );
651  }
652 
661  function x_axis_colour( $axis, $grid='' )
662  {
663  $this->x_axis_colour = $axis;
664  $this->x_grid_colour = $grid;
665  }
666 
675  function y_axis_colour( $axis, $grid='' )
676  {
677  $this->y_axis_colour = $axis;
678 
679  if( strlen( $grid ) > 0 )
680  $this->y_grid_colour = $grid;
681  }
682 
689  function y_right_axis_colour( $colour )
690  {
691  $this->y2_axis_colour = $colour;
692  }
693 
708  function line( $width, $colour='', $text='', $size=-1, $circles=-1 )
709  {
710  $type = 'line'. $this->next_line();
711 
712  $description = '';
713  if( $width > 0 )
714  {
715  $description .= $width;
716  $description .= ','. $colour;
717  }
718 
719  if( strlen( $text ) > 0 )
720  {
721  $description.= ','. $text;
722  $description .= ','. $size;
723  }
724 
725  if( $circles > 0 )
726  $description .= ','. $circles;
727 
728  $this->lines[$type] = $description;
729  }
730 
745  function line_dot( $width, $dot_size, $colour, $text='', $font_size='' )
746  {
747  $type = 'line_dot'. $this->next_line();
748 
749  $description = "$width,$colour,$text";
750 
751  if( strlen( $font_size ) > 0 )
752  $description .= ",$font_size,$dot_size";
753 
754  $this->lines[$type] = $description;
755  }
756 
771  function line_hollow( $width, $dot_size, $colour, $text='', $font_size='' )
772  {
773  $type = 'line_hollow'. $this->next_line();
774 
775  $description = "$width,$colour,$text";
776 
777  if( strlen( $font_size ) > 0 )
778  $description .= ",$font_size,$dot_size";
779 
780  $this->lines[$type] = $description;
781  }
782 
801  function area_hollow( $width, $dot_size, $colour, $alpha, $text='', $font_size='', $fill_colour='' )
802  {
803  $type = 'area_hollow'. $this->next_line();
804 
805  $description = "$width,$dot_size,$colour,$alpha";
806 
807  if( strlen( $text ) > 0 )
808  $description .= ",$text,$font_size";
809 
810  if( strlen( $fill_colour ) > 0 )
811  $description .= ','. $fill_colour;
812 
813  $this->lines[$type] = $description;
814  }
815 
828  function bar( $alpha, $colour='', $text='', $size=-1 )
829  {
830  $type = 'bar'. $this->next_line();
831 
832  $description = $alpha .','. $colour .','. $text .','. $size;
833 
834  $this->lines[$type] = $description;
835  }
836 
851  function bar_filled( $alpha, $colour, $colour_outline, $text='', $size=-1 )
852  {
853  $type = 'filled_bar'. $this->next_line();
854 
855  $description = "$alpha,$colour,$colour_outline,$text,$size";
856 
857  $this->lines[$type] = $description;
858  }
859 
860  function bar_sketch( $alpha, $offset, $colour, $colour_outline, $text='', $size=-1 )
861  {
862  $type = 'bar_sketch'. $this->next_line();
863 
864  $description = "$alpha,$offset,$colour,$colour_outline,$text,$size";
865 
866  $this->lines[$type] = $description;
867  }
868 
881  function bar_3D( $alpha, $colour='', $text='', $size=-1 )
882  {
883  $type = 'bar_3d'. $this->next_line();
884 
885  $description = $alpha .','. $colour .','. $text .','. $size;
886 
887  $this->lines[$type] = $description;
888  }
889 
904  function bar_glass( $alpha, $colour, $outline_colour, $text='', $size=-1 )
905  {
906  $type = 'bar_glass'. $this->next_line();
907 
908  $description = $alpha .','. $colour .','. $outline_colour .','. $text .','. $size;
909 
910  $this->lines[$type] = $description;
911  }
912 
925  function bar_fade( $alpha, $colour='', $text='', $size=-1 )
926  {
927  $type = 'bar_fade'. $this->next_line();
928 
929  $description = $alpha .','. $colour .','. $text .','. $size;
930 
931  $this->lines[$type] = $description;
932  }
933 
934  function candle( $data, $alpha, $line_width, $colour, $text='', $size=-1 )
935  {
936  $type = 'candle'. $this->next_line();
937 
938  $description = $alpha .','. $line_width .','. $colour .','. $text .','. $size;
939 
940  $this->lines[$type] = $description;
941 
942  $a = array();
943  foreach( $data as $can )
944  $a[] = $can->toString();
945 
946  $this->data[] = implode(',',$a);
947  }
948 
949  function hlc( $data, $alpha, $line_width, $colour, $text='', $size=-1 )
950  {
951  $type = 'hlc'. $this->next_line();
952 
953  $description = $alpha .','. $line_width .','. $colour .','. $text .','. $size;
954 
955  $this->lines[$type] = $description;
956 
957  $a = array();
958  foreach( $data as $can )
959  $a[] = $can->toString();
960 
961  $this->data[] = implode(',',$a);
962  }
963 
964  function scatter( $data, $line_width, $colour, $text='', $size=-1 )
965  {
966  $type = 'scatter'. $this->next_line();
967 
968  $description = $line_width .','. $colour .','. $text .','. $size;
969 
970  $this->lines[$type] = $description;
971 
972  $a = array();
973  foreach( $data as $can )
974  $a[] = $can->toString();
975 
976  $this->data[] = implode(',',$a);
977  }
978 
979 
980  //
981  // Patch by, Jeremy Miller (14th Nov, 2007)
982  //
997  function pie( $alpha, $line_colour, $style, $gradient = true, $border_size = false )
998  {
999  $this->pie = $alpha.','.$line_colour.','.$style;
1000  if( !$gradient )
1001  {
1002  $this->pie .= ','.!$gradient;
1003  }
1004  if ($border_size)
1005  {
1006  if ($gradient === false)
1007  {
1008  $this->pie .= ',';
1009  }
1010  $this->pie .= ','.$border_size;
1011  }
1012  }
1013 
1024  function pie_values( $values, $labels=array(), $links=array() )
1025  {
1026  $this->pie_values = implode(',',$values);
1027  $this->pie_labels = implode(',',$labels);
1028  $this->pie_links = implode(",",$links);
1029  }
1030 
1037  function pie_slice_colours( $colours )
1038  {
1039  $this->pie_colours = implode(',',$colours);
1040  }
1041 
1042 
1046  function render()
1047  {
1048  $tmp = array();
1049 
1050  //echo headers_sent() ?'yes':'no';
1051  if( !headers_sent() )
1052  header('content-type: text; charset: utf-8');
1053 
1054  if($this->output_type == 'js')
1055  {
1056  $this->set_unique_id();
1057 
1058  $tmp[] = '<div id="' . $this->unique_id . '"></div>';
1059  $tmp[] = '<script src="' . $this->js_path . 'swfobject.js"></script>';
1060  $tmp[] = '<script>';
1061  $tmp[] = 'var so = new SWFObject("' . $this->swf_path . 'open-flash-chart.swf", "ofc", "'. $this->width . '", "' . $this->height . '", "9", "#FFFFFF");';
1062  $tmp[] = 'so.addVariable("wmode", "transparent");';
1063  $tmp[] = 'so.addVariable("variables","true");';
1064  }
1065 
1066  if( strlen( $this->title ) > 0 )
1067  {
1068  $values = $this->title;
1069  $values .= ','. $this->title_style;
1070  $tmp[] = $this->format_output('title',$values);
1071  }
1072 
1073  if( strlen( $this->x_legend ) > 0 )
1074  {
1075  $values = $this->x_legend;
1076  $values .= ','. $this->x_legend_size;
1077  $values .= ','. $this->x_legend_colour;
1078  $tmp[] = $this->format_output('x_legend',$values);
1079  }
1080 
1081  if( strlen( $this->x_label_style ) > 0 )
1082  $tmp[] = $this->format_output('x_label_style',$this->x_label_style);
1083 
1084  if( $this->x_tick_size > 0 )
1085  $tmp[] = $this->format_output('x_ticks',$this->x_tick_size);
1086 
1087  if( $this->x_axis_steps > 0 )
1088  $tmp[] = $this->format_output('x_axis_steps',$this->x_axis_steps);
1089 
1090  if( strlen( $this->x_axis_3d ) > 0 )
1091  $tmp[] = $this->format_output('x_axis_3d',$this->x_axis_3d);
1092 
1093  if( strlen( $this->y_legend ) > 0 )
1094  $tmp[] = $this->format_output('y_legend',$this->y_legend);
1095 
1096  if( strlen( $this->y_legend_right ) > 0 )
1097  $tmp[] = $this->format_output('y2_legend',$this->y_legend_right);
1098 
1099  if( strlen( $this->y_label_style ) > 0 )
1100  $tmp[] = $this->format_output('y_label_style',$this->y_label_style);
1101 
1102  $values = '5,10,'. $this->y_steps;
1103  $tmp[] = $this->format_output('y_ticks',$values);
1104 
1105  if( count( $this->lines ) == 0 && count($this->data_sets)==0 )
1106  {
1107  $tmp[] = $this->format_output($this->line_default['type'],$this->line_default['values']);
1108  }
1109  else
1110  {
1111  foreach( $this->lines as $type=>$description )
1112  $tmp[] = $this->format_output($type,$description);
1113  }
1114 
1115  $num = 1;
1116  foreach( $this->data as $data )
1117  {
1118  if( $num==1 )
1119  {
1120  $tmp[] = $this->format_output( 'values', $data);
1121  }
1122  else
1123  {
1124  $tmp[] = $this->format_output('values_'. $num, $data);
1125  }
1126 
1127  $num++;
1128  }
1129 
1130  $num = 1;
1131  foreach( $this->links as $link )
1132  {
1133  if( $num==1 )
1134  {
1135  $tmp[] = $this->format_output( 'links', $link);
1136  }
1137  else
1138  {
1139  $tmp[] = $this->format_output('links_'. $num, $link);
1140  }
1141 
1142  $num++;
1143  }
1144 
1145  if( count( $this->y2_lines ) > 0 )
1146  {
1147  $tmp[] = $this->format_output('y2_lines',implode( ',', $this->y2_lines ));
1148  //
1149  // Should this be an option? I think so...
1150  //
1151  $tmp[] = $this->format_output('show_y2','true');
1152  }
1153 
1154  if( count( $this->x_labels ) > 0 )
1155  $tmp[] = $this->format_output('x_labels',implode(',',$this->x_labels));
1156  else
1157  {
1158  if( strlen($this->x_min) > 0 )
1159  $tmp[] = $this->format_output('x_min',$this->x_min);
1160 
1161  if( strlen($this->x_max) > 0 )
1162  $tmp[] = $this->format_output('x_max',$this->x_max);
1163  }
1164 
1165  $tmp[] = $this->format_output('y_min',$this->y_min);
1166  $tmp[] = $this->format_output('y_max',$this->y_max);
1167 
1168  if( strlen($this->y2_min) > 0 )
1169  $tmp[] = $this->format_output('y2_min',$this->y2_min);
1170 
1171  if( strlen($this->y2_max) > 0 )
1172  $tmp[] = $this->format_output('y2_max',$this->y2_max);
1173 
1174  if( strlen( $this->bg_colour ) > 0 )
1175  $tmp[] = $this->format_output('bg_colour',$this->bg_colour);
1176 
1177  if( strlen( $this->bg_image ) > 0 )
1178  {
1179  $tmp[] = $this->format_output('bg_image',$this->bg_image);
1180  $tmp[] = $this->format_output('bg_image_x',$this->bg_image_x);
1181  $tmp[] = $this->format_output('bg_image_y',$this->bg_image_y);
1182  }
1183 
1184  if( strlen( $this->x_axis_colour ) > 0 )
1185  {
1186  $tmp[] = $this->format_output('x_axis_colour',$this->x_axis_colour);
1187  $tmp[] = $this->format_output('x_grid_colour',$this->x_grid_colour);
1188  }
1189 
1190  if( strlen( $this->y_axis_colour ) > 0 )
1191  $tmp[] = $this->format_output('y_axis_colour',$this->y_axis_colour);
1192 
1193  if( strlen( $this->y_grid_colour ) > 0 )
1194  $tmp[] = $this->format_output('y_grid_colour',$this->y_grid_colour);
1195 
1196  if( strlen( $this->y2_axis_colour ) > 0 )
1197  $tmp[] = $this->format_output('y2_axis_colour',$this->y2_axis_colour);
1198 
1199  if( strlen( $this->x_offset ) > 0 )
1200  $tmp[] = $this->format_output('x_offset',$this->x_offset);
1201 
1202  if( strlen( $this->inner_bg_colour ) > 0 )
1203  {
1204  $values = $this->inner_bg_colour;
1205  if( strlen( $this->inner_bg_colour_2 ) > 0 )
1206  {
1207  $values .= ','. $this->inner_bg_colour_2;
1208  $values .= ','. $this->inner_bg_angle;
1209  }
1210  $tmp[] = $this->format_output('inner_background',$values);
1211  }
1212 
1213  if( strlen( $this->pie ) > 0 )
1214  {
1215  $tmp[] = $this->format_output('pie',$this->pie);
1216  $tmp[] = $this->format_output('values',$this->pie_values);
1217  $tmp[] = $this->format_output('pie_labels',$this->pie_labels);
1218  $tmp[] = $this->format_output('colours',$this->pie_colours);
1219  $tmp[] = $this->format_output('links',$this->pie_links);
1220  }
1221 
1222  if( strlen( $this->tool_tip ) > 0 )
1223  $tmp[] = $this->format_output('tool_tip',$this->tool_tip);
1224 
1225 
1226 
1227  if( strlen( $this->y_format ) > 0 )
1228  $tmp[] = $this->format_output('y_format',$this->y_format);
1229 
1230  if( strlen( $this->num_decimals ) > 0 )
1231  $tmp[] = $this->format_output('num_decimals',$this->num_decimals);
1232 
1233  if( strlen( $this->is_fixed_num_decimals_forced ) > 0 )
1234  $tmp[] = $this->format_output('is_fixed_num_decimals_forced',$this->is_fixed_num_decimals_forced);
1235 
1236  if( strlen( $this->is_decimal_separator_comma ) > 0 )
1237  $tmp[] = $this->format_output('is_decimal_separator_comma',$this->is_decimal_separator_comma);
1238 
1239  if( strlen( $this->is_thousand_separator_disabled ) > 0 )
1240  $tmp[] = $this->format_output('is_thousand_separator_disabled',$this->is_thousand_separator_disabled);
1241 
1242 
1243  $count = 1;
1244  foreach( $this->data_sets as $set )
1245  {
1246  $tmp[] = $set->toString( $this->output_type, $count>1?'_'.$count:'' );
1247  $count++;
1248  }
1249 
1250  if($this->output_type == 'js')
1251  {
1252  $tmp[] = 'so.write("' . $this->unique_id . '");';
1253  $tmp[] = '</script>';
1254  }
1255 
1256  return implode("\r\n",$tmp);
1257  }
1258 }
1259 
1269 class line
1270 {
1272  var $colour;
1273  var $_key;
1274  var $key;
1276  // hold the data
1277  var $data;
1278  // extra tool tip info:
1279  var $tips;
1280 
1281  function line( $line_width, $colour )
1282  {
1283  $this->var = 'line';
1284 
1285  $this->line_width = $line_width;
1286  $this->colour = $colour;
1287  $this->data = array();
1288  $this->links = array();
1289  $this->tips = array();
1290  $this->_key = false;
1291  }
1292 
1293 
1294  function key( $key, $size )
1295  {
1296  $this->_key = true;
1297  $this->key = graph::esc( $key );
1298  $this->key_size = $size;
1299  }
1300 
1301  function add( $data )
1302  {
1303  $this->data[] = $data;
1304  }
1305 
1306  function add_link( $data, $link )
1307  {
1308  $this->data[] = $data;
1309  $this->links[] = graph::esc( $link );
1310  }
1311 
1312  function add_data_tip( $data, $tip )
1313  {
1314  $this->data[] = $data;
1315  $this->tips[] = graph::esc( $tip );
1316  }
1317 
1318  function add_data_link_tip( $data, $link, $tip )
1319  {
1320  $this->data[] = $data;
1321  $this->links[] = graph::esc( $link );
1322  $this->tips[] = graph::esc( $tip );
1323  }
1324 
1325  // return the variables for this chart
1327  {
1328  $values = array();
1329  $values[] = $this->line_width;
1330  $values[] = $this->colour;
1331 
1332  if( $this->_key )
1333  {
1334  $values[] = $this->key;
1335  $values[] = $this->key_size;
1336  }
1337 
1338  return $values;
1339  }
1340 
1341  function toString( $output_type, $set_num )
1342  {
1343  $values = implode( ',', $this->_get_variable_list() );
1344 
1345  $tmp = array();
1346 
1347  if( $output_type == 'js' )
1348  {
1349  $tmp[] = 'so.addVariable("'. $this->var.$set_num .'","'. $values . '");';
1350 
1351  $tmp[] = 'so.addVariable("values'. $set_num .'","'. implode( ',', $this->data ) .'");';
1352 
1353  if( count( $this->links ) > 0 )
1354  $tmp[] = 'so.addVariable("links'. $set_num .'","'. implode( ',', $this->links ) .'");';
1355 
1356  if( count( $this->tips ) > 0 )
1357  $tmp[] = 'so.addVariable("tool_tips_set'. $set_num .'","'. implode( ',', $this->tips ) .'");';
1358 
1359  }
1360  else
1361  {
1362  $tmp[] = '&'. $this->var. $set_num .'='. $values .'&';
1363  $tmp[] = '&values'. $set_num .'='. implode( ',', $this->data ) .'&';
1364 
1365  if( count( $this->links ) > 0 )
1366  $tmp[] = '&links'. $set_num .'='. implode( ',', $this->links ) .'&';
1367 
1368  if( count( $this->tips ) > 0 )
1369  $tmp[] = '&tool_tips_set'. $set_num .'='. implode( ',', $this->tips ) .'&';
1370  }
1371 
1372  return implode( "\r\n", $tmp );
1373  }
1374 }
1375 
1385 class line_hollow extends line
1386 {
1388 
1389  function line_hollow( $line_width, $dot_size, $colour )
1390  {
1391  parent::line( $line_width, $colour );
1392  $this->var = 'line_hollow';
1393  $this->dot_size = $dot_size;
1394  }
1395 
1396  // return the variables for this chart
1398  {
1399  $values = array();
1400  $values[] = $this->line_width;
1401  $values[] = $this->colour;
1402 
1403  if( $this->_key )
1404  {
1405  $values[] = $this->key;
1406  $values[] = $this->key_size;
1407  }
1408  else
1409  {
1410  $values[] = '';
1411  $values[] = '';
1412  }
1413  $values[] = $this->dot_size;
1414 
1415  return $values;
1416  }
1417 }
1418 
1428 class line_dot extends line_hollow
1429 {
1431  {
1432  parent::line_dot( $line_width, $colour );
1433  $this->var = 'line_dot';
1434  }
1435 }
1436 
1446 class bar
1447 {
1448  var $colour;
1449  var $alpha;
1450  var $data;
1451  var $links;
1452  var $_key;
1453  var $key;
1455  var $var;
1456  // extra tool tip info:
1457  var $tips;
1458 
1459  function bar( $alpha, $colour )
1460  {
1461  $this->var = 'bar';
1462 
1463  $this->alpha = $alpha;
1464  $this->colour = $colour;
1465  $this->data = array();
1466  $this->links = array();
1467  $this->tips = array();
1468  $this->_key = false;
1469  }
1470 
1471  function key( $key, $size )
1472  {
1473  $this->_key = true;
1474  $this->key = graph::esc( $key );
1475  $this->key_size = $size;
1476  }
1477 
1478  function add( $data )
1479  {
1480  $this->data[] = $data;
1481  }
1482 
1483  function add_link( $data, $link )
1484  {
1485  $this->data[] = $data;
1486  $this->links[] = graph::esc( $link );
1487  }
1488 
1489  function add_data_tip( $data, $tip )
1490  {
1491  $this->data[] = $data;
1492  $this->tips[] = graph::esc( $tip );
1493  }
1494 
1495  // return the variables for this
1496  // bar chart
1498  {
1499  $values = array();
1500  $values[] = $this->alpha;
1501  $values[] = $this->colour;
1502 
1503  if( $this->_key )
1504  {
1505  $values[] = $this->key;
1506  $values[] = $this->key_size;
1507  }
1508 
1509  return $values;
1510  }
1511 
1512  function toString( $output_type, $set_num )
1513  {
1514  $values = implode( ',', $this->_get_variable_list() );
1515 
1516  $tmp = array();
1517 
1518  if( $output_type == 'js' )
1519  {
1520  $tmp[] = 'so.addVariable("'. $this->var.$set_num .'","'. $values . '");';
1521 
1522  $tmp[] = 'so.addVariable("values'. $set_num .'","'. implode( ',', $this->data ) .'");';
1523 
1524  if( count( $this->links ) > 0 )
1525  $tmp[] = 'so.addVariable("links'. $set_num .'","'. implode( ',', $this->links ) .'");';
1526 
1527  if( count( $this->tips ) > 0 )
1528  $tmp[] = 'so.addVariable("tool_tips_set'. $set_num .'","'. implode( ',', $this->tips ) .'");';
1529 
1530  }
1531  else
1532  {
1533  $tmp[] = '&'. $this->var. $set_num .'='. $values .'&';
1534  $tmp[] = '&values'. $set_num .'='. implode( ',', $this->data ) .'&';
1535 
1536  if( count( $this->links ) > 0 )
1537  $tmp[] = '&links'. $set_num .'='. implode( ',', $this->links ) .'&';
1538 
1539  if( count( $this->tips ) > 0 )
1540  $tmp[] = '&tool_tips_set'. $set_num .'='. implode( ',', $this->tips ) .'&';
1541  }
1542 
1543  return implode( "\r\n", $tmp );
1544  }
1545 
1546 }
1547 
1557 class bar_3d extends bar
1558 {
1559  function bar_3d( $alpha, $colour )
1560  {
1561  parent::bar( $alpha, $colour );
1562  $this->var = 'bar_3d';
1563  }
1564 }
1565 
1575 class bar_fade extends bar
1576 {
1577  function bar_fade( $alpha, $colour )
1578  {
1579  parent::bar( $alpha, $colour );
1580  $this->var = 'bar_fade';
1581  }
1582 }
1583 
1593 class bar_outline extends bar
1594 {
1596 
1597  function bar_outline( $alpha, $colour, $outline_colour )
1598  {
1599  parent::bar( $alpha, $colour );
1600  $this->var = 'filled_bar';
1601  $this->outline_colour = $outline_colour;
1602  }
1603 
1604  // override the base method
1606  {
1607  $values = array();
1608  $values[] = $this->alpha;
1609  $values[] = $this->colour;
1610  $values[] = $this->outline_colour;
1611 
1612  if( $this->_key )
1613  {
1614  $values[] = $this->key;
1615  $values[] = $this->key_size;
1616  }
1617 
1618  return $values;
1619  }
1620 }
1621 
1631 class bar_glass extends bar_outline
1632 {
1641  {
1642  parent::bar_outline( $alpha, $colour, $outline_colour );
1643  $this->var = 'bar_glass';
1644  }
1645 }
1646 
1658 {
1659  var $offset;
1660 
1661  function bar_sketch( $alpha, $offset, $colour, $outline_colour )
1662  {
1663  parent::bar_outline( $alpha, $colour, $outline_colour );
1664  $this->var = 'bar_sketch';
1665  $this->offset = $offset;
1666  }
1667 
1668  // override the base method
1670  {
1671  $values = array();
1672  $values[] = $this->alpha;
1673  $values[] = $this->offset;
1674  $values[] = $this->colour;
1675  $values[] = $this->outline_colour;
1676 
1677  if( $this->_key )
1678  {
1679  $values[] = $this->key;
1680  $values[] = $this->key_size;
1681  }
1682 
1683  return $values;
1684  }
1685 }
1686 
1696 class candle
1697 {
1698  var $out;
1699 
1700  function candle( $high, $open, $close, $low )
1701  {
1702  $this->out = array();
1703  $this->out[] = $high;
1704  $this->out[] = $open;
1705  $this->out[] = $close;
1706  $this->out[] = $low;
1707  }
1708 
1709  function toString()
1710  {
1711  return '['. implode( ',', $this->out ) .']';
1712  }
1713 }
1714 
1724 class hlc
1725 {
1726  var $out;
1727 
1728  function hlc( $high, $low, $close )
1729  {
1730  $this->out = array();
1731  $this->out[] = $high;
1732  $this->out[] = $low;
1733  $this->out[] = $close;
1734  }
1735 
1736  function toString()
1737  {
1738  return '['. implode( ',', $this->out ) .']';
1739  }
1740 }
1741 
1751 class point
1752 {
1753  var $out;
1754 
1755  function point( $x, $y, $size_px )
1756  {
1757  $this->out = array();
1758  $this->out[] = $x;
1759  $this->out[] = $y;
1760  $this->out[] = $size_px;
1761  }
1762 
1763  function toString()
1764  {
1765  return '['. implode( ',', $this->out ) .']';
1766  }
1767 }
1768 
esc($text)
set_is_decimal_separator_comma($val)
foreach(array('date1', 'date2', 'type', 'renewals', 'width') as $item) $data
Definition: chart-data.php:29
$font_size
Definition: chart-data.php:34
set_y_label_style($size, $colour='')
Set the look and feel of the y axis labels.
bar($alpha, $colour)
set_links($links)
toString($output_type, $set_num)
set_y_max($max)
Set the maximum value of the y axis.
bar_glass($alpha, $colour, $outline_colour)
bar_glass::bar_glass()
line_hollow($width, $dot_size, $colour, $text='', $font_size='')
Draw a line with hollow dot markers on values.
set_x_tick_size($size)
Set the size of the x label ticks.
scatter($data, $line_width, $colour, $text='', $size=-1)
y_label_steps($val)
Show the y label on every $step label.
add($data)
set_y_right_min($min)
Set the minimum value of the right y axis.
set_base($base='js/')
Set the base path of the swfobject.
add_link($data, $link)
set_tool_tip($tip)
Set the tooltip to be displayed on each chart item.
unique_id()
Création d'un mot de passe crypté
Definition: fonctions.php:36
bar($alpha, $colour='', $text='', $size=-1)
Draw a bar chart.
bar_sketch($alpha, $offset, $colour, $colour_outline, $text='', $size=-1)
line_dot($width, $dot_size, $colour, $text='', $font_size='')
Draw a line with solid dot markers on values.
get_unique_id()
Get the flash object ID for the last rendered object.
y_axis_colour($axis, $grid='')
Set the colour of the y axis line and grid.
set_is_thousand_separator_disabled($val)
set_y_right_legend($text, $size=-1, $colour='')
Set the parameters of the right y legend.
set_x_labels($a)
Set the x axis labels.
set_x_legend($text, $size=-1, $colour='')
Set the parameters of the x legend.
set_num_decimals($val)
add($data)
set_y_right_label_style($size, $colour='')
Set the look and feel of the right y axis labels.
_set_y_legend($text, $size, $colour)
The private method of building the y legend output.
point($x, $y, $size_px)
candle($data, $alpha, $line_width, $colour, $text='', $size=-1)
set_y_legend($text, $size=-1, $colour='')
Set the parameters of the y legend.
format_output($function, $values)
Format the text to the type of output.
set_x_offset($val)
set_y_right_max($max)
Set the maximum value of the right y axis.
line_hollow($line_width, $dot_size, $colour)
bar_fade($alpha, $colour)
bar_fade($alpha, $colour='', $text='', $size=-1)
Draw a faded bar chart.
set_x_axis_steps($steps)
Set how often you would like to show a tick on the x axis.
pie_slice_colours($colours)
Set the pie slice colours.
next_line()
returns the next line label for multiple lines.
candle($high, $open, $close, $low)
key($key, $size)
set_unique_id()
Set the unique_id to use for the flash object id.
set_width($width)
Set the width of the chart.
bar_outline($alpha, $colour, $outline_colour)
graph()
Constructer for the open_flash_chart_api Sets our default variables.
set_title($title, $style='')
Set the text and style of the title.
bar_3D($alpha, $colour='', $text='', $size=-1)
Draw a 3D bar chart.
hlc($high, $low, $close)
bar_filled($alpha, $colour, $colour_outline, $text='', $size=-1)
Draw a bar chart with an outline.
add_link($data, $link)
set_x_axis_3d($size)
Set the depth in pixels of the 3D X axis slab.
set_bg_image($url, $x='center', $y='center')
Set a background image.
set_x_label_style($size, $colour='', $orientation=0, $step=-1, $grid_colour='')
Set the look and feel of the x axis labels.
pie_values($values, $labels=array(), $links=array())
Set the values of the pie chart.
_get_variable_list()
y_right_axis_colour($colour)
Set the colour of the right y axis line.
set_x_max($max)
add_data_tip($data, $tip)
add_data_link_tip($data, $link, $tip)
title($title, $style='')
bar_3d($alpha, $colour)
$GLOBALS['page_columns_count']
set_height($height)
Set the height of the chart.
set_swf_path($path)
Set the base path for the open-flash-chart.swf.
set_bg_colour($colour)
Set the background colour.
attach_to_y_right_axis($data_number)
Attach a set of data (a line, area or bar chart) to the right Y axis.
line($line_width, $colour)
_get_variable_list()
set_js_path($path)
Set the base path for the swfobject.js.
bar_glass($alpha, $colour, $outline_colour, $text='', $size=-1)
Draw a 3D bar chart that looks like glass.
set_x_min($min)
_set_y_label_style($size, $colour)
Internal function to build the y label style for y and y2.
area_hollow($width, $dot_size, $colour, $alpha, $text='', $font_size='', $fill_colour='')
Draw an area chart.
render()
Render the output.
x_axis_colour($axis, $grid='')
Set the colour of the x axis line and grid.
set_data($a)
Set the data for the chart.
line_dot($line_width, $dot_size, $colour)
key($key, $size)
line($width, $colour='', $text='', $size=-1, $circles=-1)
Draw a line without markers on values.
pie($alpha, $line_colour, $style, $gradient=true, $border_size=false)
Draw a pie chart.
bar_sketch($alpha, $offset, $colour, $outline_colour)
set_is_fixed_num_decimals_forced($val)
add_data_tip($data, $tip)
toString($output_type, $set_num)
set_y_format($val)
set_y_min($min)
Set the minimum value of the y axis.
set_inner_background($col, $col2='', $angle=-1)
Set the background colour of the grid portion of the chart.
hlc($data, $alpha, $line_width, $colour, $text='', $size=-1)
set_output_type($type)
Set the type of output data.

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:27 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.