[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 | 'E' => array(3,2,1,2,2), |
---|
| 9 | 'N' => array(1,1,1.5,2), |
---|
| 10 | 'nw' => array(1,1,1.5,2), |
---|
| 11 | 'S' => array(2,3,5,1), |
---|
| 12 | ); |
---|
| 13 | |
---|
| 14 | // Define the color,weight and style of some individual radial |
---|
| 15 | // grid lines. Axis can be specified either by their (localized) |
---|
| 16 | // label or by their index. |
---|
| 17 | // Note; Depending on how many axis you have in the plot the |
---|
| 18 | // index will vary between 0..n where n is the number of |
---|
| 19 | // compass directions. |
---|
| 20 | $axiscolors = array('nw'=>'brown'); |
---|
| 21 | $axisweights = array('nw'=>8); // Could also be specified as 6 => 8 |
---|
| 22 | $axisstyles = array('nw'=>'solid'); |
---|
| 23 | |
---|
| 24 | // First create a new windrose graph with a title |
---|
| 25 | $graph = new WindroseGraph(400,500); |
---|
| 26 | $graph->title->Set('Windrose example 9'); |
---|
| 27 | $graph->title->SetFont(FF_VERDANA,FS_BOLD,14); |
---|
| 28 | $graph->title->SetColor('navy'); |
---|
| 29 | |
---|
| 30 | // Create the free windrose plot. |
---|
| 31 | $wp = new WindrosePlot($data); |
---|
| 32 | $wp->SetType(WINDROSE_TYPE16); |
---|
| 33 | |
---|
| 34 | // Specify colors weights and style for the radial gridlines |
---|
| 35 | $wp->SetRadialColors($axiscolors); |
---|
| 36 | $wp->SetRadialWeights($axisweights); |
---|
| 37 | $wp->SetRadialStyles($axisstyles); |
---|
| 38 | |
---|
| 39 | // Add some "arbitrary" text to the center |
---|
| 40 | $wp->scale->SetZeroLabel("SOx\n8%%"); |
---|
| 41 | |
---|
| 42 | // Finally add it to the graph and send back to the client |
---|
| 43 | $graph->Add($wp); |
---|
| 44 | $graph->Stroke(); |
---|
| 45 | ?> |
---|
| 46 | |
---|