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,170); |
---|
7 | |
---|
8 | // Setup graph titles |
---|
9 | $graph->title->Set('Custom formatting'); |
---|
10 | $graph->title->SetColor('white'); |
---|
11 | $graph->title->SetFont(FF_ARIAL,FS_BOLD); |
---|
12 | |
---|
13 | // Add drop shadow for graph |
---|
14 | $graph->SetShadow(); |
---|
15 | |
---|
16 | // Now we need to create an odometer to add to the graph. |
---|
17 | $odo = new Odometer(); |
---|
18 | $odo->SetColor("lightgray:1.9"); |
---|
19 | |
---|
20 | // Setup the scale |
---|
21 | $odo->scale->Set(100,600); |
---|
22 | $odo->scale->SetTicks(50,2); |
---|
23 | $odo->scale->SetTickColor('brown'); |
---|
24 | $odo->scale->SetTickLength(0.05); |
---|
25 | $odo->scale->SetTickWeight(2); |
---|
26 | |
---|
27 | $odo->scale->SetLabelPos(0.75); |
---|
28 | $odo->scale->label->SetFont(FF_FONT1, FS_BOLD); |
---|
29 | $odo->scale->label->SetColor('brown'); |
---|
30 | $odo->scale->label->SetFont(FF_ARIAL,FS_NORMAL,10); |
---|
31 | |
---|
32 | // Setup a label with a degree mark |
---|
33 | $odo->scale->SetLabelFormat('%dC'.SymChar::Get('degree')); |
---|
34 | |
---|
35 | // Set display value for the odometer |
---|
36 | $odo->needle->Set(280); |
---|
37 | |
---|
38 | // Add drop shadow for needle |
---|
39 | $odo->needle->SetShadow(); |
---|
40 | |
---|
41 | // Add the odometer to the graph |
---|
42 | $graph->Add($odo); |
---|
43 | |
---|
44 | // ... and finally stroke and stream the image back to the browser |
---|
45 | $graph->Stroke(); |
---|
46 | ?> |
---|