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");
|
---|
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($l1plot);
|
---|
30 | $graph->Add($bplot);
|
---|
31 |
|
---|
32 |
|
---|
33 | $graph->title->Set("Adding a line plot to a bar graph v1");
|
---|
34 | $graph->xaxis->title->Set("X-title");
|
---|
35 | $graph->yaxis->title->Set("Y-title");
|
---|
36 |
|
---|
37 | $graph->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
38 | $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
39 | $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
40 |
|
---|
41 | //$graph->xaxis->SetTickLabels($datax);
|
---|
42 | //$graph->xaxis->SetTextTickInterval(2);
|
---|
43 |
|
---|
44 | // Display the graph
|
---|
45 | $graph->Stroke();
|
---|
46 | ?>
|
---|