source: trunk/xgraph/jpgraph/Examples/odoex02.php @ 42

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 2.9 KB
Line 
1<?php
2//=============================================================================
3// File:        ODOEX02.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 odoex01
10// by adding several indicator bands to the fascia.
11//
12// Copyright (C) 2002 Johan Persson. All rights reserved.
13//=============================================================================
14require_once ('jpgraph/jpgraph.php');
15require_once ('jpgraph/jpgraph_odo.php');
16
17//---------------------------------------------------------------------
18// Create a new odometer graph (width=250, height=200 pixels)
19//---------------------------------------------------------------------
20$graph = new OdoGraph(300,200);
21
22//---------------------------------------------------------------------
23// Specify title and subtitle using default fonts
24// * Note each title may be multilines by using a '\n' as a line
25// divider.
26//---------------------------------------------------------------------
27$graph->title->Set("Odometer title");
28$graph->title->SetColor("white");
29$graph->subtitle->Set("2002-02-13");
30$graph->subtitle->SetColor("white");
31
32//---------------------------------------------------------------------
33// Specify caption.
34// * (This is the text at the bottom of the graph.) The margins will
35// automatically adjust to fit the height of the text. A caption
36// may have multiple lines by including a '\n' character in the
37// string.
38//---------------------------------------------------------------------
39$graph->caption->Set("First caption row\n... second row");
40$graph->caption->SetColor("white");
41
42//---------------------------------------------------------------------
43// Now we need to create an odometer to add to the graph.
44// By default the scale will be 0 to 100
45//---------------------------------------------------------------------
46$odo = new Odometer(); 
47
48//---------------------------------------------------------------------
49// Set color indication
50//---------------------------------------------------------------------
51$odo->AddIndication(0,50,"green");
52$odo->AddIndication(50,80,"yellow");
53$odo->AddIndication(80,100,"red");
54
55//---------------------------------------------------------------------
56// Set display value for the odometer
57//---------------------------------------------------------------------
58$odo->needle->Set(30);
59
60//---------------------------------------------------------------------
61// Add the odometer to the graph
62//---------------------------------------------------------------------
63$graph->Add($odo);
64
65//---------------------------------------------------------------------
66// ... and finally stroke and stream the image back to the browser
67//---------------------------------------------------------------------
68$graph->Stroke();
69
70// EOF
71?>
Note: See TracBrowser for help on using the repository browser.