Пример #1
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_windrose.php';
// Data can be specified using both ordinal index of the axis
// as well as the direction label.
$data = array('45.9' => array(3, 2, 1, 2, 2), 355 => array(1, 1, 1.5, 2), 180 => array(1, 1, 1.5, 2), 150 => array(1, 2, 1, 3), 'S' => array(2, 3, 5, 1));
// Add some labels for  afew of the directions
$labels = array(355 => "At\nHome base", 180 => "Probe\n123", 150 => "Power\nplant");
// Define the color,weight and style of some individual radial grid lines.
$axiscolors = array(355 => "red");
$axisweights = array(355 => 8);
$axisstyles = array(355 => 'solid', 150 => 'solid');
// First create a new windrose graph with a title
$graph = new WindroseGraph(400, 460);
$graph->title->Set('Adding label backgrounds');
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 14);
$graph->title->SetColor('navy');
// Create the free windrose plot.
$wp = new WindrosePlot($data);
$wp->SetType(WINDROSE_TYPEFREE);
$wp->scale->SetLabelFillColor('lightblue', 'black');
// Specify colors weights and style for the radial gridlines
$wp->SetRadialColors($axiscolors);
$wp->SetRadialWeights($axisweights);
$wp->SetRadialStyles($axisstyles);
// Add a few labels
$wp->SetLabels($labels);
// Add some "arbitrary" text to the center
$wp->scale->SetZeroLabel("SOx\n8%%");
// Finally add it to the graph and send back to client
Пример #2
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_windrose.php';
// 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 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 WindrosePlot($data);
$wp->SetType(WINDROSE_TYPE8);
$wp->SetSize(0.42);
$wp->SetPos(0.25, 0.55);
$wp->SetBox();
$wp2 = new 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();
?>

Пример #3
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_windrose.php';
// 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 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 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);
Пример #4
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_windrose.php';
// 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 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 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 WindrosePlot($data);
$wp2->SetType(WINDROSE_TYPE16);
$wp2->SetDataKeyEncoding(KEYENCODING_CLOCKWISE);
$wp2->legend->Hide();
$wp2->SetPos($xpos2, $ypos1);
$wp2->SetSize(0.5);
Пример #5
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_windrose.php';
// 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 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 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));
Пример #6
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_windrose.php';
require_once 'jpgraph/jpgraph_flags.php';
// 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 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 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'));
Пример #7
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 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) {
Пример #8
0
<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_windrose.php';
// 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 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 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();