1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_line.php'); |
---|
4 | |
---|
5 | // Some data |
---|
6 | $datax = array("2001-04-01","2001-04-02","2001-04-03","2001-04-04","2001-04-05","2001-04-06"); |
---|
7 | $datay = array(28,13,24,"",90,11); |
---|
8 | $data2y = array(11,41,"-",33,"-",63); |
---|
9 | |
---|
10 | // Setup graph |
---|
11 | $graph = new Graph(400,250); |
---|
12 | $graph->img->SetMargin(40,150,40,80); |
---|
13 | $graph->SetScale("textlin"); |
---|
14 | $graph->SetShadow(); |
---|
15 | |
---|
16 | //Setup title |
---|
17 | $graph->title->Set("Line plot with null values"); |
---|
18 | |
---|
19 | // Use built in font |
---|
20 | $graph->title->SetFont(FF_ARIAL,FS_NORMAL,14); |
---|
21 | |
---|
22 | // Slightly adjust the legend from it's default position |
---|
23 | $graph->legend->Pos(0.03,0.5,"right","center"); |
---|
24 | $graph->legend->SetFont(FF_FONT1,FS_BOLD); |
---|
25 | |
---|
26 | // Setup X-scale |
---|
27 | $graph->xaxis->SetTickLabels($datax); |
---|
28 | $graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8); |
---|
29 | $graph->xaxis->SetLabelAngle(45); |
---|
30 | |
---|
31 | // Create the first line |
---|
32 | $p1 = new LinePlot($datay); |
---|
33 | $p1->mark->SetType(MARK_FILLEDCIRCLE); |
---|
34 | $p1->mark->SetFillColor("red"); |
---|
35 | $p1->mark->SetWidth(4); |
---|
36 | $p1->SetColor("blue"); |
---|
37 | $p1->SetCenter(); |
---|
38 | $p1->SetLegend("Undefined\nvariant 1"); |
---|
39 | $graph->Add($p1); |
---|
40 | |
---|
41 | // ... and the second |
---|
42 | $p2 = new LinePlot($data2y); |
---|
43 | $p2->mark->SetType(MARK_STAR); |
---|
44 | $p2->mark->SetFillColor("red"); |
---|
45 | $p2->mark->SetWidth(4); |
---|
46 | $p2->SetColor("red"); |
---|
47 | $p2->SetCenter(); |
---|
48 | $p2->SetLegend("Undefined\nvariant 2"); |
---|
49 | $graph->Add($p2); |
---|
50 | |
---|
51 | // Output line |
---|
52 | $graph->Stroke(); |
---|
53 | |
---|
54 | ?> |
---|
55 | |
---|
56 | |
---|