source: trunk/xgraph/jpgraph/Examples/windrose_ex6.php

Last change on this file was 42, checked in by marrucho, 10 years ago
File size: 1.9 KB
Line 
1<?php
2require_once ('jpgraph/jpgraph.php');
3require_once ('jpgraph/jpgraph_windrose.php');
4
5// Data can be specified using both ordinal index of the axis
6// as well as the direction label
7$data = array(
8    '10'  => array(1,1,2.5,4),
9    '32.0' => array(3,4,1,4),
10    '120.5' => array(2,3,4,4,3,2,1),
11    '223.2' => array(2,4,1,2,2),
12    '285.7' => array(2,2,1,2,4,2,1,1)
13);
14
15// Specify text for direction labels
16$labels = array( '120.5' => "Plant\n#1275",
17                 '285.7' => "Reference\n#13 Ver:2");
18
19// Range colors to be used
20$rangeColors = array('khaki','yellow','orange','orange:0.7','brown','darkred','black');
21
22// First create a new windrose graph with a title
23$graph = new WindroseGraph(400,450);
24
25// Setup titles
26$graph->title->Set('Windrose example 6');
27$graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
28$graph->title->SetColor('navy');
29
30$graph->subtitle->Set('(Free type plot)');
31$graph->subtitle->SetFont(FF_VERDANA,FS_ITALIC,10);
32$graph->subtitle->SetColor('navy');
33
34// Create the windrose plot.
35$wp = new WindrosePlot($data);
36
37// Setup a free plot
38$wp->SetType(WINDROSE_TYPEFREE);
39
40// Setup labels
41$wp->SetLabels($labels);
42$wp->SetLabelPosition(LBLPOSITION_CENTER);
43$wp->SetLabelMargin(30);
44
45// Setup the colors for the ranges
46$wp->SetRangeColors($rangeColors);
47
48// Adjust the font and font color for scale labels
49$wp->scale->SetFont(FF_ARIAL,FS_NORMAL,9);
50
51// Set the diameter and position for plot
52$wp->SetSize(230);
53$wp->SetZCircleSize(30);
54
55// Adjust the font and font color for compass directions
56$wp->SetFont(FF_ARIAL,FS_NORMAL,10);
57$wp->SetFontColor('darkgreen');
58
59// Adjust grid colors
60$wp->SetGridColor('darkgreen@0.7','blue');
61
62// Add (m/s) text to legend
63$wp->legend->SetText('(m/s)');
64
65// Display legend values with no decimals
66$wp->legend->SetFormat('%d');
67
68// Add plot to graph and send back to the client
69$graph->Add($wp);
70$graph->Stroke();
71?>
72
Note: See TracBrowser for help on using the repository browser.