| 1 | <?php
|
|---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
|---|
| 3 | require_once ('jpgraph/jpgraph_windrose.php');
|
|---|
| 4 |
|
|---|
| 5 | $data = array(
|
|---|
| 6 | '10' => array(1,1,2.5,4),
|
|---|
| 7 | '32.0' => array(3,4,1,4),
|
|---|
| 8 | '120.5' => array(2,3,4,4,3,2,1),
|
|---|
| 9 | '223.2' => array(2,4,1,2,2),
|
|---|
| 10 | '285.7' => array(2,2,1,2,4,2,1,1)
|
|---|
| 11 | );
|
|---|
| 12 |
|
|---|
| 13 | // This file is encode din utf-8. The two Kanji characters roughly means
|
|---|
| 14 | // äž = Chinese
|
|---|
| 15 | // æ = Sentences
|
|---|
| 16 | $ctxt = 'äžæ';
|
|---|
| 17 |
|
|---|
| 18 | // Specify text for direction labels
|
|---|
| 19 | $labels = array(
|
|---|
| 20 | '120.5' => $ctxt,
|
|---|
| 21 | '232.2' => "Reference\n#13 Ver:2");
|
|---|
| 22 |
|
|---|
| 23 | // Range colors to be used
|
|---|
| 24 | $rangeColors = array('khaki','yellow','orange','orange:0.7','brown','darkred','black');
|
|---|
| 25 |
|
|---|
| 26 | // First create a new windrose graph with a title
|
|---|
| 27 | $graph = new WindroseGraph(400,450);
|
|---|
| 28 |
|
|---|
| 29 | // Setup title
|
|---|
| 30 | $graph->title->Set('Using chinese charecters');
|
|---|
| 31 | #$graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
|
|---|
| 32 | $graph->title->SetColor('navy');
|
|---|
| 33 | $graph->subtitle->Set('(Free type plot)');
|
|---|
| 34 | #$graph->subtitle->SetFont(FF_VERDANA,FS_ITALIC,10);
|
|---|
| 35 | $graph->subtitle->SetColor('navy');
|
|---|
| 36 |
|
|---|
| 37 | // Create the windrose plot.
|
|---|
| 38 | $wp = new WindrosePlot($data);
|
|---|
| 39 |
|
|---|
| 40 | // Setup a free plot
|
|---|
| 41 | $wp->SetType(WINDROSE_TYPEFREE);
|
|---|
| 42 |
|
|---|
| 43 | // Setup labels
|
|---|
| 44 | $wp->SetLabels($labels);
|
|---|
| 45 | $wp->SetLabelPosition(LBLPOSITION_CENTER);
|
|---|
| 46 | $wp->SetLabelMargin(30);
|
|---|
| 47 |
|
|---|
| 48 | // Setup the colors for the ranges
|
|---|
| 49 | $wp->SetRangeColors($rangeColors);
|
|---|
| 50 |
|
|---|
| 51 | // Adjust the font and font color for scale labels
|
|---|
| 52 | #$wp->scale->SetFont(FF_ARIAL,FS_NORMAL,9);
|
|---|
| 53 |
|
|---|
| 54 | // Set the diameter and position for plot
|
|---|
| 55 | #$wp->SetSize(240);
|
|---|
| 56 | $wp->SetSize(200);
|
|---|
| 57 | $wp->SetZCircleSize(30);
|
|---|
| 58 | $wp->SetPos(0.5,0.5);
|
|---|
| 59 |
|
|---|
| 60 | // Adjust the font and font color for compass directions
|
|---|
| 61 | #$wp->SetFont(FF_CHINESE,FS_NORMAL,12);
|
|---|
| 62 | $wp->SetFontColor('darkgreen');
|
|---|
| 63 |
|
|---|
| 64 | // Adjust grid colors
|
|---|
| 65 | $wp->SetGridColor('darkgreen@0.7','blue');
|
|---|
| 66 |
|
|---|
| 67 | // Add (m/s) text to legend
|
|---|
| 68 | $wp->legend->SetText('(m/s)');
|
|---|
| 69 | $wp->legend->SetTFontColor('blue');
|
|---|
| 70 |
|
|---|
| 71 | // Set legend label font color
|
|---|
| 72 | $wp->legend->SetLFontColor('orange:0.7');
|
|---|
| 73 | #$wp->legend->SetLFont(FF_ARIAL,FS_ITALIC,8);
|
|---|
| 74 |
|
|---|
| 75 | // Display legend values with no decimals
|
|---|
| 76 | $wp->legend->SetFormat('%d');
|
|---|
| 77 |
|
|---|
| 78 | // Set the circle font to use chinse character set
|
|---|
| 79 | // Note: When FF_CHINESE is used the input charectr data are
|
|---|
| 80 | // assumed to already be in utf-8 encoding
|
|---|
| 81 | #$wp->legend->SetCFont(FF_CHINESE,FS_NORMAL,14);
|
|---|
| 82 | $wp->legend->SetCircleText($ctxt);
|
|---|
| 83 | $wp->legend->SetCFontColor('red');
|
|---|
| 84 |
|
|---|
| 85 | // Add plot to graph and send back to client
|
|---|
| 86 | $graph->Add($wp);
|
|---|
| 87 | $graph->Stroke();
|
|---|
| 88 | ?>
|
|---|
| 89 |
|
|---|