1 | <?php |
---|
2 | //============================================================================= |
---|
3 | // File: ODOEX011.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 odoex10.php with graph titles |
---|
10 | // and captions and also adds individual captions for each odometer. |
---|
11 | |
---|
12 | // |
---|
13 | // Copyright (C) 2002 Johan Persson. All rights reserved. |
---|
14 | //============================================================================= |
---|
15 | require_once ('jpgraph/jpgraph.php'); |
---|
16 | require_once ('jpgraph/jpgraph_odo.php'); |
---|
17 | |
---|
18 | //--------------------------------------------------------------------- |
---|
19 | // Create a new odometer graph (width=200, height=400 pixels) |
---|
20 | //--------------------------------------------------------------------- |
---|
21 | $graph = new OdoGraph(200,370); |
---|
22 | $graph->SetShadow(); |
---|
23 | |
---|
24 | //--------------------------------------------------------------------- |
---|
25 | // Specify title and subtitle using default fonts |
---|
26 | // * Note each title may be multilines by using a '\n' as a line |
---|
27 | // divider. |
---|
28 | //--------------------------------------------------------------------- |
---|
29 | $graph->title->Set("Result from 2002"); |
---|
30 | $graph->title->SetColor("white"); |
---|
31 | $graph->subtitle->Set("O1 - W-Site"); |
---|
32 | $graph->subtitle->SetColor("white"); |
---|
33 | |
---|
34 | //--------------------------------------------------------------------- |
---|
35 | // Specify caption. |
---|
36 | // * (This is the text at the bottom of the graph.) The margins will |
---|
37 | // automatically adjust to fit the height of the text. A caption |
---|
38 | // may have multiple lines by including a '\n' character in the |
---|
39 | // string. |
---|
40 | //--------------------------------------------------------------------- |
---|
41 | $graph->caption->Set("Fig1. Values within 85%\nconfidence intervall"); |
---|
42 | $graph->caption->SetColor("white"); |
---|
43 | |
---|
44 | //--------------------------------------------------------------------- |
---|
45 | // We will display three odometers stacked vertically |
---|
46 | // The first thing to do is to create them |
---|
47 | //--------------------------------------------------------------------- |
---|
48 | $odo1 = new Odometer(); |
---|
49 | $odo2 = new Odometer(); |
---|
50 | $odo3 = new Odometer(); |
---|
51 | |
---|
52 | |
---|
53 | //--------------------------------------------------------------------- |
---|
54 | // Set caption for each odometer |
---|
55 | //--------------------------------------------------------------------- |
---|
56 | $odo1->caption->Set("April"); |
---|
57 | $odo1->caption->SetFont(FF_FONT2,FS_BOLD); |
---|
58 | $odo2->caption->Set("May"); |
---|
59 | $odo2->caption->SetFont(FF_FONT2,FS_BOLD); |
---|
60 | $odo3->caption->Set("June"); |
---|
61 | $odo3->caption->SetFont(FF_FONT2,FS_BOLD); |
---|
62 | |
---|
63 | //--------------------------------------------------------------------- |
---|
64 | // Set Indicator bands for the odometers |
---|
65 | //--------------------------------------------------------------------- |
---|
66 | $odo1->AddIndication(80,100,"red"); |
---|
67 | $odo2->AddIndication(20,30,"green"); |
---|
68 | $odo2->AddIndication(65,100,"red"); |
---|
69 | $odo3->AddIndication(60,90,"yellow"); |
---|
70 | $odo3->AddIndication(90,100,"red"); |
---|
71 | |
---|
72 | //--------------------------------------------------------------------- |
---|
73 | // Set display values for the odometers |
---|
74 | //--------------------------------------------------------------------- |
---|
75 | $odo1->needle->Set(17); |
---|
76 | $odo2->needle->Set(47); |
---|
77 | $odo3->needle->Set(86); |
---|
78 | |
---|
79 | $odo1->needle->SetFillColor("blue"); |
---|
80 | $odo2->needle->SetFillColor("yellow:0.7"); |
---|
81 | $odo3->needle->SetFillColor("black"); |
---|
82 | $odo3->needle->SetColor("black"); |
---|
83 | |
---|
84 | |
---|
85 | //--------------------------------------------------------------------- |
---|
86 | // Set scale label properties |
---|
87 | //--------------------------------------------------------------------- |
---|
88 | $odo1->scale->label->SetColor("navy"); |
---|
89 | $odo2->scale->label->SetColor("blue"); |
---|
90 | $odo3->scale->label->SetColor("darkred"); |
---|
91 | |
---|
92 | $odo1->scale->label->SetFont(FF_FONT1); |
---|
93 | $odo2->scale->label->SetFont(FF_FONT2,FS_BOLD); |
---|
94 | $odo3->scale->label->SetFont(FF_ARIAL,FS_BOLD,10); |
---|
95 | |
---|
96 | //--------------------------------------------------------------------- |
---|
97 | // Add the odometers to the graph using a vertical layout |
---|
98 | //--------------------------------------------------------------------- |
---|
99 | $l1 = new LayoutVert( array($odo1,$odo2,$odo3) ) ; |
---|
100 | $graph->Add( $l1 ); |
---|
101 | |
---|
102 | //--------------------------------------------------------------------- |
---|
103 | // ... and finally stroke and stream the image back to the browser |
---|
104 | //--------------------------------------------------------------------- |
---|
105 | $graph->Stroke(); |
---|
106 | |
---|
107 | // EOF |
---|
108 | ?> |
---|