[42] | 1 | <?php |
---|
| 2 | //============================================================================= |
---|
| 3 | // File: ODOEX03.PHP |
---|
| 4 | // Description: Example 1 for odometer graphs |
---|
| 5 | // Created: 2002-02-22 |
---|
| 6 | // Version: $Id$ |
---|
| 7 | // |
---|
| 8 | // Comment: |
---|
| 9 | // Example file for odometer graph. This examples extends odoex02 |
---|
| 10 | // by changing scale tick interval and scale fonts. |
---|
| 11 | // |
---|
| 12 | // Copyright (C) 2002 Johan Persson. All rights reserved. |
---|
| 13 | //============================================================================= |
---|
| 14 | require_once ('jpgraph/jpgraph.php'); |
---|
| 15 | require_once ('jpgraph/jpgraph_odo.php'); |
---|
| 16 | |
---|
| 17 | //--------------------------------------------------------------------- |
---|
| 18 | // Create a new odometer graph (width=250, height=200 pixels) |
---|
| 19 | //--------------------------------------------------------------------- |
---|
| 20 | $graph = new OdoGraph(250,200); |
---|
| 21 | $graph->SetShadow(); |
---|
| 22 | |
---|
| 23 | //--------------------------------------------------------------------- |
---|
| 24 | // Specify title and subtitle using default fonts |
---|
| 25 | // * Note each title may be multilines by using a '\n' as a line |
---|
| 26 | // divider. |
---|
| 27 | //--------------------------------------------------------------------- |
---|
| 28 | $graph->title->Set("Odometer title"); |
---|
| 29 | $graph->title->SetColor("white"); |
---|
| 30 | $graph->subtitle->Set("2002-02-13"); |
---|
| 31 | $graph->subtitle->SetColor("white"); |
---|
| 32 | |
---|
| 33 | //--------------------------------------------------------------------- |
---|
| 34 | // Specify caption. |
---|
| 35 | // * (This is the text at the bottom of the graph.) The margins will |
---|
| 36 | // automatically adjust to fit the height of the text. A caption |
---|
| 37 | // may have multiple lines by including a '\n' character in the |
---|
| 38 | // string. |
---|
| 39 | //--------------------------------------------------------------------- |
---|
| 40 | $graph->caption->Set("First caption row\n... second row"); |
---|
| 41 | $graph->caption->SetColor("white"); |
---|
| 42 | |
---|
| 43 | //--------------------------------------------------------------------- |
---|
| 44 | // Now we need to create an odometer to add to the graph. |
---|
| 45 | // By default the scale will be 0 to 100 |
---|
| 46 | //--------------------------------------------------------------------- |
---|
| 47 | $odo = new Odometer(); |
---|
| 48 | |
---|
| 49 | //--------------------------------------------------------------------- |
---|
| 50 | // Set color indication |
---|
| 51 | //--------------------------------------------------------------------- |
---|
| 52 | $odo->AddIndication(0,50,"green"); |
---|
| 53 | $odo->AddIndication(50,80,"yellow"); |
---|
| 54 | $odo->AddIndication(80,100,"red"); |
---|
| 55 | |
---|
| 56 | //--------------------------------------------------------------------- |
---|
| 57 | // Adjust scale ticks to be shown at 10 steps interval and scale |
---|
| 58 | // labels at every second tick |
---|
| 59 | //--------------------------------------------------------------------- |
---|
| 60 | $odo->scale->SetTicks(10,2); |
---|
| 61 | |
---|
| 62 | //--------------------------------------------------------------------- |
---|
| 63 | // Use a bold font for tick labels |
---|
| 64 | //--------------------------------------------------------------------- |
---|
| 65 | $odo->scale->label->SetFont(FF_FONT1, FS_BOLD); |
---|
| 66 | |
---|
| 67 | //--------------------------------------------------------------------- |
---|
| 68 | // Set display value for the odometer |
---|
| 69 | //--------------------------------------------------------------------- |
---|
| 70 | $odo->needle->Set(30); |
---|
| 71 | |
---|
| 72 | //--------------------------------------------------------------------- |
---|
| 73 | // Add the odometer to the graph |
---|
| 74 | //--------------------------------------------------------------------- |
---|
| 75 | $graph->Add($odo); |
---|
| 76 | |
---|
| 77 | //--------------------------------------------------------------------- |
---|
| 78 | // ... and finally stroke and stream the image back to the browser |
---|
| 79 | //--------------------------------------------------------------------- |
---|
| 80 | $graph->Stroke(); |
---|
| 81 | |
---|
| 82 | // EOF |
---|
| 83 | ?> |
---|