source: trunk/xgraph/jpgraph/Examples/linebarcentex1.php

Last change on this file was 42, checked in by marrucho, 10 years ago
File size: 1.2 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2require_once ('jpgraph/jpgraph.php');
3require_once ('jpgraph/jpgraph_line.php');
4require_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
9$datax=$gDateLocale->GetShortMonth();
10
11// Create the graph.
12$graph = new Graph(400,200);   
13$graph->SetScale("textlin");
14$graph->SetMargin(40,130,20,40);
15$graph->SetShadow();
16$graph->xaxis->SetTickLabels($datax);
17
18// Create the linear error plot
19$l1plot=new LinePlot($l1datay);
20$l1plot->SetColor("red");
21$l1plot->SetWeight(2);
22$l1plot->SetLegend("Prediction");
23
24//Center the line plot in the center of the bars
25$l1plot->SetBarCenter();
26
27
28// Create the bar plot
29$bplot = new BarPlot($l2datay);
30$bplot->SetFillColor("orange");
31$bplot->SetLegend("Result");
32
33// Add the plots to t'he graph
34$graph->Add($bplot);
35$graph->Add($l1plot);
36
37
38$graph->title->Set("Adding a line plot to a bar graph v1");
39$graph->xaxis->title->Set("X-title");
40$graph->yaxis->title->Set("Y-title");
41
42$graph->title->SetFont(FF_FONT1,FS_BOLD);
43$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
44$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
45
46
47// Display the graph
48$graph->Stroke();
49?>
Note: See TracBrowser for help on using the repository browser.