<?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();
$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); // Setup color for axis and labels $graph->xaxis->SetColor("black", "white"); $graph->yaxis->SetColor("black", "white"); // Setup font for axis $graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 10); $graph->yaxis->SetFont(FF_VERDANA, FS_NORMAL, 10); // Setup X-axis title (color & font) $graph->xaxis->title->Set("X-axis"); $graph->xaxis->title->SetColor("white");
<?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();
<?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_WIDE_MIDVER"'); $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_WIDE_MIDVER); // Set color for the frame of each bar $bplot->SetColor("navy"); $graph->Add($bplot); // Finally send the graph to the browser $graph->Stroke();
$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 $bplot = new Plot\BarPlot($datay); $bplot->SetWidth(0.6); // Setup color for gradient fill style $bplot->SetFillGradient("navy", "steelblue", GRAD_MIDVER); // Set color for the frame of each bar $bplot->SetColor("navy"); $graph->Add($bplot); // Finally send the graph to the browser $graph->Stroke();
// 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); // We don't want to display Y-axis $graph->yaxis->Hide(); // Now create a bar pot $bplot = new Plot\BarPlot($datay); $bplot->SetShadow(); //You can change the width of the bars if you like //$bplot->SetWidth(0.5); // Set gradient fill for bars $bplot->SetFillGradient('darkred', 'yellow', GRAD_HOR); // We want to display the value of each bar at the top $bplot->value->Show(); $bplot->value->SetFont(FF_ARIAL, FS_BOLD, 10); //$bplot->value->SetAlign('left','center'); $bplot->value->SetColor("white"); $bplot->value->SetFormat('%.1f'); $bplot->SetValuePos('max'); // Add the bar to the graph $graph->Add($bplot); // Add some explanation text $txt = new Text('Note: Higher value is better.'); $txt->SetPos(190, 399, 'center', 'bottom'); $txt->SetFont(FF_ARIAL, FS_NORMAL, 8); $graph->Add($txt); // .. and stroke the graph
<?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_RAISED_PANEL"'); $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', 'orange', GRAD_RAISED_PANEL); // Set color for the frame of each bar $bplot->SetColor("navy"); $graph->Add($bplot); // Finally send the graph to the browser $graph->Stroke();
<?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_MIDHOR"'); $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_MIDHOR); // Set color for the frame of each bar $bplot->SetColor("navy"); $graph->Add($bplot); // Finally send the graph to the browser $graph->Stroke();
$graph->ygrid->SetFill(true, '#DDDDDD@0.5', '#BBBBBB@0.5'); $graph->ygrid->SetLineStyle('dashed'); $graph->ygrid->SetColor('gray'); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle('dashed'); $graph->xgrid->SetColor('gray'); // Setup month as labels on the X-axis $graph->xaxis->SetTickLabels($months); $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $graph->xaxis->SetLabelAngle(45); // Create a bar pot $bplot = new Plot\BarPlot($ydata); $bplot->SetWidth(0.6); $fcol = '#440000'; $tcol = '#FF9090'; $bplot->SetFillGradient($fcol, $tcol, GRAD_LEFT_REFLECTION); // Set line weigth to 0 so that there are no border // around each bar $bplot->SetWeight(0); $graph->Add($bplot); // Create filled line plot $lplot = new Plot\LinePlot($ydata2); $lplot->SetFillColor('skyblue@0.5'); $lplot->SetColor('navy@0.7'); $lplot->SetBarCenter(); $lplot->mark->SetType(MARK_SQUARE); $lplot->mark->SetColor('blue@0.5'); $lplot->mark->SetFillColor('lightblue'); $lplot->mark->SetSize(6); $graph->Add($lplot); // .. and finally send it back to the browser
$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); $bplot->SetWidth(0.6); // Setup color for gradient fill style $bplot->SetFillGradient("navy:0.9", "navy:1.85", GRAD_LEFT_REFLECTION); // Set color for the frame of each bar $bplot->SetColor("white"); $graph->Add($bplot); // Finally send the graph to the browser $graph->Stroke();