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); // 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);
use Amenadiel\JpGraph\Plot; $datay = array(1992, 1993, 1995, 1996, 1997, 1998, 2001); // Size of graph $width = 400; $height = 500; // Set the basic parameters of the graph $graph = new Graph\Graph($width, $height); $graph->SetScale('textlin'); $top = 60; $bottom = 30; $left = 80; $right = 30; $graph->Set90AndMargin($left, $right, $top, $bottom); // Nice shadow $graph->SetShadow(); // Setup labels $lbl = array("Andrew\nTait", "Thomas\nAnderssen", "Kevin\nSpacey", "Nick\nDavidsson", "David\nLindquist", "Jason\nTait", "Lorin\nPersson"); $graph->xaxis->SetTickLabels($lbl); // Label align for X-axis $graph->xaxis->SetLabelAlign('right', 'center', 'right'); // Label align for Y-axis $graph->yaxis->SetLabelAlign('center', 'bottom'); // Titles $graph->title->Set('Number of incidents'); // Create a bar pot $bplot = new Plot\BarPlot($datay); $bplot->SetFillColor('orange'); $bplot->SetWidth(0.5); $bplot->SetYMin(1990); $graph->Add($bplot); $graph->Stroke();