1 | <?php
|
---|
2 | //=============================================================================
|
---|
3 | // File: ODOEX010.PHP
|
---|
4 | // Description: Example 0 for odometer graphs
|
---|
5 | // Created: 2002-02-22
|
---|
6 | // Version: $Id$
|
---|
7 | //
|
---|
8 | // Comment:
|
---|
9 | // Example file for odometer graph. Extends odoex09.php to show how multiple
|
---|
10 | // odometers can have different properties
|
---|
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(200,300);
|
---|
21 |
|
---|
22 | //---------------------------------------------------------------------
|
---|
23 | // We will display three odometers stacked vertically
|
---|
24 | // The first thing to do is to create them
|
---|
25 | //---------------------------------------------------------------------
|
---|
26 | $odo1 = new Odometer();
|
---|
27 | $odo2 = new Odometer();
|
---|
28 | $odo3 = new Odometer();
|
---|
29 |
|
---|
30 | //---------------------------------------------------------------------
|
---|
31 | // Set Indicator bands for the odometers
|
---|
32 | //---------------------------------------------------------------------
|
---|
33 | $odo1->AddIndication(80,100,"red");
|
---|
34 | $odo2->AddIndication(20,30,"green");
|
---|
35 | $odo2->AddIndication(65,100,"red");
|
---|
36 | $odo3->AddIndication(60,90,"yellow");
|
---|
37 | $odo3->AddIndication(90,100,"red");
|
---|
38 |
|
---|
39 | //---------------------------------------------------------------------
|
---|
40 | // Set display values for the odometers
|
---|
41 | //---------------------------------------------------------------------
|
---|
42 | $odo1->needle->Set(17);
|
---|
43 | $odo2->needle->Set(47);
|
---|
44 | $odo3->needle->Set(86);
|
---|
45 |
|
---|
46 | $odo1->needle->SetFillColor("blue");
|
---|
47 | $odo2->needle->SetFillColor("yellow:0.7");
|
---|
48 | $odo3->needle->SetFillColor("black");
|
---|
49 | $odo3->needle->SetColor("black");
|
---|
50 |
|
---|
51 |
|
---|
52 | //---------------------------------------------------------------------
|
---|
53 | // Set scale label properties
|
---|
54 | //---------------------------------------------------------------------
|
---|
55 | $odo1->scale->label->SetColor("navy");
|
---|
56 | $odo2->scale->label->SetColor("blue");
|
---|
57 | $odo3->scale->label->SetColor("darkred");
|
---|
58 |
|
---|
59 | $odo1->scale->label->SetFont(FF_FONT1);
|
---|
60 | $odo2->scale->label->SetFont(FF_FONT2,FS_BOLD);
|
---|
61 | $odo3->scale->label->SetFont(FF_ARIAL,FS_BOLD,11);
|
---|
62 |
|
---|
63 | //---------------------------------------------------------------------
|
---|
64 | // Add the odometers to the graph using a vertical layout
|
---|
65 | //---------------------------------------------------------------------
|
---|
66 | $l1 = new LayoutVert( array($odo1,$odo2,$odo3) ) ;
|
---|
67 | $graph->Add( $l1 );
|
---|
68 |
|
---|
69 | //---------------------------------------------------------------------
|
---|
70 | // ... and finally stroke and stream the image back to the browser
|
---|
71 | //---------------------------------------------------------------------
|
---|
72 | $graph->Stroke();
|
---|
73 |
|
---|
74 | // EOF
|
---|
75 | ?> |
---|