$lr = new LinearRegression($datax, $datay); list($stderr, $corr) = $lr->GetStat(); list($xd, $yd) = $lr->GetY(0, 19); // Create the graph $graph = new Graph\Graph(300, 250); $graph->SetScale('linlin'); // Setup title $graph->title->Set("Linear regression"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); $graph->subtitle->Set('(stderr=' . sprintf('%.2f', $stderr) . ', corr=' . sprintf('%.2f', $corr) . ')'); $graph->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 12); // make sure that the X-axis is always at the // bottom at the plot and not just at Y=0 which is // the default position $graph->xaxis->SetPos('min'); // Create the scatter plot with some nice colors $sp1 = new ScatterPlot($datay, $datax); $sp1->mark->SetType(MARK_FILLEDCIRCLE); $sp1->mark->SetFillColor("red"); $sp1->SetColor("blue"); $sp1->SetWeight(3); $sp1->mark->SetWidth(4); // Create the regression line $lplot = new Plot\LinePlot($yd); $lplot->SetWeight(2); $lplot->SetColor('navy'); // Add the pltos to the line $graph->Add($sp1); $graph->Add($lplot); // ... and stroke $graph->Stroke();
use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; $ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7); $y2data = array(354, 200, 265, 99, 111, 91, 198, 225, 293, 251); // Create the graph and specify the scale for both Y-axis $graph = new Graph\Graph(400, 200); $graph->SetScale('textlin'); $graph->SetY2Scale('lin'); $graph->SetShadow(); // Adjust the margin $graph->img->SetMargin(40, 140, 20, 40); // Create the two linear plot $lineplot = new Plot\LinePlot($ydata); $lineplot2 = new Plot\LinePlot($y2data); // Add the plot to the graph $graph->Add($lineplot); $graph->AddY2($lineplot2); $lineplot2->SetColor('orange'); $lineplot2->SetWeight(2); // Adjust the axis color $graph->y2axis->SetColor('orange'); $graph->yaxis->SetColor('blue'); $graph->title->Set('Example 6'); $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); // Set the colors for the plots $lineplot->SetColor('blue'); $lineplot->SetWeight(2);
<?php // content="text/plain; charset=utf-8" require_once '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; // Some data for ($i = 0; $i < 12; ++$i) { $databary[$i] = rand(1, 20); } $months = $gDateLocale->GetShortMonth(); // new Graph\Graph with a drop shadow $graph = new Graph\Graph(300, 200); $graph->SetShadow(); // Use a "text" X-scale $graph->SetScale('textlin'); // Specify X-labels $graph->xaxis->SetTickLabels($months); $graph->xaxis->SetTextTickInterval(2, 0); // Set title and subtitle $graph->title->Set('Textscale with tickinterval=2'); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Create the bar plot $b1 = new Plot\BarPlot($databary); $b1->SetLegend('Temperature'); // The order the plots are added determines who's ontop $graph->Add($b1); // Finally output the image $graph->Stroke();
<?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'); // Create the second bar $bplot2 = new Plot\BarPlot($datay2); $bplot2->SetFillGradient('olivedrab1', 'olivedrab4', GRAD_VERT); $bplot2->SetColor('darkgreen'); // And join them in an accumulated bar $accbplot = new Plot\AccBarPlot(array($bplot, $bplot2)); $graph->Add($accbplot); $graph->Stroke();
// Create the graph. These two calls are always required $graph = new Graph\Graph(310, 200, 'auto'); $graph->SetScale("textlin"); $graph->img->SetMargin(40, 30, 20, 40); $graph->SetShadow(); // Create the bar plots $b1plot = new Plot\BarPlot($data1y); $b1plot->SetFillColor("orange"); $targ = array("bar_clsmex2.php#1", "bar_clsmex2.php#2", "bar_clsmex2.php#3", "bar_clsmex2.php#4", "bar_clsmex2.php#5", "bar_clsmex2.php#6"); $alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d"); $b1plot->SetCSIMTargets($targ, $alts); $b2plot = new Plot\BarPlot($data2y); $b2plot->SetFillColor("blue"); $targ = array("bar_clsmex2.php#7", "bar_clsmex2.php#8", "bar_clsmex2.php#9", "bar_clsmex2.php#10", "bar_clsmex2.php#11", "bar_clsmex2.php#12"); $alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d"); $b2plot->SetCSIMTargets($targ, $alts); // Create the grouped bar plot $abplot = new Plot\AccBarPlot(array($b1plot, $b2plot)); $abplot->SetShadow(); $abplot->value->Show(); // ...and add it to the graPH $graph->Add($abplot); $graph->title->Set("Image map barex2"); $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); // Send back the HTML page which will call this script again // to retrieve the image. $graph->StrokeCSIM();
require_once '../../vendor/autoload.php'; require_once 'jpgraph/jpgraph_line.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; $ydata = array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11); $ydata2 = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); $targ = array("#1", "#2", "#3", "#4", "#5", "#6", "#7", "#8", "#9", "#10"); $alt = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // Create the graph. $graph = new Graph\Graph(300, 200); $graph->SetScale("textlin"); $graph->img->SetMargin(40, 20, 30, 40); $graph->title->Set("CSIM example with bar and line"); $graph->title->SetFont(FF_FONT1, FS_BOLD); // Setup axis titles $graph->xaxis->title->Set("X-title"); $graph->yaxis->title->Set("Y-title"); // Create the linear plot $lineplot = new Plot\LinePlot($ydata); $lineplot->mark->SetType(MARK_FILLEDCIRCLE); $lineplot->mark->SetWidth(5); $lineplot->mark->SetColor('black'); $lineplot->mark->SetFillColor('red'); $lineplot->SetCSIMTargets($targ, $alt); // Create line plot $barplot = new Plot\BarPlot($ydata2); $barplot->SetCSIMTargets($targ, $alt); // Add the plots to the graph $graph->Add($lineplot); $graph->Add($barplot); $graph->StrokeCSIM();
$graph->SetColor(array(250, 250, 250)); $graph->img->SetTransparent("white"); $t1 = new Text\Text("This is a text"); $t1->SetPos(0.5, 0.5); $t1->SetOrientation("h"); $t1->SetFont(FF_FONT1, FS_BOLD); $t1->SetBox("white", "black", "gray"); $t1->SetColor("black"); $graph->AddText($t1); // Create the linear error plot $l1plot = new Plot\LinePlot($l1datay); $l1plot->SetColor("blue"); $l1plot->SetWeight(2); $l1plot->SetLegend("Prediction"); // Create the bar plot $l2plot = new Plot\BarPlot($l2datay); $l2plot->SetFillColor("orange"); $l2plot->SetLegend("Result"); // Add the plots to the graph $graph->Add($l1plot); $graph->Add($l2plot); $graph->title->Set("Example 16.3"); $graph->xaxis->title->Set("Month"); $graph->yaxis->title->Set("x10,000 US\$"); $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();
$data1y = array(47, 80, 40, 116); $data2y = array(61, 30, 82, 105); $data3y = array(115, 50, 70, 93); // Create the graph. These two calls are always required $graph = new Graph\Graph(350, 200, 'auto'); $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->yaxis->SetTickPositions(array(0, 30, 60, 90, 120, 150), array(15, 45, 75, 105, 135)); $graph->SetBox(false); $graph->ygrid->SetFill(false); $graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D')); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); // Create the bar plots $b1plot = new Plot\BarPlot($data1y); $b2plot = new Plot\BarPlot($data2y); $b3plot = new Plot\BarPlot($data3y); // Create the grouped bar plot $gbplot = new Plot\GroupBarPlot(array($b1plot, $b2plot, $b3plot)); // ...and add it to the graPH $graph->Add($gbplot); $b1plot->SetColor("white"); $b1plot->SetFillColor("#cc1111"); $b2plot->SetColor("white"); $b2plot->SetFillColor("#11cccc"); $b3plot->SetColor("white"); $b3plot->SetFillColor("#1111cc"); $graph->title->Set("Bar Plots"); // Display the graph $graph->Stroke();
$graph->SetScale("textlin"); if ($theme) { $graph->SetTheme(new $theme()); } $theme_class = new Themes\AquaTheme(); $graph->SetTheme($theme_class); $plot = array(); // Create the bar plots for ($i = 0; $i < 4; $i++) { $plot[$i] = new Plot\BarPlot($data[$i]); $plot[$i]->SetLegend('plot' . ($i + 1)); } //$acc1 = new Plot\AccBarPlot(array($plot[0], $plot[1])); //$acc1->value->Show(); Kint::enabled(true); ddd($plot); $gbplot = new Plot\GroupBarPlot(array($plot[2], $plot[1])); for ($i = 4; $i < 8; $i++) { $plot[$i] = new Plot\LinePlot($data[$i]); $plot[$i]->SetLegend('plot' . $i); $plot[$i]->value->Show(); } $graph->Add($gbplot); $graph->Add($plot[4]); $title = "AquaTheme Example"; $title = mb_convert_encoding($title, 'UTF-8'); $graph->title->Set($title); $graph->xaxis->title->Set("X-title"); $graph->yaxis->title->Set("Y-title"); // Display the graph $graph->Stroke();
$graph->xaxis->SetLabelMargin(10); // Label align for X-axis $graph->xaxis->SetLabelAlign('right', 'center'); // Add some grace to y-axis so the bars doesn't go // all the way to the end of the plot area $graph->yaxis->scale->SetGrace(20); // We don't want to display Y-axis $graph->yaxis->Hide(); // Now create a bar pot $bplot = new Plot\BarPlot($datay); $bplot->SetShadow(); //You can change the width of the bars if you like //$bplot->SetWidth(0.5); // Set gradient fill for bars $bplot->SetFillGradient('darkred', 'yellow', GRAD_HOR); // We want to display the value of each bar at the top $bplot->value->Show(); $bplot->value->SetFont(FF_ARIAL, FS_BOLD, 10); //$bplot->value->SetAlign('left','center'); $bplot->value->SetColor("white"); $bplot->value->SetFormat('%.1f'); $bplot->SetValuePos('max'); // Add the bar to the graph $graph->Add($bplot); // Add some explanation text $txt = new Text('Note: Higher value is better.'); $txt->SetPos(190, 399, 'center', 'bottom'); $txt->SetFont(FF_ARIAL, FS_NORMAL, 8); $graph->Add($txt); // .. and stroke the graph $graph->Stroke();
require_once '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; $datay1 = array(11, 7, 5, 8, 3, 5, 5, 4, 8, 6, 5, 5, 3, 2, 5, 1, 2, 0); $datay2 = array(4, 5, 4, 5, 6, 5, 7, 4, 7, 4, 4, 3, 2, 4, 1, 2, 2, 1); $datay3 = array(4, 5, 7, 10, 13, 15, 15, 22, 26, 26, 30, 34, 40, 43, 47, 55, 60, 62); // Create the graph. These two calls are always required $graph = new Graph\Graph(300, 200); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->img->SetMargin(40, 30, 20, 40); // Create the linear plots for each category $dplot[] = new Plot\LinePlot($datay1); $dplot[] = new Plot\LinePlot($datay2); $dplot[] = new Plot\LinePlot($datay3); $dplot[0]->SetFillColor("red"); $dplot[1]->SetFillColor("blue"); $dplot[2]->SetFillColor("green"); // Create the accumulated graph $accplot = new AccLinePlot($dplot); // Add the plot to the graph $graph->Add($accplot); $graph->xaxis->SetTextTickInterval(2); $graph->title->Set("Example 17"); $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 '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; $errdatay = array(11, 9, 2, 4, 19, 26, 13, 19, 7, 12); // Create the graph. These two calls are always required $graph = new Graph\Graph(300, 200); $graph->SetScale("textlin"); $graph->img->SetMargin(40, 30, 20, 40); $graph->SetShadow(); // Create the linear plot $errplot = new Plot\ErrorLinePlot($errdatay); $errplot->SetColor("red"); $errplot->SetWeight(2); $errplot->SetCenter(); $errplot->line->SetWeight(2); $errplot->line->SetColor("blue"); // Add the plot to the graph $graph->Add($errplot); $graph->title->Set("Linear error plot"); $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); $datax = $gDateLocale->GetShortMonth(); $graph->xaxis->SetTickLabels($datax); // Display the graph $graph->Stroke();
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetColor('white'); $graph->yaxis->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->SetColor('white'); //$graph->ygrid->Show(false); $graph->ygrid->SetColor('white@0.5'); // Setup graph title $graph->title->Set('Using alpha blending with a 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('orange@0.4'); $bplot2->SetFillColor('brown@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" require_once '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; $ydata = array(12, 19, 3, 9, 15, 10); // The code to setup a very basic graph $graph = new Graph\Graph(200, 150); $graph->SetScale('intlin'); $graph->SetMargin(30, 15, 40, 30); $graph->SetMarginColor('white'); $graph->SetFrame(true, 'blue', 3); $graph->title->Set('Label background'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12); $graph->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 10); $graph->subtitle->SetColor('darkred'); $graph->subtitle->Set('"LABELBKG_YAXIS"'); $graph->SetAxisLabelBackground(LABELBKG_YAXIS, 'orange', 'red', 'lightblue', 'red'); // Use Ariel font $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 9); $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 9); $graph->xgrid->Show(); // Create the plot line $p1 = new Plot\LinePlot($ydata); $graph->Add($p1); // Output graph $graph->Stroke();
<?php // content="text/plain; charset=utf-8" require_once '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; $datay = array(62, 105, 85, 50); // Create the graph. These two calls are always required $graph = new Graph\Graph(350, 220, 'auto'); $graph->SetScale("textlin"); //$theme_class="DefaultTheme"; //$graph->SetTheme(new $theme_class()); // set major and minor tick positions manually $graph->yaxis->SetTickPositions(array(0, 30, 60, 90, 120, 150), array(15, 45, 75, 105, 135)); $graph->SetBox(false); //$graph->ygrid->SetColor('gray'); $graph->ygrid->SetFill(false); $graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D')); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); // Create the bar plots $b1plot = new Plot\BarPlot($datay); // ...and add it to the graPH $graph->Add($b1plot); $b1plot->SetColor("white"); $b1plot->SetFillGradient("#4B0082", "white", GRAD_LEFT_REFLECTION); $b1plot->SetWidth(45); $graph->title->Set("Bar Gradient(Left reflection)"); // Display the graph $graph->Stroke();
<?php // content="text/plain; charset=utf-8" // Basic contour plot example require_once '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; $data = array(array(12, 7, 3, 15), array(18, 5, 1, 9), array(13, 9, 5, 12), array(5, 3, 8, 9), array(1, 8, 5, 7)); // Basic contour graph $graph = new Graph\Graph(350, 250); $graph->SetScale('intint'); // Show axis on all sides $graph->SetAxisStyle(AXSTYLE_BOXOUT); // Adjust the margins to fit the margin $graph->SetMargin(30, 100, 40, 30); // Setup $graph->title->Set('Basic contour plot with multiple axis'); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12); // A simple contour plot with default arguments (e.g. 10 isobar lines) $cp = new Plot\ContourPlot($data, 10, 2); // Display the legend $cp->ShowLegend(); $graph->Add($cp); // ... and send the graph back to the browser $graph->Stroke();
<?php // content="text/plain; charset=utf-8" require_once '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; $data = array(0.1235, 0.4567, 0.67, 0.45, 0.832); // Callback function // Get called with the actual value and should return the // value to be displayed as a string function cbFmtPercentage($aVal) { return sprintf("%.1f%%", 100 * $aVal); // Convert to string } // Create the graph. $graph = new Graph\Graph(400, 300); $graph->SetScale("textlin"); // Create a bar plots $bar1 = new Plot\BarPlot($data); // Setup the callback function $bar1->value->SetFormatCallback("cbFmtPercentage"); $bar1->value->Show(); // Add the plot to the graph $graph->Add($bar1); // .. and send the graph back to the browser $graph->Stroke();
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 $bplot = new Plot\BarPlot($l2datay); $bplot->SetFillColor("orange"); $bplot->SetLegend("Result"); // Add the plots to t'he graph $graph->Add($l1plot); $graph->Add($bplot); $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); //$graph->xaxis->SetTickLabels($datax); //$graph->xaxis->SetTextTickInterval(2); // Display the graph $graph->Stroke();
$graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); // Setup month as labels on the X-axis $graph->xaxis->SetTickLabels($months); // Create the bar plots $b1plot = new Plot\BarPlot($data1y); $b2plot = new Plot\BarPlot($data2y); $b3plot = new Plot\BarPlot($data3y); $b4plot = new Plot\BarPlot($data4y); $b5plot = new Plot\BarPlot($data5y); $lplot = new Plot\LinePlot($data6y); // Create the grouped bar plot $gbbplot = new Plot\AccBarPlot(array($b3plot, $b4plot, $b5plot)); $gbplot = new Plot\GroupBarPlot(array($b1plot, $b2plot, $gbbplot)); // ...and add it to the graPH $graph->Add($gbplot); $graph->AddY2($lplot); $b1plot->SetColor("#0000CD"); $b1plot->SetFillColor("#0000CD"); $b1plot->SetLegend("Cliants"); $b2plot->SetColor("#B0C4DE"); $b2plot->SetFillColor("#B0C4DE"); $b2plot->SetLegend("Machines"); $b3plot->SetColor("#8B008B"); $b3plot->SetFillColor("#8B008B"); $b3plot->SetLegend("First Track"); $b4plot->SetColor("#DA70D6"); $b4plot->SetFillColor("#DA70D6"); $b4plot->SetLegend("All"); $b5plot->SetColor("#9370DB"); $b5plot->SetFillColor("#9370DB");
<?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();
$datazero = array(0, 0, 0, 0); // Create the graph. $graph = new Graph\Graph(450, 200); $graph->title->Set('Example with 2 scale bars'); // Setup Y and Y2 scales with some "grace" $graph->SetScale("textlin"); $graph->SetY2Scale("lin"); $graph->yaxis->scale->SetGrace(30); $graph->y2axis->scale->SetGrace(30); //$graph->ygrid->Show(true,true); $graph->ygrid->SetColor('gray', 'lightgray@0.5'); // Setup graph colors $graph->SetMarginColor('white'); $graph->y2axis->SetColor('darkred'); // Create the "dummy" 0 bplot $bplotzero = new Plot\BarPlot($datazero); // Create the "Y" axis group $ybplot1 = new Plot\BarPlot($datay); $ybplot1->value->Show(); $ybplot = new Plot\GroupBarPlot(array($ybplot1, $bplotzero)); // Create the "Y2" axis group $ybplot2 = new Plot\BarPlot($datay2); $ybplot2->value->Show(); $ybplot2->value->SetColor('darkred'); $ybplot2->SetFillColor('darkred'); $y2bplot = new Plot\GroupBarPlot(array($bplotzero, $ybplot2)); // Add the grouped bar plots to the graph $graph->Add($ybplot); $graph->AddY2($y2bplot); // .. and finally stroke the image back to browser $graph->Stroke();