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_scatter.php');
|
---|
5 |
|
---|
6 | $datay = array(
|
---|
7 | array(4,26,15,44),
|
---|
8 | array(20,51,32,20));
|
---|
9 |
|
---|
10 | // Setup the graph
|
---|
11 | $graph = new Graph(300,200);
|
---|
12 | $graph->SetMarginColor('white');
|
---|
13 | $graph->SetScale("textlin");
|
---|
14 | $graph->SetFrame(false);
|
---|
15 | $graph->SetMargin(30,5,25,20);
|
---|
16 |
|
---|
17 | // Enable X-grid as well
|
---|
18 | $graph->xgrid->Show();
|
---|
19 |
|
---|
20 | // Use months as X-labels
|
---|
21 | $graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
|
---|
22 |
|
---|
23 | //------------------------
|
---|
24 | // Create the plots
|
---|
25 | //------------------------
|
---|
26 | $p1 = new LinePlot($datay[0]);
|
---|
27 | $p1->SetColor("navy");
|
---|
28 |
|
---|
29 | // Use a flag
|
---|
30 | $p1->mark->SetType(MARK_FLAG1,197);
|
---|
31 |
|
---|
32 | // Displayes value on top of marker image
|
---|
33 | $p1->value->SetFormat('%d mil');
|
---|
34 | $p1->value->Show();
|
---|
35 | $p1->value->SetColor('darkred');
|
---|
36 | $p1->value->SetFont(FF_ARIAL,FS_BOLD,10);
|
---|
37 | // Increase the margin so that the value is printed avove tje
|
---|
38 | // img marker
|
---|
39 | $p1->value->SetMargin(14);
|
---|
40 |
|
---|
41 | // Incent the X-scale so the first and last point doesn't
|
---|
42 | // fall on the edges
|
---|
43 | $p1->SetCenter();
|
---|
44 |
|
---|
45 | $graph->Add($p1);
|
---|
46 |
|
---|
47 | //------------
|
---|
48 | // 2:nd plot
|
---|
49 | //------------
|
---|
50 | $p2 = new LinePlot($datay[1]);
|
---|
51 | $p2->SetColor("navy");
|
---|
52 |
|
---|
53 | // Use a flag
|
---|
54 | $p2->mark->SetType(MARK_FLAG1,'united states');
|
---|
55 |
|
---|
56 | // Displayes value on top of marker image
|
---|
57 | $p2->value->SetFormat('%d mil');
|
---|
58 | $p2->value->Show();
|
---|
59 | $p2->value->SetColor('darkred');
|
---|
60 | $p2->value->SetFont(FF_ARIAL,FS_BOLD,10);
|
---|
61 | // Increase the margin so that the value is printed avove tje
|
---|
62 | // img marker
|
---|
63 | $p2->value->SetMargin(14);
|
---|
64 |
|
---|
65 | // Incent the X-scale so the first and last point doesn't
|
---|
66 | // fall on the edges
|
---|
67 | $p2->SetCenter();
|
---|
68 | $graph->Add($p2);
|
---|
69 |
|
---|
70 | $graph->Stroke();
|
---|
71 |
|
---|
72 | ?>
|
---|
73 |
|
---|
74 |
|
---|