[42] | 1 | <?php
|
---|
| 2 | //=============================================================================
|
---|
| 3 | // File: ODOEX012.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 odoex11.php to add two more
|
---|
| 10 | // odometers to the image and showing more layout possibilities
|
---|
| 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=400, height=400 pixels)
|
---|
| 19 | //---------------------------------------------------------------------
|
---|
| 20 | $graph = new OdoGraph(400,370);
|
---|
| 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("Result from 2002");
|
---|
| 29 | $graph->title->SetColor("white");
|
---|
| 30 | $graph->subtitle->Set("O1 - W-Site");
|
---|
| 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("Fig1. Values within 85%\nconfidence intervall");
|
---|
| 41 | $graph->caption->SetColor("white");
|
---|
| 42 |
|
---|
| 43 | //---------------------------------------------------------------------
|
---|
| 44 | // We will display two columns where the first column has
|
---|
| 45 | // three odometers (same as in example 11) and the second column
|
---|
| 46 | // has two odoemters
|
---|
| 47 | // The first thing to do is to create them
|
---|
| 48 | //---------------------------------------------------------------------
|
---|
| 49 | $odo1 = new Odometer();
|
---|
| 50 | $odo2 = new Odometer();
|
---|
| 51 | $odo3 = new Odometer();
|
---|
| 52 | $odo4 = new Odometer();
|
---|
| 53 | $odo5 = new Odometer();
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | //---------------------------------------------------------------------
|
---|
| 57 | // Set caption for each odometer
|
---|
| 58 | //---------------------------------------------------------------------
|
---|
| 59 | $odo1->caption->Set("April");
|
---|
| 60 | $odo1->caption->SetFont(FF_ARIAL,FS_BOLD);
|
---|
| 61 | $odo2->caption->Set("May");
|
---|
| 62 | $odo2->caption->SetFont(FF_FONT2,FS_BOLD);
|
---|
| 63 | $odo3->caption->Set("June");
|
---|
| 64 | $odo3->caption->SetFont(FF_FONT2,FS_BOLD);
|
---|
| 65 | $odo4->caption->Set("Daily low average");
|
---|
| 66 | $odo4->caption->SetFont(FF_FONT1,FS_BOLD);
|
---|
| 67 | $odo5->caption->Set("Daily high average");
|
---|
| 68 | $odo5->caption->SetFont(FF_FONT1,FS_BOLD);
|
---|
| 69 |
|
---|
| 70 | //---------------------------------------------------------------------
|
---|
| 71 | // Set Indicator bands for the odometers
|
---|
| 72 | //---------------------------------------------------------------------
|
---|
| 73 | $odo1->AddIndication(80,100,"red");
|
---|
| 74 | $odo2->AddIndication(20,30,"green");
|
---|
| 75 | $odo2->AddIndication(65,100,"red");
|
---|
| 76 | $odo3->AddIndication(60,90,"yellow");
|
---|
| 77 | $odo3->AddIndication(90,100,"red");
|
---|
| 78 |
|
---|
| 79 | //---------------------------------------------------------------------
|
---|
| 80 | // Set display values for the odometers
|
---|
| 81 | //---------------------------------------------------------------------
|
---|
| 82 | $odo1->needle->Set(17);
|
---|
| 83 | $odo2->needle->Set(47);
|
---|
| 84 | $odo3->needle->Set(86);
|
---|
| 85 | $odo4->needle->Set(22);
|
---|
| 86 | $odo5->needle->Set(77);
|
---|
| 87 |
|
---|
| 88 | $odo1->needle->SetFillColor("blue");
|
---|
| 89 | $odo2->needle->SetFillColor("yellow:0.7");
|
---|
| 90 | $odo3->needle->SetFillColor("black");
|
---|
| 91 | $odo3->needle->SetColor("black");
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 | //---------------------------------------------------------------------
|
---|
| 95 | // Set scale label properties
|
---|
| 96 | //---------------------------------------------------------------------
|
---|
| 97 | $odo1->scale->label->SetColor("navy");
|
---|
| 98 | $odo2->scale->label->SetColor("blue");
|
---|
| 99 | $odo3->scale->label->SetColor("darkred");
|
---|
| 100 |
|
---|
| 101 | $odo1->scale->label->SetFont(FF_FONT1);
|
---|
| 102 | $odo2->scale->label->SetFont(FF_FONT2,FS_BOLD);
|
---|
| 103 | $odo3->scale->label->SetFont(FF_ARIAL,FS_BOLD,10);
|
---|
| 104 |
|
---|
| 105 | //---------------------------------------------------------------------
|
---|
| 106 | // Add the odometers to the graph using a vertical layout
|
---|
| 107 | //---------------------------------------------------------------------
|
---|
| 108 | $l1 = new LayoutVert( array($odo1,$odo2,$odo3) ) ;
|
---|
| 109 | $l2 = new LayoutVert( array($odo4,$odo5) ) ;
|
---|
| 110 | $l3 = new LayoutHor( array($l1,$l2) );
|
---|
| 111 | $graph->Add( $l3 );
|
---|
| 112 |
|
---|
| 113 | //---------------------------------------------------------------------
|
---|
| 114 | // ... and finally stroke and stream the image back to the browser
|
---|
| 115 | //---------------------------------------------------------------------
|
---|
| 116 | $graph->Stroke();
|
---|
| 117 |
|
---|
| 118 | // EOF
|
---|
| 119 | ?> |
---|