Exemplo n.º 1
1
<?php

// content="text/plain; charset=utf-8"
// Example for use of JpGraph,
// ljp, 01/03/01 19:44
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// We need some data
$datay = array(0.3031, 0.3044, 0.3049, 0.304, 0.3024, 0.3047);
// Setup the graph.
$graph = new Graph\Graph(400, 200);
$graph->img->SetMargin(60, 30, 30, 40);
$graph->SetScale("textlin");
$graph->SetMarginColor("teal");
$graph->SetShadow();
// Create the bar pot
$bplot = new Plot\BarPlot($datay);
$bplot->SetWidth(0.6);
// This is how you make the bar graph start from something other than 0
$bplot->SetYMin(0.302);
// Setup color for gradient fill style
$tcol = array(100, 100, 255);
$fcol = array(255, 100, 100);
$bplot->SetFillGradient($fcol, $tcol, GRAD_HOR);
$bplot->SetFillColor("orange");
$graph->Add($bplot);
// Set up the title for the graph
$graph->title->Set("Bargraph which doesn't start from y=0");
$graph->title->SetColor("yellow");
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 12);
Exemplo n.º 2
0
 public function __construct($aWidth = 300, $aHeight = 200, $aCachedName = "", $aTimeOut = 0, $aInline = true)
 {
     parent::__construct($aWidth, $aHeight, $aCachedName, $aTimeOut, $aInline);
     $this->SetDensity(TICKD_DENSE);
     $this->SetBox();
     $this->SetMarginColor('white');
 }
Exemplo n.º 3
0
 public function __construct($width = 300, $height = 200, $cachedName = "", $timeout = 0, $inline = 1)
 {
     parent::__construct($width, $height, $cachedName, $timeout, $inline);
     $this->posx = $width / 2;
     $this->posy = $height / 2;
     $this->SetColor([255, 255, 255]);
     if ($this->graph_theme) {
         $this->graph_theme->ApplyGraph($this);
     }
 }
Exemplo n.º 4
0
 public function __construct($width = 300, $height = 200, $cachedName = "", $timeout = 0, $inline = 1)
 {
     parent::__construct($width, $height, $cachedName, $timeout, $inline);
     $this->posx = $width / 2;
     $this->posy = $height / 2;
     $this->len = min($width, $height) * 0.35;
     $this->SetColor(array(255, 255, 255));
     $this->SetTickDensity(TICKD_NORMAL);
     $this->SetScale('lin');
     $this->SetGridDepth(DEPTH_FRONT);
 }
Exemplo n.º 5
0
 public function __construct($aWidth = 0, $aHeight = 0, $aCachedName = "", $aTimeOut = 0, $aInline = true)
 {
     // Backward compatibility
     if ($aWidth == -1) {
         $aWidth = 0;
     }
     if ($aHeight == -1) {
         $aHeight = 0;
     }
     if ($aWidth < 0 || $aHeight < 0) {
         Util\JpGraphError::RaiseL(6002);
         //("You can't specify negative sizes for Gantt graph dimensions. Use 0 to indicate that you want the library to automatically determine a dimension.");
     }
     parent::__construct($aWidth, $aHeight, $aCachedName, $aTimeOut, $aInline);
     $this->scale = new GanttScale($this->img);
     // Default margins
     $this->img->SetMargin(15, 17, 25, 15);
     $this->hgrid = new HorizontalGridLine();
     $this->scale->ShowHeaders(GANTT_HWEEK | GANTT_HDAY);
     $this->SetBox();
 }
Exemplo n.º 6
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Some (random) data
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Size of the overall graph
$width = 350;
$height = 250;
// Create the graph and set a scale.
// These two calls are always required
$graph = new Graph\Graph($width, $height);
$graph->SetScale('intlin');
$graph->SetShadow();
// Setup margin and titles
$graph->SetMargin(40, 20, 20, 40);
$graph->title->Set('Calls per operator');
$graph->subtitle->Set('(March 12, 2008)');
$graph->xaxis->title->Set('Operator');
$graph->yaxis->title->Set('# of calls');
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->SetColor('blue');
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot->SetColor('blue');
$lineplot->SetWeight(2);
// Two pixel wide
// Add an image mark scaled to 50%
Exemplo n.º 7
0
use Amenadiel\JpGraph\Plot;
require_once 'jpgraph/jpgraph_utils.inc.php';
// Create some "fake" regression data
$datay = array();
$datax = array();
$a = 3.2;
$b = 2.5;
for ($x = 0; $x < 20; ++$x) {
    $datax[$x] = $x;
    $datay[$x] = $a + $b * $x + rand(-20, 20);
}
$lr = new LinearRegression($datax, $datay);
list($stderr, $corr) = $lr->GetStat();
list($xd, $yd) = $lr->GetY(0, 19);
// Create the graph
$graph = new Graph\Graph(300, 250);
$graph->SetScale('linlin');
// Setup title
$graph->title->Set("Linear regression");
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph->subtitle->Set('(stderr=' . sprintf('%.2f', $stderr) . ', corr=' . sprintf('%.2f', $corr) . ')');
$graph->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 12);
// make sure that the X-axis is always at the
// bottom at the plot and not just at Y=0 which is
// the default position
$graph->xaxis->SetPos('min');
// Create the scatter plot with some nice colors
$sp1 = new ScatterPlot($datay, $datax);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
$sp1->mark->SetFillColor("red");
$sp1->SetColor("blue");
Exemplo n.º 8
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
// Setup some data to use for the contour
$data = array(array(12, 12, 10, 10), array(10, 10, 8, 14), array(7, 7, 13, 17), array(4, 5, 8, 12), array(10, 8, 7, 8));
// create a basic graph as a container
$graph = new Graph\Graph(300, 300);
$graph->SetMargin(30, 30, 40, 30);
$graph->SetScale('intint');
$graph->SetMarginColor('white');
// Setup title of graph
$graph->title->Set('Filled contour plot');
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 12);
$graph->subtitle->Set('(With lines and labels)');
$graph->subtitle->SetFont(FF_VERDANA, FS_ITALIC, 10);
// Create a new contour plot
$cp = new FilledContourPlot($data, 7);
// Use only blue/red color schema
$cp->UseHighContrastColor(true);
// Flip visually
$cp->SetInvert();
// Fill the contours
$cp->SetFilled(true);
// Specify method to use
$cp->SetMethod('tri');
// Display the labels
$cp->ShowLabels(true, true);
$cp->SetFont(FF_ARIAL, FS_BOLD, 9);
$cp->SetFontColor('white');
Exemplo n.º 9
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
$y2data = array(354, 200, 265, 99, 111, 91, 198, 225, 293, 251);
// Create the graph and specify the scale for both Y-axis
$graph = new Graph\Graph(300, 240);
$graph->SetScale("textlin");
$graph->SetY2Scale("lin");
$graph->SetShadow();
// Adjust the margin
$graph->img->SetMargin(40, 40, 20, 70);
// Create the two linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot2 = new Plot\LinePlot($y2data);
// Add the plot to the graph
$graph->Add($lineplot);
$graph->AddY2($lineplot2);
$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);
// Adjust the axis color
$graph->y2axis->SetColor("orange");
$graph->yaxis->SetColor("blue");
$graph->title->Set("Example 6.1");
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
Exemplo n.º 10
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Some data
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(350, 250);
$graph->SetScale('textlin');
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot->SetColor('blue');
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
Exemplo n.º 11
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$data1y = array(12, 8, 19, 3, 10, 5);
$data2y = array(8, 2, 12, 7, 14, 4);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(310, 200, 'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 30, 20, 40);
$graph->SetShadow();
// Create the bar plots
$b1plot = new Plot\BarPlot($data1y);
$b1plot->SetFillColor("orange");
$targ = array("bar_clsmex2.php#1", "bar_clsmex2.php#2", "bar_clsmex2.php#3", "bar_clsmex2.php#4", "bar_clsmex2.php#5", "bar_clsmex2.php#6");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$b1plot->SetCSIMTargets($targ, $alts);
$b2plot = new Plot\BarPlot($data2y);
$b2plot->SetFillColor("blue");
$targ = array("bar_clsmex2.php#7", "bar_clsmex2.php#8", "bar_clsmex2.php#9", "bar_clsmex2.php#10", "bar_clsmex2.php#11", "bar_clsmex2.php#12");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$b2plot->SetCSIMTargets($targ, $alts);
// Create the grouped bar plot
$abplot = new Plot\AccBarPlot(array($b1plot, $b2plot));
$abplot->SetShadow();
$abplot->value->Show();
// ...and add it to the graPH
$graph->Add($abplot);
$graph->title->Set("Image map barex2");
Exemplo n.º 12
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$datay = array(62, 105, 85, 50);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(350, 220, 'auto');
$graph->SetScale("textlin");
//$theme_class="DefaultTheme";
//$graph->SetTheme(new $theme_class());
// set major and minor tick positions manually
$graph->yaxis->SetTickPositions(array(0, 30, 60, 90, 120, 150), array(15, 45, 75, 105, 135));
$graph->SetBox(false);
//$graph->ygrid->SetColor('gray');
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
// Create the bar plots
$b1plot = new Plot\BarPlot($datay);
// ...and add it to the graPH
$graph->Add($b1plot);
$b1plot->SetColor("white");
$b1plot->SetFillGradient("#4B0082", "white", GRAD_LEFT_REFLECTION);
$b1plot->SetWidth(45);
$graph->title->Set("Bar Gradient(Left reflection)");
// Display the graph
$graph->Stroke();
Exemplo n.º 13
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Some data
$datay = array(7, 19, 11, 4, 20);
// Create the graph and setup the basic parameters
$graph = new Graph\Graph(300, 200, 'auto');
$graph->img->SetMargin(40, 30, 40, 50);
$graph->SetScale("textint");
$graph->SetFrame(true, 'blue', 1);
$graph->SetColor('lightblue');
$graph->SetMarginColor('lightblue');
// Setup X-axis labels
$a = $gDateLocale->GetShortMonth();
$graph->xaxis->SetTickLabels($a);
$graph->xaxis->SetFont(FF_FONT1);
$graph->xaxis->SetColor('darkblue', 'black');
// Setup "hidden" y-axis by given it the same color
// as the background (this could also be done by setting the weight
// to zero)
$graph->yaxis->SetColor('lightblue', 'darkblue');
$graph->ygrid->SetColor('white');
// Setup graph title ands fonts
$graph->title->Set('Using grace = 10%');
$graph->title->SetFont(FF_FONT2, FS_BOLD);
$graph->xaxis->SetTitle('Year 2002', 'center');
$graph->xaxis->SetTitleMargin(10);
$graph->xaxis->title->SetFont(FF_FONT2, FS_BOLD);
Exemplo n.º 14
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
$y2data = array(354, 200, 265, 99, 111, 91, 198, 225, 293, 251);
// Create the graph and specify the scale for both Y-axis
$graph = new Graph\Graph(400, 200);
$graph->SetScale('textlin');
$graph->SetY2Scale('lin');
$graph->SetShadow();
// Adjust the margin
$graph->img->SetMargin(40, 140, 20, 40);
// Create the two linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot2 = new Plot\LinePlot($y2data);
// Add the plot to the graph
$graph->Add($lineplot);
$graph->AddY2($lineplot2);
$lineplot2->SetColor('orange');
$lineplot2->SetWeight(2);
// Adjust the axis color
$graph->y2axis->SetColor('orange');
$graph->yaxis->SetColor('blue');
$graph->title->Set('Example 6');
$graph->xaxis->title->Set('X-title');
$graph->yaxis->title->Set('Y-title');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
Exemplo n.º 15
0
<?php

// content="text/plain; charset=utf-8"
// Contour example 05
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$data = array(array(0.0, 0.001, 0.002, 0.005, -0.003, -0.053, -0.156, -0.245, -0.235, -0.143, -0.056, -0.014, -0.002, 0.0, 0.0), array(0.0, 0.002, 0.008999999999999999, 0.015, -0.04, -0.308, -0.826, -1.257, -1.188, -0.719, -0.28, -0.07000000000000001, -0.011, -0.001, 0.0), array(0.001, 0.005, 0.024, 0.047, -0.103, -0.878, -2.432, -3.767, -3.591, -2.166, -0.828, -0.195, -0.026, -0.001, 0.0), array(0.001, 0.007, 0.046, 0.145, 0.096, -0.913, -3.472, -6.042, -6.038, -3.625, -1.283, -0.235, -0.005, 0.007, 0.002), array(-0.003, -0.008999999999999999, 0.008999999999999999, 0.208, 0.734, 0.864, -0.9370000000000001, -3.985, -4.866, -2.781, -0.5600000000000001, 0.194, 0.151, 0.043, 0.007), array(-0.013, -0.07199999999999999, -0.229, -0.259, 0.652, 2.587, 3.058, 0.661, -1.097, 0.014, 1.336, 1.154, 0.474, 0.113, 0.017), array(-0.028, -0.171, -0.653, -1.397, -1.091, 1.421, 3.424, 1.942, 0.403, 1.784, 2.986, 2.12, 0.821, 0.191, 0.028), array(-0.037, -0.231, -0.9340000000000001, -2.255, -2.78, -0.699, 1.692, 0.981, 0.198, 2.199, 3.592, 2.515, 0.968, 0.225, 0.033), array(-0.031, -0.201, -0.829, -2.076, -2.82, -1.399, 0.61, 0.408, 0.122, 1.882, 3.004, 2.085, 0.8, 0.186, 0.027), array(-0.018, -0.115, -0.469, -1.133, -1.343, 0.011, 1.921, 2.256, 1.824, 2.115, 2.141, 1.312, 0.481, 0.11, 0.016), array(-0.007, -0.039, -0.13, -0.152, 0.5600000000000001, 2.77, 5.591, 6.719, 5.583, 3.646, 1.973, 0.832, 0.251, 0.052, 0.007), array(-0.001, -0.003, 0.024, 0.273, 1.297, 3.628, 6.515, 7.832, 6.517, 3.875, 1.69, 0.546, 0.13, 0.022, 0.003), array(0.0, 0.004, 0.036, 0.215, 0.837, 2.171, 3.809, 4.578, 3.81, 2.218, 0.913, 0.268, 0.056, 0.008, 0.001), array(0.0, 0.002, 0.014, 0.076, 0.284, 0.721, 1.257, 1.511, 1.257, 0.728, 0.294, 0.083, 0.017, 0.002, 0.0), array(0.0, 0.0, 0.003, 0.016, 0.057, 0.144, 0.25, 0.3, 0.25, 0.144, 0.058, 0.016, 0.003, 0.0, 0.0));
// Setup a basic graph context with some generous margins to be able
// to fit the legend
$graph = new Graph\Graph(480, 390);
$graph->SetMargin(40, 120, 60, 50);
$graph->title->Set("Contour plot, high contrast color");
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->SetMargin(10);
// For contour plots it is custom to use a box style ofr the axis
$graph->SetScale('intint', 0, 56, 0, 56);
// Setup axis and grids
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
$graph->xgrid->Show(true);
$graph->ygrid->Show(true);
// A simple contour plot with 10 isobar lines and flipped Y-coordinates
// Make the data smoother by interpolate the original matrice by a factor of two
// which will make each grid cell half the original size
$cp = new Plot\ContourPlot($data, 10, 3);
$cp->UseHighContrastColor(true);
// Display the legend
$cp->ShowLegend();
// Make the isobar lines slightly thicker
$graph->Add($cp);
// ... and send the graph back to the browser
Exemplo n.º 16
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Some data
$months = $gDateLocale->GetShortMonth();
srand((double) microtime() * 1000000);
for ($i = 0; $i < 25; ++$i) {
    $databary[] = rand(1, 50);
    $databarx[] = $months[$i % 12];
}
// new Graph\Graph with a drop shadow
$graph = new Graph\Graph(300, 200, 'auto');
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale("textlin");
// Specify X-labels
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetTextLabelInterval(1);
$graph->xaxis->SetTextTickInterval(3);
// Set title and subtitle
$graph->title->Set("Bar tutorial example 5");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Create the bar plot
$b1 = new Plot\BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetWidth(0.4);
// The order the plots are added determines who's ontop
Exemplo n.º 17
0
require_once 'jpgraph/jpgraph_line.php';
//bar1
$data1y = array(115, 130, 135, 130, 110, 130, 130, 150, 130, 130, 150, 120);
//bar2
$data2y = array(180, 200, 220, 190, 170, 195, 190, 210, 200, 205, 195, 150);
//bar3
$data3y = array(220, 230, 210, 175, 185, 195, 200, 230, 200, 195, 180, 130);
$data4y = array(40, 45, 70, 80, 50, 75, 70, 70, 80, 75, 80, 50);
$data5y = array(20, 20, 25, 22, 30, 25, 35, 30, 27, 25, 25, 45);
//line1
$data6y = array(50, 58, 60, 58, 53, 58, 57, 60, 58, 58, 57, 50);
foreach ($data6y as &$y) {
    $y -= 10;
}
// Create the graph. These two calls are always required
$graph = new Graph\Graph(750, 320, 'auto');
$graph->SetScale("textlin");
$graph->SetY2Scale("lin", 0, 90);
$graph->SetY2OrderBack(false);
$graph->SetMargin(35, 50, 20, 5);
$theme_class = new UniversalTheme();
$graph->SetTheme($theme_class);
$graph->yaxis->SetTickPositions(array(0, 50, 100, 150, 200, 250, 300, 350), array(25, 75, 125, 175, 275, 325));
$graph->y2axis->SetTickPositions(array(30, 40, 50, 60, 70, 80, 90));
$months = $gDateLocale->GetShortMonth();
$months = array_merge(array_slice($months, 3, 9), array_slice($months, 0, 3));
$graph->SetBox(false);
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
Exemplo n.º 18
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$data = array(0.1235, 0.4567, 0.67, 0.45, 0.832);
// Callback function
// Get called with the actual value and should return the
// value to be displayed as a string
function cbFmtPercentage($aVal)
{
    return sprintf("%.1f%%", 100 * $aVal);
    // Convert to string
}
// Create the graph.
$graph = new Graph\Graph(400, 300);
$graph->SetScale("textlin");
// Create a bar plots
$bar1 = new Plot\BarPlot($data);
// Setup the callback function
$bar1->value->SetFormatCallback("cbFmtPercentage");
$bar1->value->Show();
// Add the plot to the graph
$graph->Add($bar1);
// .. and send the graph back to the browser
$graph->Stroke();
Exemplo n.º 19
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$datay = array(2, 3, 5, 8, 12, 6, 3);
$datax = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul');
// Size of graph
$width = 400;
$height = 500;
// Set the basic parameters of the graph
$graph = new Graph\Graph($width, $height, 'auto');
$graph->SetScale('textlin');
// Rotate graph 90 degrees and set margin
$graph->Set90AndMargin(50, 20, 50, 30);
// Nice shadow
$graph->SetShadow();
// Setup title
$graph->title->Set('Horizontal bar graph ex 1');
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 14);
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 12);
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(10);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right', 'center');
// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area
$graph->yaxis->scale->SetGrace(20);
Exemplo n.º 20
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
require_once 'jpgraph/jpgraph_log.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$ydata = array(11, 3, 8, 42, 5, 1, 9, 13, 5, 7);
$datax = array("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "aug", "Sep", "Oct");
// Create the graph. These two calls are always required
$graph = new Graph\Graph(350, 200);
$graph->SetScale("textlog");
$graph->img->SetMargin(40, 110, 20, 40);
$graph->SetShadow();
$graph->ygrid->Show(true, true);
$graph->xgrid->Show(true, false);
// Specify the tick labels
$a = $gDateLocale->GetShortMonth();
$graph->xaxis->SetTickLabels($a);
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
// Add the plot to the graph
$graph->Add($lineplot);
$graph->title->Set("Examples 9");
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
Exemplo n.º 21
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$datay = array(2, 3, -5, 8, 12, 6, 3);
$datax = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul");
// Size of graph
$width = 400;
$height = 500;
// Set the basic parameters of the graph
$graph = new Graph\Graph($width, $height, 'auto');
$graph->SetScale("textlin");
$top = 50;
$bottom = 80;
$left = 50;
$right = 20;
$graph->Set90AndMargin($left, $right, $top, $bottom);
$graph->xaxis->SetPos('min');
// Nice shadow
$graph->SetShadow();
// Setup title
$graph->title->Set("Horizontal bar graph ex 3");
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 14);
$graph->subtitle->Set("(Axis at bottom)");
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_FONT2, FS_BOLD, 12);
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(5);
Exemplo n.º 22
0
<?php

// content="text/plain; charset=utf-8"
// Basic contour plot example
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$data = array(array(12, 7, 3, 15), array(18, 5, 1, 9), array(13, 9, 5, 12), array(5, 3, 8, 9), array(1, 8, 5, 7));
// Basic contour graph
$graph = new Graph\Graph(350, 250);
$graph->SetScale('intint');
// Show axis on all sides
$graph->SetAxisStyle(AXSTYLE_BOXOUT);
// Adjust the margins to fit the margin
$graph->SetMargin(30, 100, 40, 30);
// Setup
$graph->title->Set('Basic contour plot with multiple axis');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
// A simple contour plot with default arguments (e.g. 10 isobar lines)
$cp = new Plot\ContourPlot($data, 10, 2);
// Display the legend
$cp->ShowLegend();
$graph->Add($cp);
// ... and send the graph back to the browser
$graph->Stroke();
Exemplo n.º 23
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$ydata = array(12, 19, 3, 9, 15, 10);
// The code to setup a very basic graph
$graph = new Graph\Graph(200, 150);
$graph->SetScale('intlin');
$graph->SetMargin(30, 15, 40, 30);
$graph->SetMarginColor('white');
$graph->SetFrame(true, 'blue', 3);
$graph->title->Set('Label background');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->subtitle->SetColor('darkred');
$graph->subtitle->Set('"LABELBKG_YAXIS"');
$graph->SetAxisLabelBackground(LABELBKG_YAXIS, 'orange', 'red', 'lightblue', 'red');
// Use Ariel font
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new Plot\LinePlot($ydata);
$graph->Add($p1);
// Output graph
$graph->Stroke();
Exemplo n.º 24
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Some data
for ($i = 0; $i < 12; ++$i) {
    $databary[$i] = rand(1, 20);
}
$months = $gDateLocale->GetShortMonth();
// new Graph\Graph with a drop shadow
$graph = new Graph\Graph(300, 200);
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale('textlin');
// Specify X-labels
$graph->xaxis->SetTickLabels($months);
$graph->xaxis->SetTextTickInterval(2, 0);
// Set title and subtitle
$graph->title->Set('Textscale with tickinterval=2');
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Create the bar plot
$b1 = new Plot\BarPlot($databary);
$b1->SetLegend('Temperature');
// The order the plots are added determines who's ontop
$graph->Add($b1);
// Finally output the  image
$graph->Stroke();
Exemplo n.º 25
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$datay = array(10, 29, 3, 6);
// Create the graph.
$graph = new Graph\Graph(200, 200);
$graph->SetScale('textlin');
$graph->SetMargin(25, 10, 20, 25);
$graph->SetBox(true);
// Add 10% grace ("space") at top and botton of Y-scale.
$graph->yscale->SetGrace(10);
// Create a bar pot
$bplot = new Plot\BarPlot($datay);
$bplot->SetFillColor("lightblue");
$graph->ygrid->Show(false);
// .. and add the plot to the graph
$graph->Add($bplot);
// Add band
$band = new Plot\PlotBand(HORIZONTAL, BAND_3DPLANE, 15, 35, 'khaki4');
$band->SetDensity(40);
$band->ShowFrame(true);
$graph->AddBand($band);
// Set title
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->title->SetColor('darkred');
$graph->title->Set('BAND_3DPLANE, Density=40');
$graph->Stroke();
Exemplo n.º 26
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$datay1 = array(13, 8, 19, 7, 17, 6);
$datay2 = array(4, 5, 2, 7, 5, 25);
// Create the graph.
$graph = new Graph\Graph(350, 250);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
// Setup title
$graph->title->Set('Acc bar with gradient');
// Create the first bar
$bplot = new Plot\BarPlot($datay1);
$bplot->SetFillGradient('AntiqueWhite2', 'AntiqueWhite4:0.8', GRAD_VERT);
$bplot->SetColor('darkred');
// Create the second bar
$bplot2 = new Plot\BarPlot($datay2);
$bplot2->SetFillGradient('olivedrab1', 'olivedrab4', GRAD_VERT);
$bplot2->SetColor('darkgreen');
// And join them in an accumulated bar
$accbplot = new Plot\AccBarPlot(array($bplot, $bplot2));
$graph->Add($accbplot);
$graph->Stroke();
Exemplo n.º 27
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$data1y = array(47, 80, 40, 116);
$data2y = array(61, 30, 82, 105);
$data3y = array(115, 50, 70, 93);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(350, 200, 'auto');
$graph->SetScale("textlin");
$theme_class = new UniversalTheme();
$graph->SetTheme($theme_class);
$graph->yaxis->SetTickPositions(array(0, 30, 60, 90, 120, 150), array(15, 45, 75, 105, 135));
$graph->SetBox(false);
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false, false);
// Create the bar plots
$b1plot = new Plot\BarPlot($data1y);
$b2plot = new Plot\BarPlot($data2y);
$b3plot = new Plot\BarPlot($data3y);
// Create the grouped bar plot
$gbplot = new Plot\GroupBarPlot(array($b1plot, $b2plot, $b3plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$b1plot->SetColor("white");
$b1plot->SetFillColor("#cc1111");
$b2plot->SetColor("white");
Exemplo n.º 28
0
<?php

// content="text/plain; charset=utf-8"
// $Id: bar_csimex3.php,v 1.3 2002/08/31 20:03:46 aditus Exp $
// Horiontal bar graph with image maps
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$data1y = array(5, 8, 19, 3, 10, 5);
$data2y = array(12, 2, 12, 7, 14, 4);
// Setup the basic parameters for the graph
$graph = new Graph\Graph(400, 700);
$graph->SetAngle(90);
$graph->SetScale("textlin");
// The negative margins are necessary since we
// have rotated the image 90 degress and shifted the
// meaning of width, and height. This means that the
// left and right margins now becomes top and bottom
// calculated with the image width and not the height.
$graph->img->SetMargin(-80, -80, 210, 210);
$graph->SetMarginColor('white');
// Setup title for graph
$graph->title->Set('Horizontal bar graph');
$graph->title->SetFont(FF_FONT2, FS_BOLD);
$graph->subtitle->Set("With image map\nNote: The URL just points back to this image");
// Setup X-axis.
$graph->xaxis->SetTitle("X-title", 'center');
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetAngle(90);
$graph->xaxis->SetTitleMargin(30);
$graph->xaxis->SetLabelMargin(15);
Exemplo n.º 29
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// We need some data
$datay = array(4, 8, 6);
// Setup the graph.
$graph = new Graph\Graph(200, 150);
$graph->SetScale("textlin");
$graph->img->SetMargin(25, 15, 25, 25);
$graph->title->Set('"GRAD_CENTER"');
$graph->title->SetColor('darkred');
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1);
$graph->yaxis->SetFont(FF_FONT1);
// Create the bar pot
$bplot = new Plot\BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillGradient("navy", "lightsteelblue", GRAD_CENTER);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
Exemplo n.º 30
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Some data
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph\Graph(350, 250);
$graph->SetScale("textlin");
$graph->SetMargin(40, 40, 50, 50);
// Setup the grid and plotarea box
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->setColor('darkgray');
$graph->SetBox(true);
// Steup graph titles
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->title->Set('Using background image');
$graph->subtitle->SetFont(FF_COURIER, FS_BOLD, 11);
$graph->subtitle->Set('"BGIMG_COPY"');
$graph->subtitle->SetColor('darkred');
// Add background with 25% mix
$graph->SetBackgroundImage('heat1.jpg', BGIMG_COPY);
$graph->SetBackgroundImageMix(25);
// Create the linear plot
$lineplot = new Plot\LinePlot($ydata);
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph