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,140); |
---|
7 | |
---|
8 | // Setup a title |
---|
9 | $graph->title->Set('An example with thick border'); |
---|
10 | $graph->title->SetFont(FF_ARIAL,FS_BOLD,11); |
---|
11 | |
---|
12 | // Add drop shadow for graph |
---|
13 | $graph->SetShadow(); |
---|
14 | |
---|
15 | // Set some nonstandard colors |
---|
16 | $color = array(205,220,205); |
---|
17 | $graph->SetMarginColor($color); |
---|
18 | $graph->SetColor($color); |
---|
19 | |
---|
20 | // Now we need to create an odometer to add to the graph. |
---|
21 | // By default the scale will be 0 to 100 |
---|
22 | $odo = new Odometer(); |
---|
23 | $odo->SetColor('white'); |
---|
24 | $odo->SetBorder('darkgreen:0.8',5); |
---|
25 | |
---|
26 | $odo->scale->label->SetFont(FF_ARIAL,FS_BOLD,10); |
---|
27 | $odo->scale->label->SetColor('brown:0.6'); |
---|
28 | |
---|
29 | // Set display value for the odometer |
---|
30 | $odo->needle->Set(70); |
---|
31 | |
---|
32 | // Add drop shadow for needle |
---|
33 | $odo->needle->SetShadow(); |
---|
34 | |
---|
35 | // Add the odometer to the graph |
---|
36 | $graph->Add($odo); |
---|
37 | |
---|
38 | // ... and finally stroke and stream the image back to the browser |
---|
39 | $graph->Stroke(); |
---|
40 | |
---|
41 | ?> |
---|