$graph->xaxis->title->SetColor('white'); $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);
<?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();
<?php // content="text/plain; charset=utf-8" require_once '../jpgraph.php'; require_once '../jpgraph_bar.php'; $datay = array(12, 26, 9, 17, 31); // Create the graph. $graph = new Graph\Graph(400, 250); $graph->SetScale('textlin'); $graph->SetMargin(50, 80, 20, 40); // Create a bar pot $bplot = new Plot\BarPlot($datay); $n = count($datay); // Number of bars global $_wrapperfilename; // Create targets for the image maps. One for each column $targ = array(); $alt = array(); $wtarg = array(); for ($i = 0; $i < $n; ++$i) { $urlarg = 'clickedon=' . ($i + 1); $targ[] = $_wrapperfilename . '?' . $urlarg; $alt[] = 'val=%d'; $wtarg[] = ''; } $bplot->SetCSIMTargets($targ, $alt, $wtarg); $graph->Add($bplot); $graph->title->Set('Multiple Image maps'); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->title->SetCSIMTarget('#45', 'Title for Bar', '_blank'); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
if ($i % 10 == 0) { $databarx[] = $i; $databary[] = $datay[$i] / 2; } } // new Graph\Graph with a background image and drop shadow $graph = new Graph\Graph(450, 300); $graph->img->SetMargin(40, 180, 40, 40); $graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME); //$graph->img->SetAntiAliasing(); $graph->SetScale("intlin"); $graph->SetShadow(); $graph->title->Set("Combined bar and line plot"); $graph->subtitle->Set("(\"center\" aligned bars)"); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Slightly adjust the legend from it's default position in the // top right corner. $graph->legend->Pos(0.05, 0.5, "right", "center"); // Create the first line $p1 = new Plot\LinePlot($datay, $datax); $p1->SetWeight(1); $p1->SetColor("red"); $p1->SetLegend("Triumph Tiger -98"); $graph->Add($p1); $b1 = new Plot\BarPlot($databary, $databarx); $b1->SetAbsWidth(10); $b1->SetAlign("center"); $b1->SetShadow(); $graph->Add($b1); $graph->Stroke();
$graph->SetScale("textlin"); // Set title and subtitle $graph->title->Set("Combined bar and line plot"); $graph->subtitle->Set("100 data points, X-Scale: 'text'"); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Make the margin around the plot a little bit bigger // then default $graph->img->SetMargin(40, 140, 40, 80); // Slightly adjust the legend from it's default position in the // top right corner to middle right side $graph->legend->Pos(0.05, 0.5, "right", "center"); // Display every 10:th datalabel $graph->xaxis->SetTextTickInterval(6); $graph->xaxis->SetTextLabelInterval(2); $graph->xaxis->SetTickLabels($databarx); $graph->xaxis->SetLabelAngle(90); // Create a red line plot $p1 = new Plot\LinePlot($datay); $p1->SetColor("red"); $p1->SetLegend("Pressure"); // Create the bar plot $b1 = new Plot\BarPlot($databary); $b1->SetLegend("Temperature"); $b1->SetAbsWidth(6); $b1->SetShadow(); // The order the plots are added determines who's ontop $graph->Add($p1); $graph->Add($b1); // Finally output the image $graph->Stroke();
<?php // 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"); // 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'); // Setup values $bplot->value->Show(); $bplot->value->SetFormat('%d'); $bplot->value->SetFont(FF_FONT1, FS_BOLD); // Center the values in the bar $bplot->SetValuePos('center'); // Make the bar a little bit wider $bplot->SetWidth(0.7); $graph->Add($bplot); // Setup the titles $graph->title->Set("Centered values for bars"); $graph->xaxis->title->Set("X-title"); $graph->yaxis->title->Set("Y-title"); $graph->title->SetFont(FF_FONT1, FS_BOLD);
<?php // 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"); // 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->SetWidth(1.0); $graph->Add($bplot); // Setup the titles $graph->title->Set("Bar graph"); $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();
$graph = new Graph\Graph(400, 300); $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);
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_bar.php'; require_once 'jpgraph/jpgraph_line.php'; require_once 'jpgraph/jpgraph_plotline.php'; $datay = array(2, 3, 5, 8.5, 11.5, 6, 3); // Create the graph. $graph = new Graph\Graph(460, 400, 'auto'); $graph->SetScale("textlin"); $graph->SetMargin(40, 20, 50, 70); $graph->legend->SetPos(0.5, 0.97, 'center', 'bottom'); $graph->title->Set('Plot line legend'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); $graph->SetTitleBackground('lightblue:1.3', TITLEBKG_STYLE2, TITLEBKG_FRAME_BEVEL); $graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED, 'lightblue', 'navy'); // Create a bar pot $bplot = new Plot\BarPlot($datay); $bplot->value->Show(); $bplot->value->SetFont(FF_VERDANA, FS_BOLD, 8); $bplot->SetValuePos('top'); $bplot->SetLegend('Bar Legend'); $graph->Add($bplot); $pline = new PlotLine(HORIZONTAL, 8, 'red', 2); $pline->SetLegend('Line Legend'); $graph->legend->SetColumns(10); $graph->Add($pline); $graph->Stroke();
$l1datay = array(11, 9, 2, 4, 3, 13, 17); $l2datay = array(23, 12, 5, 19, 17, 10, 15); $datax = $gDateLocale->GetShortMonth(); // Create the graph. $graph = new Graph\Graph(400, 200); $graph->SetScale("textlin"); $graph->SetMargin(40, 130, 20, 40); $graph->SetShadow(); $graph->xaxis->SetTickLabels($datax); // Create the linear error plot $l1plot = new Plot\LinePlot($l1datay); $l1plot->SetColor("red"); $l1plot->SetWeight(2); $l1plot->SetLegend("Prediction"); //Center the line plot in the center of the bars $l1plot->SetBarCenter(); // Create the bar plot $bplot = new Plot\BarPlot($l2datay); $bplot->SetFillColor("orange"); $bplot->SetLegend("Result"); // Add the plots to t'he graph $graph->Add($bplot); $graph->Add($l1plot); $graph->title->Set("Adding a line plot to a bar graph v1"); $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();
$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("Use of static line, 3D and solid band"); // Turn off Y-grid (it's on by default) $graph->ygrid->Show(false); // Add 10% grace ("space") at top of Y-scale. $graph->yscale->SetGrace(10); $graph->yscale->SetAutoMin(-20); // 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"); $bplot->SetShadow("darkblue"); // 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 $band[0] = new Plot\PlotBand(HORIZONTAL, BAND_3DPLANE, "min", 0, "blue"); $band[0]->ShowFrame(false); $band[0]->SetDensity(20); $band[1] = new Plot\PlotBand(HORIZONTAL, BAND_SOLID, 0, "max", "steelblue"); $band[1]->ShowFrame(false);
<?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();
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_bar.php'; $datay = array(12, 26, 9, 17, 31); // Create the graph. $graph = new Graph\Graph(400, 250); $graph->SetScale("textlin"); $graph->SetMargin(50, 80, 20, 40); $graph->yaxis->SetTitleMargin(30); $graph->yaxis->scale->SetGrace(30); $graph->SetShadow(); // Create a bar pot $bplot = new Plot\BarPlot($datay); // Create targets for the bars image maps. One for each column $targ = array("bar_clsmex1.php#1", "bar_clsmex1.php#2", "bar_clsmex1.php#3", "bar_clsmex1.php#4", "bar_clsmex1.php#5", "bar_clsmex1.php#6"); $alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d"); $bplot->SetCSIMTargets($targ, $alts); $bplot->SetFillColor("orange"); $bplot->SetLegend('Year 2001 %%', '#kalle ', '%s'); // Display the values on top of each bar $bplot->SetShadow(); $bplot->value->SetFormat(" \$ %2.1f", 70); $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 9); $bplot->value->SetColor("blue"); $bplot->value->Show(); $graph->Add($bplot); // Create a big "button" that has an image map action $txt1 = new Text("A simple text with\ntwo rows"); $txt1->SetFont(FF_ARIAL);
$graph = new Graph\Graph($width, $height); $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
$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();
} // new Graph\Graph with a background image and drop shadow $graph = new Graph\Graph(450, 300); $graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME); $graph->SetShadow(); // Use an integer X-scale $graph->SetScale("intlin"); // Set title and subtitle $graph->title->Set("Combined bar and line plot"); $graph->subtitle->Set("(\"left\" aligned bars)"); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Make the margin around the plot a little bit bigger // then default $graph->img->SetMargin(40, 120, 40, 40); // Slightly adjust the legend from it's default position in the // top right corner to middle right side $graph->legend->Pos(0.05, 0.5, "right", "center"); // Create a red line plot $p1 = new Plot\LinePlot($datay, $datax); $p1->SetColor("red"); $p1->SetLegend("Status one"); $graph->Add($p1); // Create the bar plot $b1 = new Plot\BarPlot($databary, $databarx); $b1->SetLegend("Status two"); $b1->SetAlign("left"); $b1->SetShadow(); $graph->Add($b1); // Finally output the image $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();
<?php // 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
$data1y = array(12, 8, 19, 3, 10, 5); $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