$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();
<?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();
require_once '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; // Some data $months = $gDateLocale->GetShortMonth(); srand((double) microtime() * 1000000); for ($i = 0; $i < 25; ++$i) { $databary[] = rand(1, 50); $databarx[] = $months[$i % 12]; } // new Graph\Graph with a drop shadow $graph = new Graph\Graph(300, 200, 'auto'); $graph->SetShadow(); // Use a "text" X-scale $graph->SetScale("textlin"); // Specify X-labels $graph->xaxis->SetTickLabels($databarx); $graph->xaxis->SetTextLabelInterval(1); $graph->xaxis->SetTextTickInterval(3); // Set title and subtitle $graph->title->Set("Bar tutorial example 5"); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Create the bar plot $b1 = new Plot\BarPlot($databary); $b1->SetLegend("Temperature"); $b1->SetWidth(0.4); // The order the plots are added determines who's ontop $graph->Add($b1); // Finally output the image $graph->Stroke();