[42] | 1 | <?php
|
---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
---|
| 3 | require_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[0] = array(
|
---|
| 8 | 0 => array(1,1,2.5,4),
|
---|
| 9 | 1 => array(3,4,1,4),
|
---|
| 10 | 3 => array(2,7,4,4,3),
|
---|
| 11 | 5 => array(2,7,1,2));
|
---|
| 12 |
|
---|
| 13 | $data[1] = array(
|
---|
| 14 | "n" => array(1,1,2.5,4),
|
---|
| 15 | "ssw" => array(3,4,1,4),
|
---|
| 16 | "se" => array(2,7,4,4,3));
|
---|
| 17 |
|
---|
| 18 | // Store the position and size data for each plot in an
|
---|
| 19 | // array to make it easier to create multiple plots.
|
---|
| 20 | // The format choosen for the layout data is
|
---|
| 21 | // (type,x-pos,y-pos,size, z-circle size)
|
---|
| 22 | $layout = array(
|
---|
| 23 | array(WINDROSE_TYPE8,0.25,0.55,0.4,0.25),
|
---|
| 24 | array(WINDROSE_TYPE16,0.75,0.55,0.4,0.25));
|
---|
| 25 |
|
---|
| 26 | $legendtxt = array('(m/s) Station 7','(m/s) Station 12');
|
---|
| 27 |
|
---|
| 28 | // First create a new windrose graph with a dropshadow
|
---|
| 29 | $graph = new WindroseGraph(600,350);
|
---|
| 30 | $graph->SetShadow('darkgray');
|
---|
| 31 |
|
---|
| 32 | // Setup titles
|
---|
| 33 | $graph->title->Set('Windrose example 3');
|
---|
| 34 | $graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
|
---|
| 35 | $graph->title->SetColor('navy');
|
---|
| 36 | $graph->subtitle->Set('(Multiple plots in the same graph)');
|
---|
| 37 | $graph->subtitle->SetFont(FF_VERDANA,FS_NORMAL,9);
|
---|
| 38 | $graph->subtitle->SetColor('navy');
|
---|
| 39 |
|
---|
| 40 | // Create the two windrose plots.
|
---|
| 41 | for( $i=0; $i < count($data); ++$i ) {
|
---|
| 42 | $wp[$i] = new WindrosePlot($data[$i]);
|
---|
| 43 |
|
---|
| 44 | // Make it have 8 compass direction
|
---|
| 45 | $wp[$i]->SetType($layout[$i][0]);
|
---|
| 46 |
|
---|
| 47 | // Adjust the font and font color for scale labels
|
---|
| 48 | $wp[$i]->scale->SetFont(FF_TIMES,FS_NORMAL,10);
|
---|
| 49 | $wp[$i]->scale->SetFontColor('navy');
|
---|
| 50 |
|
---|
| 51 | // Set the position of the plot
|
---|
| 52 | $wp[$i]->SetPos($layout[$i][1],$layout[$i][2]);
|
---|
| 53 |
|
---|
| 54 | // Set the diameter for the plot to 30% of the width of the graph pixels
|
---|
| 55 | $wp[$i]->SetSize($layout[$i][3]);
|
---|
| 56 |
|
---|
| 57 | // Set the size of the innermost center circle to 30% of the plot size
|
---|
| 58 | $wp[$i]->SetZCircleSize($layout[$i][4]);
|
---|
| 59 |
|
---|
| 60 | // Adjust the font and font color for compass directions
|
---|
| 61 | $wp[$i]->SetFont(FF_ARIAL,FS_NORMAL,10);
|
---|
| 62 | $wp[$i]->SetFontColor('darkgreen');
|
---|
| 63 |
|
---|
| 64 | // Add legend text
|
---|
| 65 | $wp[$i]->legend->SetText($legendtxt[$i]);
|
---|
| 66 |
|
---|
| 67 | $graph->Add($wp[$i]);
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | // Send the graph to the browser
|
---|
| 71 | $graph->Stroke();
|
---|
| 72 | ?>
|
---|
| 73 |
|
---|