[42] | 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 | // Set display value for the odometer |
---|
| 25 | $odo->needle->Set(90); |
---|
| 26 | |
---|
| 27 | // Set the size of the non-colored base area to 40% of the radius |
---|
| 28 | $odo->SetCenterAreaWidth(0.45); |
---|
| 29 | |
---|
| 30 | // Add drop shadow for needle |
---|
| 31 | $odo->needle->SetShadow(); |
---|
| 32 | |
---|
| 33 | // Setup the second needle |
---|
| 34 | $odo->needle2->Set(44); |
---|
| 35 | $odo->needle2->Show(); |
---|
| 36 | $odo->needle2->SetLength(0.4); |
---|
| 37 | $odo->needle2->SetFillColor("navy"); |
---|
| 38 | $odo->needle2->SetShadow(); |
---|
| 39 | |
---|
| 40 | // Add the odometer to the graph |
---|
| 41 | $graph->Add($odo); |
---|
| 42 | |
---|
| 43 | // ... and finally stroke and stream the image back to the browser |
---|
| 44 | $graph->Stroke(); |
---|
| 45 | |
---|
| 46 | // EOF |
---|
| 47 | ?> |
---|