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_plotline.php'); |
---|
5 | |
---|
6 | $datay1 = array(2,6,7,12,13,18); |
---|
7 | $datay2 = array(5,12,12,19,25,20); |
---|
8 | |
---|
9 | // Setup the graph |
---|
10 | $graph = new Graph(350,200); |
---|
11 | $graph->SetMargin(30,20,60,20); |
---|
12 | $graph->SetMarginColor('white'); |
---|
13 | $graph->SetScale("linlin"); |
---|
14 | |
---|
15 | // Hide the frame around the graph |
---|
16 | $graph->SetFrame(false); |
---|
17 | |
---|
18 | // Setup title |
---|
19 | $graph->title->Set("Using Builtin PlotMarks"); |
---|
20 | $graph->title->SetFont(FF_VERDANA,FS_BOLD,14); |
---|
21 | |
---|
22 | // Note: requires jpgraph 1.12p or higher |
---|
23 | // $graph->SetBackgroundGradient('blue','navy:0.5',GRAD_HOR,BGRAD_PLOT); |
---|
24 | $graph->tabtitle->Set('Region 1' ); |
---|
25 | $graph->tabtitle->SetWidth(TABTITLE_WIDTHFULL); |
---|
26 | |
---|
27 | // Enable X and Y Grid |
---|
28 | $graph->xgrid->Show(); |
---|
29 | $graph->xgrid->SetColor('gray@0.5'); |
---|
30 | $graph->ygrid->SetColor('gray@0.5'); |
---|
31 | |
---|
32 | // Format the legend box |
---|
33 | $graph->legend->SetColor('navy'); |
---|
34 | $graph->legend->SetFillColor('lightgreen'); |
---|
35 | $graph->legend->SetLineWeight(1); |
---|
36 | $graph->legend->SetFont(FF_ARIAL,FS_BOLD,8); |
---|
37 | $graph->legend->SetShadow('gray@0.4',3); |
---|
38 | $graph->legend->SetAbsPos(15,120,'right','bottom'); |
---|
39 | |
---|
40 | // Create the line plots |
---|
41 | |
---|
42 | $p1 = new LinePlot($datay1); |
---|
43 | $p1->SetColor("red"); |
---|
44 | $p1->SetFillColor("yellow@0.5"); |
---|
45 | $p1->SetWeight(2); |
---|
46 | $p1->mark->SetType(MARK_IMG_DIAMOND,5,0.6); |
---|
47 | $p1->SetLegend('2006'); |
---|
48 | $graph->Add($p1); |
---|
49 | |
---|
50 | $p2 = new LinePlot($datay2); |
---|
51 | $p2->SetColor("darkgreen"); |
---|
52 | $p2->SetWeight(2); |
---|
53 | $p2->SetLegend('2001'); |
---|
54 | $p2->mark->SetType(MARK_IMG_MBALL,'red'); |
---|
55 | $graph->Add($p2); |
---|
56 | |
---|
57 | // Add a vertical line at the end scale position '7' |
---|
58 | $l1 = new PlotLine(VERTICAL,7); |
---|
59 | $graph->Add($l1); |
---|
60 | |
---|
61 | // Output the graph |
---|
62 | $graph->Stroke(); |
---|
63 | |
---|
64 | ?> |
---|
65 | |
---|
66 | |
---|