[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 = 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 | // First create a new windrose graph with a title |
---|
| 14 | $graph = new WindroseGraph(400,400); |
---|
| 15 | |
---|
| 16 | // Setup title |
---|
| 17 | $graph->title->Set('Windrose example 4'); |
---|
| 18 | $graph->title->SetFont(FF_VERDANA,FS_BOLD,12); |
---|
| 19 | $graph->title->SetColor('navy'); |
---|
| 20 | |
---|
| 21 | // Create the windrose plot. |
---|
| 22 | $wp = new WindrosePlot($data); |
---|
| 23 | |
---|
| 24 | // Adjust the font and font color for scale labels |
---|
| 25 | $wp->scale->SetFont(FF_TIMES,FS_NORMAL,11); |
---|
| 26 | $wp->scale->SetFontColor('navy'); |
---|
| 27 | |
---|
| 28 | // Set the diameter and position for plot |
---|
| 29 | $wp->SetSize(190); |
---|
| 30 | |
---|
| 31 | // Set the size of the innermost center circle to 40% of the plot size |
---|
| 32 | // Note that we can have the automatic "Zero" sum appear in our custom text |
---|
| 33 | $wp->SetZCircleSize(0.38); |
---|
| 34 | $wp->scale->SetZeroLabel("Station 12\n(Calm %d%%)"); |
---|
| 35 | |
---|
| 36 | // Adjust color and font for center circle text |
---|
| 37 | $wp->scale->SetZFont(FF_ARIAL,FS_NORMAL,9); |
---|
| 38 | $wp->scale->SetZFontColor('darkgreen'); |
---|
| 39 | |
---|
| 40 | // Adjust the font and font color for compass directions |
---|
| 41 | $wp->SetFont(FF_ARIAL,FS_NORMAL,10); |
---|
| 42 | $wp->SetFontColor('darkgreen'); |
---|
| 43 | |
---|
| 44 | // Adjust the margin to the compass directions |
---|
| 45 | $wp->SetLabelMargin(50); |
---|
| 46 | |
---|
| 47 | // Adjust grid colors |
---|
| 48 | $wp->SetGridColor('silver','blue'); |
---|
| 49 | |
---|
| 50 | // Add (m/s) text to legend |
---|
| 51 | $wp->legend->SetText('(m/s)'); |
---|
| 52 | $wp->legend->SetMargin(20,5); |
---|
| 53 | |
---|
| 54 | // Add and send back to client |
---|
| 55 | $graph->Add($wp); |
---|
| 56 | $graph->Stroke(); |
---|
| 57 | ?> |
---|
| 58 | |
---|