1<?php
2require_once('jpgraph/jpgraph.php');
3require_once('jpgraph/jpgraph_odo.php');
4require_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.
12for ($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    }
22    $odo[$i]->scale->label->SetFont(FF_ARIAL, FS_NORMAL, $fsize);
23    $odo[$i]->AddIndication(92, 100, 'red');
24    $odo[$i]->AddIndication(80, 92, 'orange');
25    $odo[$i]->AddIndication(60, 80, 'yellow');
26}
27
28// Create the layout
29$row1 = new LayoutHor(array($odo[0],$odo[1]));
30$row2 = new LayoutHor(array($odo[2],$odo[3],$odo[4]));
31$col1 = new LayoutVert(array($row1,$row2));
32
33// Add the odometer to the graph
34$graph->Add($col1);
35
36// Add an icon and text
37$icon = new IconPlot('jpglogo.jpg', 250, 10, 0.85, 30);
38$icon->SetAnchor('center', 'top');
39$graph->Add($icon);
40
41$t = new Text('JpGraph', 250, 70);
42$t->SetAlign('center', 'top');
43#$t->SetFont(FF_VERA,FS_BOLD,11);
44$t->SetColor('darkgray');
45$graph->Add($t);
46
47// ... and finally stroke and stream the image back to the browser
48$graph->Stroke();
49