$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();
$graph->yaxis->SetTickSide(SIDE_LEFT); $graph->y2axis->SetTickSide(SIDE_RIGHT); $graph->y2axis->SetColor('black', 'blue'); $graph->y2axis->SetLabelFormat('%3d.0%%'); // Create a bar pot $bplot = new Plot\BarPlot($data_freq); // Create targets and alt texts for the image maps. One for each bar // (In this example this is just "dummy" targets) $targ = array("#1", "#2", "#3", "#4", "#5", "#6", "#7"); $alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d"); $bplot->SetCSIMTargets($targ, $alts); // Create accumulative graph $lplot = new Plot\LinePlot($data_accfreq); // We want the line plot data point in the middle of the bars $lplot->SetBarCenter(); // Use transperancy $lplot->SetFillColor('lightblue@0.6'); $lplot->SetColor('blue@0.6'); //$lplot->SetColor('blue'); $graph->AddY2($lplot); // Setup the bars $bplot->SetFillColor("orange@0.2"); $bplot->SetValuePos('center'); $bplot->value->SetFormat("%d"); $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 9); $bplot->value->Show(); // Add it to the graph $graph->Add($bplot); // Send back the HTML page which will call this script again // to retrieve the image. $graph->StrokeCSIM();
use Amenadiel\JpGraph\Plot; $l1datay = array(11, 9, 2, 4, 3, 13, 17); $l2datay = array(23, 12, 5, 19, 17, 10, 15); $datax = array('Jan', 'Feb', 'Mar', 'Apr', 'May'); // Create the graph. $graph = new Graph\Graph(400, 200); $graph->SetScale('textlin'); $graph->img->SetMargin(40, 130, 20, 40); $graph->SetShadow(); // Create the linear error plot $l1plot = new Plot\LinePlot($l1datay); $l1plot->SetColor('red'); $l1plot->SetWeight(2); $l1plot->SetLegend('Prediction'); // Create the bar plot $l2plot = new Plot\LinePlot($l2datay); $l2plot->SetFillColor('orange'); $l2plot->SetLegend('Result'); // Add the plots to the graph $graph->Add($l2plot); $graph->Add($l1plot); $graph->title->Set('Mixing line and filled line'); $graph->xaxis->title->Set('X-title'); $graph->yaxis->title->Set('Y-title'); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); //$graph->xaxis->SetTickLabels($datax); //$graph->xaxis->SetTextTickInterval(2); // Display the graph $graph->Stroke();