1 | <?php
|
---|
2 | require_once ('jpgraph/jpgraph.php');
|
---|
3 | require_once ('jpgraph/jpgraph_odo.php');
|
---|
4 | require_once ('jpgraph/jpgraph_iconplot.php');
|
---|
5 |
|
---|
6 | // Create a new odometer graph
|
---|
7 | $graph = new OdoGraph(500,180);
|
---|
8 |
|
---|
9 | $odo = array();
|
---|
10 |
|
---|
11 | // Now we need to create an odometer to add to the graph.
|
---|
12 | for( $i=0; $i < 5; ++$i ) {
|
---|
13 | $odo[$i] = new Odometer();
|
---|
14 | $odo[$i]->SetColor('lightgray:1.9');
|
---|
15 | $odo[$i]->needle->Set(10+$i*17);
|
---|
16 | $odo[$i]->needle->SetShadow();
|
---|
17 | if( $i < 2 )
|
---|
18 | $fsize = 10;
|
---|
19 | else
|
---|
20 | $fsize = 8;
|
---|
21 | $odo[$i]->scale->label->SetFont(FF_ARIAL,FS_NORMAL,$fsize);
|
---|
22 | $odo[$i]->AddIndication(92,100,'red');
|
---|
23 | $odo[$i]->AddIndication(80,92,'orange');
|
---|
24 | $odo[$i]->AddIndication(60,80,'yellow');
|
---|
25 | }
|
---|
26 |
|
---|
27 | // Create the layout
|
---|
28 | $row1 = new LayoutHor( array($odo[0],$odo[1]) );
|
---|
29 | $row2 = new LayoutHor( array($odo[2],$odo[3],$odo[4]) );
|
---|
30 | $col1 = new LayoutVert( array($row1,$row2) );
|
---|
31 |
|
---|
32 | // Add the odometer to the graph
|
---|
33 | $graph->Add($col1);
|
---|
34 |
|
---|
35 | // Add an icon and text
|
---|
36 | $icon = new IconPlot('jpglogo.jpg',250,10,0.85,30);
|
---|
37 | $icon->SetAnchor('center','top');
|
---|
38 | $graph->Add($icon);
|
---|
39 |
|
---|
40 | $t = new Text('JpGraph',250,70);
|
---|
41 | $t->SetAlign('center','top');
|
---|
42 | #$t->SetFont(FF_VERA,FS_BOLD,11);
|
---|
43 | $t->SetColor('darkgray');
|
---|
44 | $graph->Add($t);
|
---|
45 |
|
---|
46 | // ... and finally stroke and stream the image back to the browser
|
---|
47 | $graph->Stroke();
|
---|
48 |
|
---|
49 | ?>
|
---|