Esempio 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);
Esempio n. 2
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);
Esempio n. 3
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();
Esempio n. 4
0
<?php

// content="text/plain; charset=utf-8"
// Example for use of JpGraph,
// ljp, 01/03/01 20:32
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// We need some data
$datay = array(-0.13, 0.25, -0.21, 0.35, 0.31, 0.04);
$datax = array("Jan", "Feb", "Mar", "Apr", "May", "June");
// Setup the graph.
$graph = new Graph\Graph(400, 200);
$graph->img->SetMargin(60, 20, 30, 50);
$graph->SetScale("textlin");
$graph->SetMarginColor("silver");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set("Example negative bars");
$graph->title->SetFont(FF_VERDANA, FS_NORMAL, 18);
$graph->title->SetColor("darkred");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 12);
$graph->xaxis->SetColor("black", "red");
$graph->yaxis->SetFont(FF_VERDANA, FS_NORMAL, 11);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// Create the bar pot
Esempio n. 5
0
$data_freq = array(22, 20, 12, 10, 5, 4, 2);
$data_accfreq = accfreq($data_freq);
// Create the graph.
$graph = new Graph\Graph(350, 250);
// We need to make this extra call for CSIM scripts
// that make use of the cache. If the cache contains this
// graph the HTML wrapper will be returned and then the
// method will call exit() and hence NO LINES AFTER THIS
// CALL WILL BE EXECUTED.
// $graph->CheckCSIMCache('auto');
// Setup some basic graph parameters
$graph->SetScale("textlin");
$graph->SetY2Scale('lin', 0, 100);
$graph->img->SetMargin(50, 70, 30, 40);
$graph->yaxis->SetTitleMargin(30);
$graph->SetMarginColor('#EEEEEE');
// Setup titles and fonts
$graph->title->Set("Frequence plot");
$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);
// Turn the tickmarks
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->y2axis->SetTickSide(SIDE_RIGHT);
$graph->y2axis->SetColor('black', 'blue');
$graph->y2axis->SetLabelFormat('%3d.0%%');
// Create a bar pot
$bplot = new Plot\BarPlot($data_freq);
Esempio n. 6
0
<?php

// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
require_once 'jpgraph/jpgraph_line.php';
$datay = array(2, 3, 5, 8.5, 11.5, 6, 3);
// Create the graph.
$graph = new Graph\Graph(350, 300);
$graph->SetScale("textlin");
$graph->SetMarginColor('navy:1.9');
$graph->SetBox();
$graph->title->Set('Bar Pattern');
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 20);
$graph->SetTitleBackground('lightblue:1.3', TITLEBKG_STYLE2, TITLEBKG_FRAME_BEVEL);
$graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED, 'lightblue', 'blue');
// Create a bar pot
$bplot = new Plot\BarPlot($datay);
$bplot->SetFillColor('darkorange');
$bplot->SetWidth(0.6);
$bplot->SetPattern(PATTERN_CROSS1, 'navy');
$graph->Add($bplot);
$graph->Stroke();
Esempio n. 7
0
<?php

// content="text/plain; charset=utf-8"
// Example for use of JpGraph,
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// We need some data
$datay = array(0.13, 0.25, 0.21, 0.35, 0.31, 0.06);
$datax = array("January", "February", "March", "April", "May", "June");
// Setup the graph.
$graph = new Graph\Graph(400, 240);
$graph->img->SetMargin(60, 20, 35, 75);
$graph->SetScale("textlin");
$graph->SetMarginColor("lightblue:1.1");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set("Bar gradient with left reflection");
$graph->title->SetMargin(8);
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 12);
$graph->title->SetColor("darkred");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 10);
$graph->yaxis->SetFont(FF_VERDANA, FS_NORMAL, 10);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// Create the bar pot
$bplot = new Plot\BarPlot($datay);