Blame view

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