[42] | 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_error.php'); |
---|
| 5 | require_once ('jpgraph/jpgraph_bar.php'); |
---|
| 6 | |
---|
| 7 | $l1datay = array(11,9,2,4,3,13,17); |
---|
| 8 | $l2datay = array(23,12,5,19,17,10,15); |
---|
| 9 | $datax=array("Jan","Feb","Mar","Apr","May","Jun","Jul"); |
---|
| 10 | |
---|
| 11 | // Create the graph. |
---|
| 12 | $graph = new Graph(350,200); |
---|
| 13 | $graph->img->SetMargin(40,70,20,40); |
---|
| 14 | $graph->SetScale("textlin"); |
---|
| 15 | $graph->SetShadow(); |
---|
| 16 | $graph->SetColor(array(250,250,250)); |
---|
| 17 | |
---|
| 18 | $graph->img->SetTransparent("white"); |
---|
| 19 | |
---|
| 20 | $t1 = new Text("This is a text"); |
---|
| 21 | $t1->SetPos(0.5,0.5); |
---|
| 22 | $t1->SetOrientation("h"); |
---|
| 23 | $t1->SetFont(FF_FONT1,FS_BOLD); |
---|
| 24 | $t1->SetBox("white","black","gray"); |
---|
| 25 | $t1->SetColor("black"); |
---|
| 26 | $graph->AddText($t1); |
---|
| 27 | |
---|
| 28 | // Create the linear error plot |
---|
| 29 | $l1plot=new LinePlot($l1datay); |
---|
| 30 | $l1plot->SetColor("blue"); |
---|
| 31 | $l1plot->SetWeight(2); |
---|
| 32 | $l1plot->SetLegend("Prediction"); |
---|
| 33 | |
---|
| 34 | // Create the bar plot |
---|
| 35 | $l2plot = new BarPlot($l2datay); |
---|
| 36 | $l2plot->SetFillColor("orange"); |
---|
| 37 | $l2plot->SetLegend("Result"); |
---|
| 38 | |
---|
| 39 | // Add the plots to the graph |
---|
| 40 | $graph->Add($l1plot); |
---|
| 41 | $graph->Add($l2plot); |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | $graph->title->Set("Example 16.3"); |
---|
| 45 | $graph->xaxis->title->Set("Month"); |
---|
| 46 | $graph->yaxis->title->Set("x10,000 US$"); |
---|
| 47 | |
---|
| 48 | $graph->title->SetFont(FF_FONT1,FS_BOLD); |
---|
| 49 | $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); |
---|
| 50 | $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); |
---|
| 51 | |
---|
| 52 | $graph->xaxis->SetTickLabels($datax); |
---|
| 53 | //$graph->xaxis->SetTextTickInterval(2); |
---|
| 54 | |
---|
| 55 | // Display the graph |
---|
| 56 | $graph->Stroke(); |
---|
| 57 | ?> |
---|