<?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'); $bplot->SetWeight(0); // Create the second bar $bplot2 = new Plot\BarPlot($datay2); $bplot2->SetFillGradient('olivedrab1', 'olivedrab4', GRAD_VERT); $bplot2->SetColor('darkgreen'); $bplot2->SetWeight(0); // And join them in an accumulated bar $accbplot = new Plot\AccBarPlot(array($bplot, $bplot2)); $accbplot->SetColor('darkgray'); $accbplot->SetWeight(1); $graph->Add($accbplot); $graph->Stroke();
$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 $graph->Stroke();