Ejemplo n.º 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();
Ejemplo n.º 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);
    $wp[$i]->scale->SetFontColor('navy');