示例#1
0
<?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();
示例#2
0
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Data can be specified using both ordinal index of the axis
// as well as the direction label
$data[0] = array(0 => array(1, 1, 2.5, 4), 1 => array(3, 4, 1, 4), 3 => array(2, 7, 4, 4, 3), 5 => array(2, 7, 1, 2));
$data[1] = array("n" => array(1, 1, 2.5, 4), "ssw" => array(3, 4, 1, 4), "se" => array(2, 7, 4, 4, 3));
// Store the position and size data for each plot in an
// array to make it easier to create multiple plots.
// The format choosen for the layout data is
// (type,x-pos,y-pos,size, z-circle size)
$layout = array(array(WINDROSE_TYPE8, 0.25, 0.55, 0.4, 0.25), array(WINDROSE_TYPE16, 0.75, 0.55, 0.4, 0.25));
$legendtxt = array('(m/s) Station 7', '(m/s) Station 12');
// First create a new windrose graph with a dropshadow
$graph = new Graph\WindroseGraph(600, 350);
$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);
示例#3
0
<?php

require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Data can be specified using both ordinal index of the axis
// as well as the direction label.
$data = array(2 => array(1, 15, 7.5, 2), 5 => array(1, 1, 1.5, 2), 7 => array(1, 2, 10, 3, 2), 8 => array(2, 3, 1, 3, 1, 2));
// First create a new windrose graph with a title
$graph = new Graph\WindroseGraph(590, 580);
$graph->title->Set('Japanese locale');
#$graph->title->SetFont(FF_VERDANA,FS_BOLD,14);
$graph->title->SetColor('navy');
// Create the free windrose plot.
$wp = new Plot\WindrosePlot($data);
$wp->SetType(WINDROSE_TYPE8);
// Add some "arbitrary" text to the center
$wp->scale->SetZeroLabel("SOx\n8%%");
// Localize the compass direction labels into Japanese
// 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('東', '', '北東', '', '北', '', '北西', '', '西', '', '南西', '', '南', '', '南東', '');
示例#4
0
<?php

require_once '../../vendor/autoload.php';
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]));
示例#5
0
<?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
$data2 = array('vsv' => array(12, 8, 2, 3), 6 => array(5, 4, 4, 5, 4));
$se_CompassLbl = array('O', 'ONO', 'NO', 'NNO', 'N', 'NNV', 'NV', 'VNV', 'V', 'VSV', 'SV', 'SSV', 'S', 'SSO', 'SO', 'OSO');
// Create a new small windrose graph
$graph = new Graph\WindroseGraph(400, 400);
$graph->SetMargin(25, 25, 25, 25);
$graph->SetFrame();
$graph->title->Set('Example with background flag');
#$graph->title->SetFont(FF_VERA,FS_BOLD,14);
//$graph->SetBackgroundImage('bkgimg.jpg',BGIMG_FILLFRAME);
//$graph->SetBackgroundImageMix(90);
$graph->SetBackgroundCFlag(28, BGIMG_FILLFRAME, 15);
$wp2 = new Plot\WindrosePlot($data2);
$wp2->SetType(WINDROSE_TYPE16);
$wp2->SetSize(0.55);
$wp2->SetPos(0.5, 0.5);
$wp2->SetAntiAlias(false);
$wp2->SetFont(FF_ARIAL, FS_BOLD, 10);
$wp2->SetFontColor('black');
$wp2->SetCompassLabels($se_CompassLbl);
$wp2->legend->SetMargin(20, 5);
$wp2->scale->SetZFont(FF_ARIAL, FS_NORMAL, 8);
$wp2->scale->SetFont(FF_ARIAL, FS_NORMAL, 9);
$wp2->scale->SetLabelFillColor('white', 'white');
$wp2->SetRangeColors(array('green', 'yellow', 'red', 'brown'));
示例#6
0
<?php

require_once '../../vendor/autoload.php';
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)));
// Create a windrose graph with titles
$graph = new Graph\WindroseGraph(600, 650);
$graph->SetShadow();
$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 < 4; ++$i) {
    $wp[$i] = new Plot\WindrosePlot($data[$i]);
    $wp[$i]->SetSize(0.22);
    $wp[$i]->SetCenterSize(0.25);
}
// 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]));
$vl = new LayoutVert(array($hl1, $hl2));
$graph->Add($vl);
$graph->Stroke();
示例#7
0
<?php

require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Data can be specified using both ordinal index of the axis
// as well as the direction label.
$data = array(0 => array(3, 2, 1, 2, 2), 4 => array(1, 1, 1.5, 2), 6 => array(1, 1, 1.5, 2), 12 => array(2, 3, 5, 1));
$xpos1 = 0.26;
$xpos2 = 0.74;
$ypos1 = 0.5;
$ypos2 = 0.9;
// First create a new windrose graph with a title
$graph = new Graph\WindroseGraph(650, 350);
$graph->title->Set('Interpretation of ordinal keys');
$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);
示例#8
0
// Data
$data = array(0 => array(1, 1, 2.5, 4), 1 => array(3, 4, 1, 4), 3 => array(2, 7, 4, 4, 3), 5 => array(2, 7, 1, 2));
// Text to be added.
$txt = array();
$txt[0] = "It is possible to add arbitrary,multi line, text to a graph. ";
$txt[0] .= "Such a paragraph can have it's text be left, right or center ";
$txt[0] .= "aligned.";
$txt[1] = "This is an example of a right aligned paragraph.";
$txt[2] = "Finally we can show a center aligned paragraph without box.";
// We store the layout for each of the text boxes in an array
// to keep the code clean
$txtlayout = array(array(0.97, 0.15, 25, 'left', 'black', 'lightblue'), array(0.97, 0.4, 20, 'right', 'black', 'lightblue'), array(0.97, 0.7, 20, 'center', 'darkred', false, FF_COMIC, FS_NORMAL, 12));
// Range colors to be used
$rangeColors = array('silver', 'khaki', 'orange', 'brown', 'blue', 'navy', 'maroon', 'red');
// First create a new windrose graph with a title
$graph = new Graph\WindroseGraph(570, 430);
$graph->title->Set('Windrose example 5');
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 12);
$graph->title->SetColor('navy');
// 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) {