]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/external_packages/phplot/examples/create_chart.php
Update
[bacula/bacula] / gui / bacula-web / external_packages / phplot / examples / create_chart.php
1 <?php    
2 /* $Id$ */
3
4 error_reporting(E_ALL);
5
6 /*
7 // Check if we are processing the form
8 if (! array_key_exists('submit', $_POST)) {
9     echo "<p>This file is intended to be called from format_chart.php, the example-o-matic.".
10          "Please <a href=\"format_chart.php\">click here</a> to try it.</p>";
11     exit;
12 }    
13 */
14
15 extract ($_GET, EXTR_OVERWRITE);
16 extract ($_POST, EXTR_OVERWRITE);
17
18
19 //Sample functions
20
21 // data-data as a function
22 if ($which_data_type == 'function') { 
23         //Put function here
24         $dx = ".3";
25         $max = 6.4;
26         $maxi = $max/$dx;
27         for ($i=0; $i<$maxi; $i++) {
28                 $a = 4;
29                 $x = $dx*$i;
30                 $data[$i] = array("", $x, $a*sin($x),$a*cos($x),$a*cos($x+1));  
31         }
32         $which_data_type = "data-data";
33 }
34 // data-data-error as a random function
35 else if ($which_data_type == 'randfunction') {
36     srand ((double) microtime() * 1000000);
37     $a = 9.62;
38     $label[0] = "October"; $label[5] = "Day 5"; $label[10] = "Day 10";
39     $label[15] = "Day 15"; $label[20] = "Day 20"; $label[25] = "Day 25";
40     
41     for ($i = 0; $i <= 30; $i++) {
42         $a += rand(-1, 2);
43         $b = rand(0,1);
44         $c = rand(0,1);
45         $data[] = @ array($label[$i],$i+1,$a,$b,$c);
46     }
47     $which_data_type = 'data-data-error';
48 }
49 // MBD, this is for data_sample3.php, $num_data_rows is set there
50 else if ($which_data_type == 'data-data-error') {
51     for ($i = 0; $i < $num_data_rows; $i++) {
52         eval ("\$data[\$i] = \$data_row$i; ");
53     }      
54 } else { 
55     foreach($data_row0 as $key=>$val) {
56                 $data[$key] = array($data_row0[$key],$data_row1[$key],$data_row2[$key],$data_row3[$key],$data_row4[$key]);
57         }
58 }
59
60
61 ////////////////////////////////////////////////
62
63 //Required Settings 
64         include("../phplot.php");
65         $graph = new PHPlot($xsize_in, $ysize_in);
66         $graph->SetDataType($which_data_type);  // Must be first thing
67     
68         $graph->SetDataValues($data);
69
70 //Optional Settings (Don't need them) 
71
72 //      $graph->SetTitle("This is a\n\rmultiple line title\n\rspanning three lines.");
73     $graph->SetTitle($title);
74         $graph->SetXTitle($xlbl, $which_xtitle_pos);
75         $graph->SetYTitle($ylbl, $which_ytitle_pos);
76         $graph->SetLegend(array("A","Bee","Cee","Dee"));
77     
78         $graph->SetFileFormat($which_fileformat);
79         $graph->SetPlotType($which_plot_type);
80     
81         $graph->SetUseTTF($which_use_ttf);
82     
83         $graph->SetYTickIncrement($which_yti);
84         $graph->SetXTickIncrement($which_xti);
85     $graph->SetXTickLength($which_xtl);
86     $graph->SetYTickLength($which_ytl);
87     $graph->SetXTickCrossing($which_xtc);
88     $graph->SetYTickCrossing($which_ytc);
89     $graph->SetXTickPos($which_xtick_pos);
90     $graph->SetYTickPos($which_ytick_pos);
91
92     
93     $graph->SetShading($which_shading);
94     $graph->SetLineWidth($which_line_width);
95     $graph->SetErrorBarLineWidth($which_errorbar_line_width);
96
97     $graph->SetDrawDashedGrid($which_dashed_grid);
98     switch($which_draw_grid) {
99     case 'x':
100         $graph->SetDrawXGrid(TRUE);
101         $graph->SetDrawYGrid(FALSE);
102         break;
103     case 'y':
104         $graph->SetDrawXGrid(FALSE);
105         $graph->SetDrawYGrid(TRUE);
106         break;
107     case 'both':
108         $graph->SetDrawXGrid(TRUE);
109         $graph->SetDrawYGrid(TRUE);
110         break;
111     case 'none':
112         $graph->SetDrawXGrid(FALSE);
113         $graph->SetDrawYGrid(FALSE);
114     }    
115     
116     $graph->SetXTickLabelPos($which_xtick_label_pos);
117     $graph->SetYTickLabelPos($which_ytick_label_pos);
118     $graph->SetXDataLabelPos($which_xdata_label_pos);
119     $graph->SetYDataLabelPos($which_ydata_label_pos);
120     
121     // Please remember that angles other than 90 are taken as 0 when working fith fixed fonts.
122     $graph->SetXLabelAngle($which_xlabel_angle);
123     $graph->SetYLabelAngle($which_ylabel_angle);
124
125         //$graph->SetLineStyles(array("dashed","dashed","solid","solid"));
126         $graph->SetPointShape($which_point);
127     $graph->SetPointSize($which_point_size);
128     $graph->SetDrawBrokenLines($which_broken);
129
130     // Some forms in format_chart.php don't set this variable, suppress errors.
131         @ $graph->SetErrorBarShape($which_error_type);
132     
133         $graph->SetXAxisPosition($which_xap);
134     $graph->SetYAxisPosition($which_yap);
135     $graph->SetPlotBorderType($which_btype);
136     
137         if ($maxy_in) { 
138                 if ($which_data_type = "text-data") { 
139                         $graph->SetPlotAreaWorld(0,$miny_in,count($data),$maxy_in);
140                 }
141         }
142
143 /*
144 //Even more settings
145
146         $graph->SetPlotAreaWorld(0,100,5.5,1000);
147         $graph->SetPlotAreaWorld(0,-10,6,35);
148         $graph->SetPlotAreaPixels(150,50,600,400);
149
150     $graph->SetDataColors(
151                 array("blue","green","yellow","red"),  //Data Colors
152             array("black")                                                      //Border Colors
153     );  
154
155     $graph->SetPlotBgColor(array(222,222,222));
156     $graph->SetBackgroundColor(array(200,222,222)); //can use rgb values or "name" values
157     $graph->SetTextColor("black");
158     $graph->SetGridColor("black");
159     $graph->SetLightGridColor(array(175,175,175));
160     $graph->SetTickColor("black");
161     $graph->SetTitleColor(array(0,0,0)); // Can be array or name
162 */
163
164 //      $graph->SetPrintImage(false);
165       $graph->DrawGraph();
166 //      xdebug_dump_function_profile(XDEBUG_PROFILER_FS_SUM);
167 ?>