Пример #1
0
$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);
// Add some grace to the top so that the scale doesn't
// end exactly at the max value.
$graph->yaxis->scale->SetGrace(10);
// Create a bar pot
$bplot = new Plot\BarPlot($datay);
$bplot->SetFillColor('darkblue');
$bplot->SetColor('darkblue');
$bplot->SetWidth(0.5);
$bplot->SetShadow('darkgray');
// Setup the values that are displayed on top of each bar
// Must use TTF fonts if we want text at an arbitrary angle
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8);
$bplot->value->SetFormat('$%d');
$bplot->value->SetColor('darkred');
$bplot->value->SetAngle(45);
$graph->Add($bplot);
// Finally stroke the graph
$graph->Stroke();
Пример #2
0
$graph->yaxis->SetTickSide(SIDE_LEFT);
// Finally setup the title
$graph->yaxis->SetTitleSide(SIDE_RIGHT);
$graph->yaxis->SetTitleMargin(35);
// To align the title to the right use :
$graph->yaxis->SetTitle('Turnaround 2002', 'high');
$graph->yaxis->title->Align('right');
// To center the title use :
//$graph->yaxis->SetTitle('Turnaround 2002','center');
//$graph->yaxis->title->Align('center');
$graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->yaxis->title->SetAngle(0);
$graph->yaxis->SetFont(FF_FONT2, FS_NORMAL);
// If you want the labels at an angle other than 0 or 90
// you need to use TTF fonts
//$graph->yaxis->SetLabelAngle(0);
// Now create a bar pot
$bplot = new Plot\BarPlot($datay);
$bplot->SetFillColor("orange");
$bplot->SetShadow();
//You can change the width of the bars if you like
//$bplot->SetWidth(0.5);
// We want to display the value of each bar at the top
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL, FS_BOLD, 12);
$bplot->value->SetAlign('left', 'center');
$bplot->value->SetColor("black", "darkred");
$bplot->value->SetFormat('%.1f mkr');
// Add the bar to the graph
$graph->Add($bplot);
$graph->Stroke();
Пример #3
0
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetColor('white');
$graph->yaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->SetColor('white');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using alpha blending with a background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
// Create the three var series we will combine
$bplot1 = new Plot\BarPlot($datay1);
$bplot2 = new Plot\BarPlot($datay2);
$bplot3 = new Plot\BarPlot($datay3);
// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('orange@0.4');
$bplot2->SetFillColor('brown@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
// Setup legends
$bplot1->SetLegend('Label 1');
$bplot2->SetLegend('Label 2');
$bplot3->SetLegend('Label 3');
// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$gbarplot = new Plot\GroupBarPlot(array($bplot1, $bplot2, $bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
Пример #4
0
$graph->subtitle->Set("100 data points, X-Scale: 'text'");
// Use built in font (don't need TTF support)
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Make the margin around the plot a little bit bigger then default
$graph->img->SetMargin(40, 140, 40, 80);
// Slightly adjust the legend from it's default position in the
// top right corner to middle right side
$graph->legend->Pos(0.03, 0.5, "right", "center");
// Display every 6:th tickmark
$graph->xaxis->SetTextTickInterval(6);
// Label every 2:nd tick mark
$graph->xaxis->SetTextLabelInterval(2);
// Setup the labels
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetLabelAngle(90);
// Create a red line plot
$p1 = new Plot\LinePlot($datay);
$p1->SetColor("red");
$p1->SetLegend("Pressure");
// Create the bar plot
$b1 = new Plot\BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetFillColor("orange");
$b1->SetAbsWidth(8);
// Drop shadow on bars adjust the default values a little bit
$b1->SetShadow("steelblue", 2, 2);
// The order the plots are added determines who's ontop
$graph->Add($p1);
$graph->AddY2($b1);
// Finally output the  image
$graph->Stroke();
Пример #5
0
require_once '../../vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
$datay1 = array(35, 160, 0, 0, 0, 0);
$datay2 = array(35, 190, 190, 190, 190, 190);
$datay3 = array(20, 70, 70, 140, 230, 260);
$graph = new Graph\Graph(450, 200, 'auto');
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40, 30, 40, 40);
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
$graph->xaxis->title->Set('Year 2002');
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->Set('Group bar plot');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$bplot1 = new Plot\BarPlot($datay1);
$bplot2 = new Plot\BarPlot($datay2);
$bplot3 = new Plot\BarPlot($datay3);
$bplot1->SetFillColor("orange");
$bplot2->SetFillColor("brown");
$bplot3->SetFillColor("darkgreen");
$bplot1->SetShadow();
$bplot2->SetShadow();
$bplot3->SetShadow();
$bplot1->SetShadow();
$bplot2->SetShadow();
$bplot3->SetShadow();
$gbarplot = new Plot\GroupBarPlot(array($bplot1, $bplot2, $bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();