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 | $datay = array(28,19,18,23,12,11);
|
---|
7 | $data2y = array(14,18,33,29,39,55);
|
---|
8 |
|
---|
9 | // A nice graph with anti-aliasing
|
---|
10 | $graph = new Graph(400,200);
|
---|
11 | $graph->img->SetMargin(40,180,40,40);
|
---|
12 | $graph->SetBackgroundImage("tiger_bkg.png",BGIMG_FILLFRAME);
|
---|
13 |
|
---|
14 | $graph->img->SetAntiAliasing();
|
---|
15 | $graph->SetScale("textlin");
|
---|
16 | $graph->SetShadow();
|
---|
17 | $graph->title->Set("Background image");
|
---|
18 |
|
---|
19 | // Use built in font
|
---|
20 | $graph->title->SetFont(FF_FONT1,FS_BOLD);
|
---|
21 |
|
---|
22 | // Slightly adjust the legend from it's default position in the
|
---|
23 | // top right corner.
|
---|
24 | $graph->legend->Pos(0.05,0.5,"right","center");
|
---|
25 |
|
---|
26 | // Create the first line
|
---|
27 | $p1 = new LinePlot($datay);
|
---|
28 | $p1->mark->SetType(MARK_FILLEDCIRCLE);
|
---|
29 | $p1->mark->SetFillColor("red");
|
---|
30 | $p1->mark->SetWidth(4);
|
---|
31 | $p1->SetColor("blue");
|
---|
32 | $p1->SetCenter();
|
---|
33 | $p1->SetLegend("Triumph Tiger -98");
|
---|
34 | $graph->Add($p1);
|
---|
35 |
|
---|
36 | // ... and the second
|
---|
37 | $p2 = new LinePlot($data2y);
|
---|
38 | $p2->mark->SetType(MARK_STAR);
|
---|
39 | $p2->mark->SetFillColor("red");
|
---|
40 | $p2->mark->SetWidth(4);
|
---|
41 | $p2->SetColor("red");
|
---|
42 | $p2->SetCenter();
|
---|
43 | $p2->SetLegend("New tiger -99");
|
---|
44 | $graph->Add($p2);
|
---|
45 |
|
---|
46 | // Output line
|
---|
47 | $graph->Stroke();
|
---|
48 |
|
---|
49 | ?>
|
---|
50 |
|
---|
51 |
|
---|