// Note: The labels for data must now also match the exact // string for the compass directions. // // E 東 // NE 北東 // N 北 // NW 北西 // W 西 // SW 南西 // S 南 // SE 南東 $jp_CompassLbl = array('東', '', '北東', '', '北', '', '北西', '', '西', '', '南西', '', '南', '', '南東', ''); $wp->SetCompassLabels($jp_CompassLbl); #$wp->SetFont(FF_MINCHO,FS_NORMAL,15); // Localize the "Calm" text into Swedish and make the circle // slightly bigger than default $jp_calmtext = '平穏'; $wp->legend->SetCircleText($jp_calmtext); $wp->legend->SetCircleRadius(20); #$wp->legend->SetCFont(FF_MINCHO,FS_NORMAL,10); $wp->legend->SetMargin(5, 0); $wp->SetPos(0.5, 0.5); // Adjust the displayed ranges $ranges = array(1, 3, 5, 8, 12, 19, 29); $wp->SetRanges($ranges); // Set the scale to always have max value of 30 $wp->scale->Set(30, 10); #$wp->scale->SetFont(FF_VERA,FS_NORMAL,12); // Finally add it to the graph and send back to client $graph->Add($wp); $graph->Stroke();
<?php require_once '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; // Data can be specified using both ordinal idex of axis as well // as the direction label $data = array(1 => array(10, 10, 13, 7), 2 => array(2, 8, 10), 4 => array(1, 12, 22)); $data2 = array(4 => array(12, 8, 2, 3), 2 => array(5, 4, 4, 5, 2)); // Create a new small windrose graph $graph = new Graph\WindroseGraph(660, 400); $graph->SetShadow(); $graph->title->Set('Two windrose plots in one graph'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); $graph->subtitle->Set('(Using Box() for each plot)'); $wp = new Plot\WindrosePlot($data); $wp->SetType(WINDROSE_TYPE8); $wp->SetSize(0.42); $wp->SetPos(0.25, 0.55); $wp->SetBox(); $wp2 = new Plot\WindrosePlot($data2); $wp2->SetType(WINDROSE_TYPE16); $wp2->SetSize(0.42); $wp2->SetPos(0.74, 0.55); $wp2->SetBox(); $wp2->SetRangeColors(array('green', 'yellow', 'red', 'brown')); $graph->Add($wp); $graph->Add($wp2); $graph->Stroke();
$graph->SetShadow('darkgray'); // Setup titles $graph->title->Set('Windrose example 3'); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 12); $graph->title->SetColor('navy'); $graph->subtitle->Set('(Multiple plots in the same graph)'); $graph->subtitle->SetFont(FF_VERDANA, FS_NORMAL, 9); $graph->subtitle->SetColor('navy'); // Create the two windrose plots. for ($i = 0; $i < count($data); ++$i) { $wp[$i] = new Plot\WindrosePlot($data[$i]); // Make it have 8 compass direction $wp[$i]->SetType($layout[$i][0]); // Adjust the font and font color for scale labels $wp[$i]->scale->SetFont(FF_TIMES, FS_NORMAL, 10); $wp[$i]->scale->SetFontColor('navy'); // Set the position of the plot $wp[$i]->SetPos($layout[$i][1], $layout[$i][2]); // Set the diameter for the plot to 30% of the width of the graph pixels $wp[$i]->SetSize($layout[$i][3]); // Set the size of the innermost center circle to 30% of the plot size $wp[$i]->SetZCircleSize($layout[$i][4]); // Adjust the font and font color for compass directions $wp[$i]->SetFont(FF_ARIAL, FS_NORMAL, 10); $wp[$i]->SetFontColor('darkgreen'); // Add legend text $wp[$i]->legend->SetText($legendtxt[$i]); $graph->Add($wp[$i]); } // Send the graph to the browser $graph->Stroke();
use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; // Some data for the five windrose plots $data = array(array(1 => array(10, 10, 13, 7), 2 => array(2, 8, 10), 4 => array(1, 12, 22)), array(4 => array(12, 8, 2, 3), 2 => array(5, 4, 4, 5, 2)), array(1 => array(12, 8, 2, 3), 3 => array(5, 4, 4, 5, 2)), array(2 => array(12, 8, 2, 3), 3 => array(5, 4, 4, 5, 2)), array(4 => array(12, 8, 2, 3), 6 => array(5, 4, 4, 5, 2))); // Legend range colors $rangecolors = array('green', 'yellow', 'red', 'brown'); // Create a windrose graph with titles $graph = new Graph\WindroseGraph(750, 700); $graph->title->Set('Multiple plots with automatic layout'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); // Setup the individual windrose plots $wp = array(); for ($i = 0; $i < 5; ++$i) { $wp[$i] = new Plot\WindrosePlot($data[$i]); $wp[$i]->SetType(WINDROSE_TYPE8); if ($i < 2) { $wp[$i]->SetSize(0.28); } else { $wp[$i]->legend->Hide(); $wp[$i]->SetSize(0.16); $wp[$i]->SetCenterSize(0.25); } $wp[$i]->SetRangeColors($rangecolors); } // Position with two rows. Two plots in top row and three plots in // bottom row. $hl1 = new LayoutHor(array($wp[0], $wp[1])); $hl2 = new LayoutHor(array($wp[2], $wp[3], $wp[4])); $vl = new LayoutVert(array($hl1, $hl2)); $graph->Add($vl); $graph->Stroke();
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 14); $graph->title->SetColor('navy'); // Create the first plot $wp1 = new Plot\WindrosePlot($data); $wp1->SetType(WINDROSE_TYPE16); // This is the default encoding $wp1->SetDataKeyEncoding(KEYENCODING_ANTICLOCKWISE); $wp1->legend->Hide(); $wp1->SetPos($xpos1, $ypos1); $wp1->SetSize(0.5); // Create the second plot $wp2 = new Plot\WindrosePlot($data); $wp2->SetType(WINDROSE_TYPE16); $wp2->SetDataKeyEncoding(KEYENCODING_CLOCKWISE); $wp2->legend->Hide(); $wp2->SetPos($xpos2, $ypos1); $wp2->SetSize(0.5); $txt1 = new Text('KEYENCODING_ANTICLOCKWISE'); $txt1->SetFont(FF_COURIER, FS_BOLD, 12); $txt1->SetPos($xpos1, $ypos2); $txt1->SetAlign('center', 'top'); $txt2 = new Text('KEYENCODING_CLOCKWISE'); $txt2->SetFont(FF_COURIER, FS_BOLD, 12); $txt2->SetPos($xpos2, $ypos2); $txt2->SetAlign('center', 'top'); // Finally add it to the graph and send back to the client $graph->Add($wp1); $graph->Add($txt1); $graph->Add($wp2); $graph->Add($txt2); $graph->Stroke();
<?php require_once '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; $data = array(0 => array(1, 1, 2.5, 4), 1 => array(3, 4, 1, 4), 'wsw' => array(1, 5, 5, 3), 'N' => array(2, 7, 5, 4, 2), 15 => array(2, 7, 12)); // First create a new windrose graph with a title $graph = new Graph\WindroseGraph(400, 400); // Creta an icon to be added to the graph $icon = new IconPlot('tornado.jpg', 10, 10, 1.3, 50); $icon->SetAnchor('left', 'top'); $graph->Add($icon); // Setup title $graph->title->Set('Windrose icon example'); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 12); $graph->title->SetColor('navy'); // Create the windrose plot. $wp = new Plot\WindrosePlot($data); // Add to graph and send back to client $graph->Add($wp); $graph->Stroke();
// Setup graph background color $graph->SetColor('darkgreen@0.7'); // Setup all the defined text boxes $n = count($txt); for ($i = 0; $i < $n; ++$i) { $txtbox[$i] = new Text($txt[$i]); $txtbox[$i]->SetPos($txtlayout[$i][0], $txtlayout[$i][1], 'right'); $txtbox[$i]->SetWordwrap($txtlayout[$i][2]); $txtbox[$i]->SetParagraphAlign($txtlayout[$i][3]); $txtbox[$i]->SetColor($txtlayout[$i][4]); $txtbox[$i]->SetBox($txtlayout[$i][5]); if (count($txtlayout[$i]) > 6) { $txtbox[$i]->SetFont($txtlayout[$i][6], $txtlayout[$i][7], $txtlayout[$i][8]); } } $graph->Add($txtbox); // Create the windrose plot. $wp = new Plot\WindrosePlot($data); // Set background color for plot area $wp->SetColor('lightyellow'); // Add a box around the plot $wp->SetBox(); // 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); $wp->scale->SetFontColor('navy'); // Set the diameter and position for plot $wp->SetSize(190); $wp->SetPos(0.35, 0.53); $wp->SetZCircleSize(0.2);