1 | <?php |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_odo.php'); |
---|
4 | |
---|
5 | // Create a new odometer graph (width=250, height=200 pixels) |
---|
6 | $graph = new OdoGraph(250,150); |
---|
7 | |
---|
8 | $graph->title->Set('Example with scale indicators'); |
---|
9 | |
---|
10 | // Add drop shadow for graph |
---|
11 | $graph->SetShadow(); |
---|
12 | |
---|
13 | // Now we need to create an odometer to add to the graph. |
---|
14 | // By default the scale will be 0 to 100 |
---|
15 | $odo = new Odometer(ODO_HALF); |
---|
16 | |
---|
17 | // Add color indications |
---|
18 | $odo->AddIndication(0,20,"green:0.7"); |
---|
19 | $odo->AddIndication(20,30,"green:0.9"); |
---|
20 | $odo->AddIndication(30,60,"yellow"); |
---|
21 | $odo->AddIndication(60,80,"orange"); |
---|
22 | $odo->AddIndication(80,100,"red"); |
---|
23 | |
---|
24 | $odo->SetCenterAreaWidth(0.45); |
---|
25 | |
---|
26 | // Set display value for the odometer |
---|
27 | $odo->needle->Set(90); |
---|
28 | |
---|
29 | // Add scale labels |
---|
30 | $odo->label->Set("mBar"); |
---|
31 | $odo->label->SetFont(FF_FONT2,FS_BOLD); |
---|
32 | |
---|
33 | // Add drop shadow for needle |
---|
34 | $odo->needle->SetShadow(); |
---|
35 | |
---|
36 | // Add the odometer to the graph |
---|
37 | $graph->Add($odo); |
---|
38 | |
---|
39 | // ... and finally stroke and stream the image back to the browser |
---|
40 | $graph->Stroke(); |
---|
41 | ?> |
---|