1<?php // content="text/plain; charset=utf-8" 2require_once '../../vendor/autoload.php'; 3use Amenadiel\JpGraph\Graph; 4use Amenadiel\JpGraph\Plot; 5 6// Some data 7$datay = array(7, 19, 11, 4, 20); 8 9// Create the graph and setup the basic parameters 10$graph = new Graph\Graph(300, 200, 'auto'); 11$graph->img->SetMargin(40, 30, 40, 50); 12$graph->SetScale("textint"); 13$graph->SetFrame(true, 'blue', 1); 14$graph->SetColor('lightblue'); 15$graph->SetMarginColor('lightblue'); 16 17// Setup X-axis labels 18$a = $gDateLocale->GetShortMonth(); 19$graph->xaxis->SetTickLabels($a); 20$graph->xaxis->SetFont(FF_FONT1); 21$graph->xaxis->SetColor('darkblue', 'black'); 22 23// Setup "hidden" y-axis by given it the same color 24// as the background (this could also be done by setting the weight 25// to zero) 26$graph->yaxis->SetColor('lightblue', 'darkblue'); 27$graph->ygrid->SetColor('white'); 28 29// Setup graph title ands fonts 30$graph->title->Set('Using grace = 10%'); 31$graph->title->SetFont(FF_FONT2, FS_BOLD); 32$graph->xaxis->SetTitle('Year 2002', 'center'); 33$graph->xaxis->SetTitleMargin(10); 34$graph->xaxis->title->SetFont(FF_FONT2, FS_BOLD); 35 36// Add some grace to the top so that the scale doesn't 37// end exactly at the max value. 38$graph->yaxis->scale->SetGrace(10); 39 40// Create a bar pot 41$bplot = new Plot\BarPlot($datay); 42$bplot->SetFillColor('darkblue'); 43$bplot->SetColor('darkblue'); 44$bplot->SetWidth(0.5); 45$bplot->SetShadow('darkgray'); 46 47// Setup the values that are displayed on top of each bar 48// Must use TTF fonts if we want text at an arbitrary angle 49$bplot->value->Show(); 50$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8); 51$bplot->value->SetFormat('$%d'); 52$bplot->value->SetColor('darkred'); 53$bplot->value->SetAngle(45); 54$graph->Add($bplot); 55 56// Finally stroke the graph 57$graph->Stroke(); 58