$graph->img->SetMargin(60, 30, 50, 40); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->title->Set("Cash flow "); $graph->subtitle->Set("(Department X)"); // Show both X and Y grid $graph->xgrid->Show(true, false); // Add 10% grace ("space") at top and botton of Y-scale. $graph->yscale->SetGrace(10, 10); // Turn the tick mark out from the plot area $graph->xaxis->SetTickSide(SIDE_DOWN); $graph->yaxis->SetTickSide(SIDE_LEFT); // Create a bar pot $bplot = new Plot\BarPlot($datay); $bplot->SetFillColor("orange"); // Show the actual value for each bar on top/bottom $bplot->value->Show(true); $bplot->value->SetFormat("%02d kr"); // Position the X-axis at the bottom of the plotare $graph->xaxis->SetPos("min"); // .. and add the plot to the graph $graph->Add($bplot); // Add upper and lower band and use no frames $uband = new Plot\PlotBand(HORIZONTAL, BAND_RDIAG, 0, "max", "green"); $uband->ShowFrame(false); $uband->SetDensity(50); // 50% line density $lband = new Plot\PlotBand(HORIZONTAL, BAND_LDIAG, "min", 0, "red"); $lband->ShowFrame(false); $lband->SetDensity(20);
// content="text/plain; charset=utf-8" require_once '../../vendor/autoload.php'; require_once 'jpgraph/jpgraph_bar.php'; $datay = array(12, 8, 19, 3, 10, 5); // Create the graph. These two calls are always required $graph = new Graph\Graph(300, 200); $graph->SetScale("textlin"); $graph->yaxis->scale->SetGrace(20); // Add a drop shadow $graph->SetShadow(); // Adjust the margin a bit to make more room for titles $graph->img->SetMargin(40, 30, 20, 40); // Create a bar pot $bplot = new Plot\BarPlot($datay); // Adjust fill color $bplot->SetFillColor('orange'); $bplot->value->Show(); $bplot->value->SetFont(FF_ARIAL, FS_BOLD, 10); $bplot->value->SetAngle(45); $bplot->value->SetFormat('%0.1f'); $graph->Add($bplot); // Setup the titles $graph->title->Set("Bar graph with Y-scale grace"); $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); // Display the graph $graph->Stroke();
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_bar.php'; require_once 'jpgraph/jpgraph_line.php'; $ydata = array(12, 15, 22, 19, 5); $graph = new Graph\Graph(400, 200); $graph->img->SetMargin(40, 80, 40, 40); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->title->Set('Center the line points in bars'); $line = new Plot\LinePlot($ydata); $line->SetBarCenter(); $line->SetWeight(2); $bar = new Plot\BarPlot($ydata); $bar2 = new Plot\BarPlot($ydata); $bar2->SetFillColor("red"); $gbar = new Plot\GroupBarPlot(array($bar, $bar2)); $graph->Add($gbar); $graph->Add($line); // Output line $graph->Stroke();
$graph->img->SetMargin($tablexpos, $rightmargin, 30, $height - $tableypos); $graph->SetScale("textlin"); $graph->SetMarginColor('white'); // Setup titles and fonts $graph->title->Set('Bar and table'); $graph->title->SetFont(FF_VERDANA, FS_NORMAL, 14); $graph->yaxis->title->Set("Flow"); $graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 12); $graph->yaxis->title->SetMargin(10); // Create the bars and the accbar plot $bplot = new Plot\BarPlot($datay[3]); $bplot->SetFillColor("orange"); $bplot2 = new Plot\BarPlot($datay[2]); $bplot2->SetFillColor("red"); $bplot3 = new Plot\BarPlot($datay[1]); $bplot3->SetFillColor("darkgreen"); $accbplot = new Plot\AccBarPlot(array($bplot, $bplot2, $bplot3)); $accbplot->value->Show(); $graph->Add($accbplot); //Setup the table $table = new GTextTable(); $table->Set($datay); $table->SetPos($tablexpos, $tableypos + 1); $table->SetCellCSIMTarget(1, 1, 'tableex02.php', 'View details'); // Basic table formatting $table->SetFont(FF_ARIAL, FS_NORMAL, 10); $table->SetAlign('right'); $table->SetMinColWidth($cellwidth); $table->SetNumberFormat('%0.1f'); // Format table header row $table->SetRowFillColor(0, 'teal@0.7');
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetColor('navy'); $graph->yaxis->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->SetColor('navy'); //$graph->ygrid->Show(false); $graph->ygrid->SetColor('white@0.5'); // Setup graph title $graph->title->Set('Using a country flag background'); // Some extra margin (from the top) $graph->title->SetMargin(3); $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12); // Create the three var series we will combine $bplot1 = new Plot\BarPlot($datay1); $bplot2 = new Plot\BarPlot($datay2); $bplot3 = new Plot\BarPlot($datay3); // Setup the colors with 40% transparency (alpha channel) $bplot1->SetFillColor('yellow@0.4'); $bplot2->SetFillColor('red@0.4'); $bplot3->SetFillColor('darkgreen@0.4'); // Setup legends $bplot1->SetLegend('Label 1'); $bplot2->SetLegend('Label 2'); $bplot3->SetLegend('Label 3'); // Setup each bar with a shadow of 50% transparency $bplot1->SetShadow('black@0.4'); $bplot2->SetShadow('black@0.4'); $bplot3->SetShadow('black@0.4'); $gbarplot = new Plot\GroupBarPlot(array($bplot1, $bplot2, $bplot3)); $gbarplot->SetWidth(0.6); $graph->Add($gbarplot); $graph->Stroke();
<?php // content="text/plain; charset=utf-8" // Illustration of the different patterns for bands // $Id: smallstaticbandsex7.php,v 1.1 2002/09/01 21:51:08 aditus Exp $ require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_bar.php'; $datay = array(10, 29, 3, 6); // Create the graph. $graph = new Graph\Graph(200, 150); $graph->SetScale("textlin"); $graph->SetMargin(25, 10, 20, 20); // Add 10% grace ("space") at top and botton of Y-scale. $graph->yscale->SetGrace(10); // Create a bar pot $bplot = new Plot\BarPlot($datay); $bplot->SetFillColor("lightblue"); // Position the X-axis at the bottom of the plotare $graph->xaxis->SetPos("min"); $graph->ygrid->Show(false); // .. and add the plot to the graph $graph->Add($bplot); // Add band $band = new Plot\PlotBand(HORIZONTAL, BAND_HLINE, 15, 35, 'khaki4'); $band->ShowFrame(false); $graph->Add($band); // Set title $graph->title->SetFont(FF_ARIAL, FS_BOLD, 10); $graph->title->SetColor('darkred'); $graph->title->Set('BAND_HLINE'); $graph->Stroke();
$graph->xgrid->Show(); $p1 = new Plot\LinePlot($datay, $datax); $graph->Add($p1); //---------------------- // Setup the bar graph //---------------------- $graph2 = new Graph\Graph($w, 110); $graph2->SetScale('linlin', 0, 0, $xmin, $xmax); $graph2->SetMargin($lm, $rm, 5, 10); $graph2->SetMarginColor('white'); $graph2->SetFrame(false); $graph2->SetBox(true); $graph2->xgrid->Show(); $graph2->xaxis->SetTickPositions($tickPositions, $minTickPositions); $graph2->xaxis->SetLabelFormatString('My', true); $graph2->xaxis->SetPos('max'); $graph2->xaxis->HideLabels(); $graph2->xaxis->SetTickSide(SIDE_DOWN); $b1 = new Plot\BarPlot($datay2, $datax); $b1->SetFillColor('teal'); $b1->SetColor('teal:1.2'); $graph2->Add($b1); //----------------------- // Create a multigraph //---------------------- $mgraph = new MGraph(); $mgraph->SetMargin(2, 2, 2, 2); $mgraph->SetFrame(true, 'darkgray', 2); $mgraph->Add($graph); $mgraph->Add($graph2, 0, 240); $mgraph->Stroke();
<?php // content="text/plain; charset=utf-8" require_once '../../vendor/autoload.php'; require_once 'jpgraph/jpgraph_bar.php'; $data1y = array(12, 8, 19, 3, 10, 5); $data2y = array(8, 2, 11, 7, 14, 4); // Create the graph. These two calls are always required $graph = new Graph\Graph(310, 200); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->img->SetMargin(40, 30, 20, 40); // Create the bar plots $b1plot = new Plot\BarPlot($data1y); $b1plot->SetFillColor("orange"); $b2plot = new Plot\BarPlot($data2y); $b2plot->SetFillColor("blue"); // Create the grouped bar plot $gbplot = new Plot\GroupBarPlot(array($b1plot, $b2plot)); // ...and add it to the graPH $graph->Add($gbplot); $graph->title->Set("Example 21"); $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); // Display the graph $graph->Stroke();
$data2y = array(8, 2, 11, 7, 14, 4); $data3y = array(3, 9, 2, 7, 5, 8); $data4y = array(1, 5, 11, 2, 14, 4); // Create the graph. These two calls are always required $graph = new Graph\Graph(310, 200); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->img->SetMargin(40, 30, 20, 40); $b1plot = new Plot\BarPlot($data1y); $b1plot->SetFillColor("orange"); $b2plot = new Plot\BarPlot($data2y); $b2plot->SetFillColor("blue"); $b3plot = new Plot\BarPlot($data3y); $b3plot->SetFillColor("green"); $b4plot = new Plot\BarPlot($data4y); $b4plot->SetFillColor("brown"); // Create the accumulated bar plots $ab1plot = new Plot\AccBarPlot(array($b1plot, $b2plot)); $ab2plot = new Plot\AccBarPlot(array($b3plot, $b4plot)); // Create the grouped bar plot $gbplot = new Plot\GroupBarPlot(array($ab1plot, $ab2plot)); // ...and add it to the graph $graph->Add($gbplot); $graph->title->Set("Grouped Accumulated bar plots"); $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); // Display the graph $graph->Stroke();