1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_line.php'); |
---|
4 | require_once ('jpgraph/jpgraph_bar.php'); |
---|
5 | |
---|
6 | $l1datay = array(11,9,2,4,3,13,17); |
---|
7 | $l2datay = array(23,12,5,19,17,10,15); |
---|
8 | $datax=array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug'); |
---|
9 | |
---|
10 | // Create the graph. |
---|
11 | $graph = new Graph(400,200); |
---|
12 | $graph->SetScale('textlin'); |
---|
13 | |
---|
14 | $graph->img->SetMargin(40,130,20,40); |
---|
15 | $graph->SetShadow(); |
---|
16 | |
---|
17 | // Create the linear error plot |
---|
18 | $l1plot=new LinePlot($l1datay); |
---|
19 | $l1plot->SetColor('red'); |
---|
20 | $l1plot->SetWeight(2); |
---|
21 | $l1plot->SetLegend('Prediction'); |
---|
22 | |
---|
23 | // Create the bar plot |
---|
24 | $bplot = new BarPlot($l2datay); |
---|
25 | $bplot->SetFillColor('orange'); |
---|
26 | $bplot->SetLegend('Result'); |
---|
27 | |
---|
28 | // Add the plots to t'he graph |
---|
29 | $graph->Add($bplot); |
---|
30 | $graph->Add($l1plot); |
---|
31 | |
---|
32 | $graph->title->Set('Adding a line plot to a bar graph v1'); |
---|
33 | $graph->xaxis->title->Set('X-title'); |
---|
34 | $graph->yaxis->title->Set('Y-title'); |
---|
35 | |
---|
36 | $graph->title->SetFont(FF_FONT1,FS_BOLD); |
---|
37 | $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); |
---|
38 | $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); |
---|
39 | |
---|
40 | $graph->xaxis->SetTickLabels($datax); |
---|
41 | //$graph->xaxis->SetTextTickInterval(2); |
---|
42 | |
---|
43 | // Display the graph |
---|
44 | $graph->Stroke(); |
---|
45 | ?> |
---|