function conf__grafico(toba_ei_grafico $grafico) { if (isset($this->datos)) { $datos = array(); $leyendas = array(); foreach ($this->datos as $value) { $datos[] = $value['resultado']; $leyendas[] = $value['codc_uacad']; } } require_once toba_dir() . '/php/3ros/jpgraph/jpgraph.php'; require_once toba_dir() . '/php/3ros/jpgraph/jpgraph_bar.php'; // Setup a basic graph context with some generous margins to be able // to fit the legend $canvas = new Graph(900, 300); $canvas->SetMargin(100, 140, 60, 40); $canvas->title->Set('Cr�dito Disponible'); //$canvas->title->SetFont(FF_ARIAL,FS_BOLD,14); // For contour plots it is custom to use a box style ofr the axis $canvas->legend->SetPos(0.05, 0.5, 'right', 'center'); $canvas->SetScale('intint'); //$canvas->SetAxisStyle(AXSTYLE_BOXOUT); //$canvas->xgrid->Show(); $canvas->ygrid->Show(); $canvas->xaxis->SetTickLabels($leyendas); // A simple contour plot with default arguments (e.g. 10 isobar lines) $cp = new BarPlot($datos); $cp->SetColor("#B0C4DE"); $cp->SetFillColor("#B0C4DE"); $cp->SetLegend("Resultado"); $canvas->Add($cp); // Con esta llamada informamos al gr�fico cu�l es el gr�fico que se tiene // que dibujar $grafico->conf()->canvas__set($canvas); }
/** * Para el tipo de gráfico 'otro' hay que especificar todo lo referente a * jpgraph. Desde la inclusión de los archivos necesarios hasta la instanciación * de todas las componentes que esta necesita para generar un gráfico. * Lo único que hay que hacer es 'avisarle' al gráfico de toba cuál es el * canvas que se tiene que dibujar. Todo el resto es legal y bonito * * @param toba_ei_grafico $grafico */ function conf__grafico(toba_ei_grafico $grafico) { require_once toba_dir() . '/php/3ros/jpgraph/jpgraph.php'; require_once toba_dir() . '/php/3ros/jpgraph/jpgraph_contour.php'; $data = array(array(0.5, 1.1, 1.5, 1, 2.0, 3, 3, 2, 1, 0.1), array(1.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 1, 4), array(0.9, 2.0, 2.1, 3, 6.0, 7, 3, 2, 1, 1.4), array(1.0, 1.5, 3.0, 4, 6.0, 5, 2, 1.5, 1, 2), array(0.8, 2.0, 3.0, 3, 4.0, 4, 3, 2.4, 2, 3), array(0.6, 1.1, 1.5, 1, 4.0, 3.5, 3, 2, 3, 4), array(9.0, 1.5, 3.0, 5, 6.0, 2, 1, 1.2, 2.7, 4), array(9.800000000000001, 9.0, 3.0, 3, 5.5, 6, 3, 2, 1, 1.4), array(9.0, 1.5, 3.0, 4, 6.0, 5, 2, 1, 0.5, 0.2)); // Setup a basic graph context with some generous margins to be able // to fit the legend $canvas = new Graph(650, 300); $canvas->SetMargin(40, 140, 60, 40); $canvas->title->Set('Uso avanzado de la librería'); $canvas->title->SetFont(FF_ARIAL, FS_BOLD, 14); // For contour plots it is custom to use a box style ofr the axis $canvas->legend->SetPos(0.05, 0.5, 'right', 'center'); $canvas->SetScale('intint'); $canvas->SetAxisStyle(AXSTYLE_BOXOUT); $canvas->xgrid->Show(); $canvas->ygrid->Show(); // A simple contour plot with default arguments (e.g. 10 isobar lines) $cp = new ContourPlot($data); // Display the legend $cp->ShowLegend(); // Make the isobar lines slightly thicker $cp->SetLineWeight(2); $canvas->Add($cp); // Con esta llamada informamos al gráfico cuál es el gráfico que se tiene // que dibujar $grafico->conf()->canvas__set($canvas); }
public static function lineChart($data1, $data2, $legends) { $graph = new Graph(600, 400); $graph->SetScale('intlin'); $graph->SetShadow(); $graph->SetMargin(40, 20, 20, 40); // $graph->title->Set('Calls per operator (June,July)'); // $graph->subtitle->Set('(March 12, 2008)'); // $graph->xaxis->title->Set('Operator'); // $graph->yaxis->title->Set('# of calls'); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetTickLabels($legends); $lineplot = new LinePlot($data1); $lineplot->SetWeight(4); // Two pixel wide // Add the plot to the graph $graph->Add($lineplot); // Create the second data series $lineplot2 = new LinePlot($data2); $lineplot2->SetWeight(4); // Two pixel wide $graph->Add($lineplot2); $lineplot->SetLegend("This Year"); $lineplot2->SetLegend("Last Year"); $graph->legend->SetLayout(LEGEND_HOR); $graph->legend->Pos(0.4, 0.95, "center", "bottom"); return $graph->Stroke('../graph/compareLineChart.png'); }
function barcart($datay) { require_once "jpgraph/jpgraph.php"; require_once "jpgraph/jpgraph_bar.php"; // Setup the graph. $graph = new Graph(660, 250); $graph->SetScale("textlin"); // Add a drop shadow $graph->SetShadow(); // Adjust the margin a bit to make more room for titles $graph->SetMargin(40, 30, 20, 40); // Setup the titles $graph->title->Set('NHR Registry'); $graph->xaxis->title->Set('X-title'); $graph->yaxis->title->Set('Y-title'); // Create the bar pot $bplot = new BarPlot($datay); // Adjust fill color $bplot->SetFillColor('orange'); $graph->Add($bplot); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); return $graph; }
public function bar_task($id) { $help = new Helper(); $issues = $help->searchIssues($id); //foreach ($issues as $issue) { # code... // $issue->id //} //$iteration = Iterations::findOrFail($id); //$idTmp = $iteration->id; // $issues = Issue::where('iterationid','=', $idTmp)->get(); //$issues = $iteration->issues; //$countIssues = sizeof($issues); $countIssues = 0; $dataEstimatedTime = array(); $dataRealTime = array(); $dataIterationName = array(); $countTODO = 0; $countDOING = 0; $countDONE = 0; //$string_iterations = implode(";", $iterations); JpGraph\JpGraph::load(); JpGraph\JpGraph::module('bar'); JpGraph\JpGraph::module('line'); $datay = array(12, 8, 19, 3, 10, 5); // Create the graph. These two calls are always required $graph = new Graph(300, 200); $graph->SetScale('textlin'); // Add a drop shadow $graph->SetShadow(); // Adjust the margin a bit to make more room for titles $graph->SetMargin(40, 30, 20, 40); // Create a bar pot $bplot = new BarPlot($datay); // Adjust fill color $bplot->SetFillColor('orange'); $graph->Add($bplot); // Setup the titles $graph->title->Set('A basic 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); //$graph->Stroke(); //$response = Response::make( // $graph->Stroke() //); // $response->header('content-type', 'image/png'); // return $response; }
public function toPdf($titulo, $consulta, $encabezado) { //$data1y = array(4,8,6); $this->pdf->FPDF('P', 'mm', 'Letter'); $this->pdf->SetTopMargin(20); $this->pdf->SetLeftMargin(20); $this->pdf->AddPage(); $this->pdf->SetFillColor(255); $this->pdf->SetFont('Arial', 'B', 16); $this->pdf->Cell(180, 32, $titulo, 0, 0, 'C'); $this->pdf->SetFont('Arial', 'B', 13); $this->pdf->Ln(26); $this->pdf->Ln(15); //$graph = new \Graph(270, 200, 'auto'); // Se define el array de datos $datosy = array(25, 16, 24, 5, 8, 31); // Creamos el grafico $grafico = new \Graph(500, 250); $grafico->SetScale('textlin'); // Ajustamos los margenes del grafico----- (left,right,top,bottom) $grafico->SetMargin(40, 30, 30, 40); // Creamos barras de datos a partir del array de datos $bplot = new \BarPlot($datosy); // Configuramos color de las barras $bplot->SetFillColor('#479CC9'); //Añadimos barra de datos al grafico $grafico->Add($bplot); // Queremos mostrar el valor numerico de la barra $bplot->value->Show(); // Configuracion de los titulos $grafico->title->Set('Ingreso de paquetes'); $grafico->xaxis->title->Set('Meses'); $grafico->yaxis->title->Set('Ingresos ($)'); $grafico->title->SetFont(FF_FONT1, FS_BOLD); $grafico->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $grafico->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $nombreGrafico = "Barras"; @unlink("{$nombreGrafico}.png"); // Se muestra el grafico $grafico->Stroke("{$nombreGrafico}.png"); //img = $grafico->Stroke(_IMG_HANDLER); //Aqui agrego la imagen que acabo de crear con jpgraph $this->pdf->Image("{$nombreGrafico}.png", $this->pdf->GetX() + 20, $this->pdf->GetY(), 120, 90); //$this->pdf->GDImage($img,50,50,110,70); $this->pdf->Output(); return $this->pdf; }
function createSpline($ydata = "") { $xdata = array(2, 4, 6, 8, 10, 12, 14, 16); if (!$ydata) { $ydata = array(5, 1, 9, 6, 4, 3, 4, 2); } // Get the interpolated values by creating // a new Spline object. $spline = new Spline($xdata, $ydata); // For the new data set we want 40 points to // get a smooth curve. list($newx, $newy) = $spline->Get(50); // Create the graph $g = new Graph(380, 300); $g->SetMargin(30, 20, 40, 30); //$g->title->Set("Natural cubic splines"); //$g->title->SetFont(FF_ARIAL,FS_NORMAL,12); //$g->subtitle->Set('(Control points shown in red)'); //$g->subtitle->SetColor('darkred'); $g->SetMarginColor('lightblue'); //$g->img->SetAntiAliasing(); // We need a linlin scale since we provide both // x and y coordinates for the data points. $g->SetScale('linlin'); $xlable = array('', 'AA', 'AA', 'AB', 'AB', 'BB', 'BB', 'BC', 'BC', 'CC', 'CC', 'CD', 'CD', 'DD', 'DD', 'FF', 'FF', ''); // We want 1 decimal for the X-label //$g -> xaxis -> SetLabelFormat('%d'); $g->xaxis->SetTickLabels($xlable); // We use a scatterplot to illustrate the original // contro points. $splot = new ScatterPlot($ydata, $xdata); // $splot->mark->SetFillColor('red@0.3'); $splot->mark->SetColor('red@0.5'); // And a line plot to stroke the smooth curve we got // from the original control points $lplot = new LinePlot($newy, $newx); $lplot->SetColor('navy'); // Add the plots to the graph and stroke $g->Add($lplot); $g->Add($splot); $g->Stroke(); }
public function getGrafico() { $em = new EntityManager($_SESSION['project']['conection']); $em->query($this->query); $rows = $em->fetchResult(); $nRegistros = $em->numRows(); $em->desConecta(); unset($em); foreach ($rows as $value) { $this->datosY[] = $value[$this->columnaY]; $this->titulosX[] = $value[$this->columnaX]; } $grafico = new Graph($this->ancho, $this->alto); $grafico->SetScale('textlin'); // Ajustamos los margenes del grafico----- (left,right,top,bottom) $grafico->SetMargin(40, 30, 30, 40); // Creamos barras de datos a partir del array de datos $bplot = new BarPlot($this->datosY); // Configuramos color de las barras $bplot->SetFillColor('#479CC9'); //Añadimos barra de datos al grafico $grafico->Add($bplot); // Queremos mostrar el valor numerico de la barra $bplot->value->Show(); // Configuracion de los titulos $grafico->title->Set($this->titulo); $grafico->xaxis->title->Set($this->tituloX); $grafico->yaxis->title->Set($this->tituloY); $grafico->title->SetFont(FF_FONT1, FS_BOLD); $grafico->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $grafico->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $grafico->xaxis->SetTickLabels($this->titulosX); // Se generada el archivo con el gráfico $archivo = "docs/docs" . $_SESSION['emp'] . "/tmp/" . md5(date('d-m-Y H:i:s')) . ".png"; $grafico->Stroke($archivo); return $archivo; }
$graph3->title->SetFont(FF_FONT1, FS_BOLD); $graph3->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph3->xaxis->title->SetFont(FF_FONT1, FS_BOLD); // Setup the values that are displayed on top of each bar $bplot3->value->Show(); // Must use TTF fonts if we want text at an arbitrary angle $bplot3->value->SetFont(FF_FONT1, FS_BOLD); $bplot3->value->SetAngle(0); $bplot3->value->SetFormat('%d'); // Create the graph. These two calls are always required $graph4 = new Graph(740, 200, 'auto'); $graph4->SetScale('textint', 0, max($y4) + max($y4) * 0.2, 0, 0); // Add a drop shadow $graph4->SetShadow(); // Adjust the margin a bit to make more room for titles $graph4->SetMargin(50, 30, 30, 40); // Create a bar pot $bplot4 = new BarPlot($y4); // Adjust fill color $bplot4->SetFillColor('purple1'); $graph4->Add($bplot4); // Setup the titles $descibe4 = iconv('UTF-8', 'ASCII//TRANSLIT', tr("octeam_stat_m_caches")); $graph4->title->Set($descibe4); $graph4->xaxis->title->Set(iconv('UTF-8', 'ASCII//TRANSLIT', tr('number_month')) . '2014/2015'); $graph4->xaxis->SetTickLabels($x4); $graph4->yaxis->title->Set($ncaches); $graph4->title->SetFont(FF_FONT1, FS_BOLD); $graph4->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph4->xaxis->title->SetFont(FF_FONT1, FS_BOLD); // Setup the values that are displayed on top of each bar
} elseif ($value['var1'] == 'Enterprise-Image-Impact') { $data4['value'][$value['var3'] - 1] = $value['var2']; } elseif ($value['var1'] == 'Financial-Impact') { $data5['value'][$value['var3'] - 1] = $value['var2']; } } // require_once 'ossim_conf.inc'; $conf = $GLOBALS["CONF"]; $jpgraph = $conf->get_conf("jpgraph_path"); require_once "{$jpgraph}/jpgraph.php"; require_once "{$jpgraph}/jpgraph_line.php"; // Setup the graph. $graph = new Graph(600, 300, "auto"); $graph->SetScale("textlin"); $graph->SetMargin(100, 10, 20, 86); $graph->SetMarginColor("#fafafa"); $graph->xaxis->SetTickLabels(array(_("Ene"), _("Feb"), _("Mar"), _("Apr"), _("May"), _("Jun"), _("Jul"), _("Ago"), _("Sep"), _("Oct"), _("Nov"), _("Dic"))); $graph->SetColor("#fafafa"); $graph->SetFrame(true, '#fafafa', 0); $dplot[0] = new LinePLot($data1['value']); $dplot[1] = new LinePLot($data2['value']); $dplot[2] = new LinePLot($data3['value']); $dplot[3] = new LinePLot($data4['value']); $dplot[4] = new LinePLot($data5['value']); $dplot[0]->SetColor(COLOR1); $dplot[0]->SetLegend('QoS-Impact'); $dplot[0]->mark->SetType(MARK_SQUARE); $dplot[0]->mark->SetColor(COLOR1); $dplot[0]->mark->SetFillColor(COLOR1); //
<?php include "../jpgraph.php"; include "../jpgraph_line.php"; $ydata = array(12, 17, 22, 19, 5, 15); $graph = new Graph(270, 170); $graph->SetMargin(30, 90, 30, 30); $graph->SetScale("textlin"); $graph->img->SetAngle(90); $graph->img->SetCenter(floor(270 / 2), floor(170 / 2)); $line = new LinePlot($ydata); $line->SetLegend('2002'); $line->SetColor('darkred'); $line->SetWeight(2); $graph->Add($line); // Output graph $graph->Stroke(); ?>
<?php // content="text/plain; charset=utf-8" // Basic contour plot example require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_contour.php'; $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(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 ContourPlot($data, 10, 1); // 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 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; $datay = array(20, 10, 35, 5, 17, 35, 22); // Setup the graph $graph = new Graph(400, 200); $graph->SetMargin(40, 40, 20, 30); $graph->SetScale("intlin"); $graph->SetBox(); $graph->SetMarginColor('darkgreen@0.8'); // Setup a background gradient image $graph->SetBackgroundGradient('darkred', 'yellow', GRAD_HOR, BGRAD_PLOT); $graph->title->Set('Gradient filled line plot ex2'); $graph->yscale->SetAutoMin(0); // Create the line $p1 = new LinePlot($datay); $p1->SetFillGradient('white', 'darkgreen'); $p1->SetStepStyle(); $graph->Add($p1); // Output line $graph->Stroke(); ?>
} include $jploc . "jpgraph.php"; include $jploc . "jpgraph_bar.php"; $clientrawextra = get_raw("{$hostloc}clientrawextra.txt"); $y = $clientrawextra['484'] + $clientrawextra['485'] + $clientrawextra['486'] + $clientrawextra['487'] + $clientrawextra['488'] + $clientrawextra['489'] + $clientrawextra['490']; $y = $y / 10; $y = array($y); $datay = $y; if ($rain_conv != 1) { array_walk($datay, "MtoI"); } // Setup the graph. $graph = new Graph($xsize1, $ysize, "auto"); $graph->SetScale("textlin"); $graph->yscale->SetGrace(10); $graph->SetMargin($lm1, $rm1, $tm1, $bm1); $graph->SetShadow(); $graph->SetMarginColor("{$margincolour}"); //Setup Mian Title $graph->title->SetFont(FF_ARIAL, FS_BOLD, 8); $graph->title->Set("{$txt_7day}"); $graph->title->SetColor("{$textcolour}"); //Setup x axis $graph->xaxis->SetColor("{$xtextcolour}"); $graph->xaxis->HideLabels(true); $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 8); $graph->xaxis->title->Set("{$txt_rain} ({$rain_unit})"); $graph->xaxis->title->SetColor("{$xtextcolour}"); // Setup y axis $graph->yaxis->SetFont(FF_ARIAL, FS_BOLD, 8); $graph->yaxis->SetColor("{$ytextcolour}");
$graph->SetMarginColor('white'); $graph->SetFrame(false); $graph->SetBox(true); $graph->title->Set('Example of combined graph'); $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 14); $graph->xaxis->SetTickPositions($tickPositions, $minTickPositions); $graph->xaxis->SetLabelFormatString('My', true); $graph->xgrid->Show(); $p1 = new LinePlot($datay, $datax); $graph->Add($p1); //---------------------- // Setup the bar graph //---------------------- $graph2 = new 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 BarPlot($datay2, $datax); $b1->SetFillColor('teal'); $b1->SetColor('teal:1.2'); $graph2->Add($b1); //----------------------- // Create a multigraph
if ($dur < 172800) { return date('H:i', $aVal); } elseif ($dur < 604800) { return date('D', $aVal); } else { return date('j M', $aVal); } } //end TimeCallback() $graph->xaxis->SetLabelFormatCallback('TimeCallBack'); $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#FFFFFF@0.5'); $graph->xgrid->Show(true, true); $graph->xgrid->SetColor('#e0e0e0', '#efefef'); $graph->SetMarginColor('white'); $graph->SetFrame(false); $graph->SetMargin(75, 30, 30, 45); $graph->legend->SetFont(FF_FONT1, FS_NORMAL); $lineplot = new LinePlot($tot_data, $ticks); $lineplot->SetLegend('Traffic total'); $lineplot->SetColor('#d5d5d5'); $lineplot->SetFillColor('#d5d5d5@0.5'); // $lineplot2 = new LinePlot($tot_data_inv, $ticks); // $lineplot2->SetColor("#d5d5d5"); // $lineplot2->SetFillColor("#d5d5d5@0.5"); $lineplot_in = new LinePlot($in_data, $ticks); $lineplot_in->SetLegend('Traffic In'); $lineplot_in->SetColor('darkgreen'); $lineplot_in->SetFillColor('lightgreen@0.4'); $lineplot_in->SetWeight(1); $lineplot_out = new LinePlot($out_data_inv, $ticks); $lineplot_out->SetLegend('Traffic Out');
$datavalue = isset($_REQUEST['datavalue']) ? $_REQUEST['datavalue'] : "0,K,0"; //Exploding the Ticket status $datavalue = explode("K", $datavalue); $width = isset($_REQUEST['width']) ? $_REQUEST['width'] : 410; $height = isset($_REQUEST['height']) ? $_REQUEST['height'] : 270; $left = isset($_REQUEST['left']) ? $_REQUEST['left'] : 50; $right = isset($_REQUEST['right']) ? $_REQUEST['right'] : 130; $top = isset($_REQUEST['top']) ? $_REQUEST['top'] : 50; $bottom = isset($_REQUEST['bottom']) ? $_REQUEST['bottom'] : 60; $title = isset($_REQUEST['title']) ? $_REQUEST['title'] : "Horizontal graph"; $target_val = isset($_REQUEST['target_val']) ? $_REQUEST['target_val'] : ""; // Setup the graph $graph = new Graph($width, $height); $graph->SetMarginColor('white'); $graph->SetScale("textlin"); $graph->SetMargin($left, $right, $top, $bottom); $graph->tabtitle->Set($title); $graph->tabtitle->SetFont(FF_FONT2, FS_BOLD, 13); $graph->yaxis->HideZeroLabel(); $graph->xgrid->Show(); $thick = 6; // Create the lines of the Graph for ($i = 0; $i < count($datavalue); $i++) { $data = $datavalue[$i]; $graph_data = explode(",", $data); $name = $name_value[$i]; $color_val = $color_array[$i]; $temp = "p" . $i; ${$temp} = new LinePlot($graph_data); ${$temp}->SetColor($color_val); ${$temp}->SetLegend($name);
$graph->legend->SetFont(FF_FONT1, FS_BOLD); $indgraph = 0; $bplot[$indgraph] = new BarPlot(array_values($fluctuation_load)); //$bplot[$indgraph]->SetColor($table_colors[$indgraph]); $bplot[$indgraph]->SetWeight(1); $bplot[$indgraph]->SetFillColor('orange'); $bplot[$indgraph]->SetShadow('black', 1, 1); $bplot[$indgraph]->value->Show(); $bplot[$indgraph]->SetLegend("MAX LOAD = {$maxload}"); $graph->Add($bplot[$indgraph]); $indgraph++; // Output the graph $graph->Stroke(); } else { $graph = new Graph(750, 800); $graph->SetMargin(60, 40, 45, 90); //droit,gauche,haut,bas $graph->SetMarginColor('white'); //$graph->SetScale("linlin"); $graph->SetScale("textlin"); $graph->yaxis->scale->SetGrace(1, 1); // Hide the frame around the graph $graph->SetFrame(false); // Setup title $graph->title->Set("Graphic"); //$graph->title->SetFont(FF_VERDANA,FS_BOLD,14); // Note: requires jpgraph 1.12p or higher $graph->SetBackgroundGradient('#FFFFFF', '#CDDEFF:0.8', GRAD_HOR, BGRAD_PLOT); $graph->tabtitle->Set("{$fromstatsmonth_sday}-{$fromstatsday_sday} Hourly Graph - FROM {$hourinterval} to {$hourintervalplus} - NBCALLS {$nbcall} - " . "MAX LOAD = {$maxload}"); $graph->tabtitle->SetWidth(TABTITLE_WIDTHFULL); //$graph->yaxis->Hide();
// // Create Report // $report = new ReportUserAdded($SPAN, $start, $end); // // Check for error, such as license key problem // if ($report->isError()) { echo $report->getErrorMessage(); exit; } // Some data $ydata = $report->getData(); // Create the graph. These two calls are always required $graph = new Graph(640, 480, "auto"); $graph->SetMargin(50, 10, 35, 50); $graph->SetScale("textlin"); // Create the linear plot $lineplot = new LinePlot($ydata); $lineplot->SetColor("black"); $lineplot->SetFillColor("orange"); // Add the plot to the graph $graph->Add($lineplot); //$graph->SetMargin(10,10,25,10); $graph->title->Set("Users Added " . $report->getSpanName() . " (" . date('m/d/Y', $report->getStartDate()) . "-" . date('m/d/Y', $report->getEndDate()) . ")"); $graph->subtitle->Set($sys_name); //$graph->xaxis-> title->Set("Date" ); //$graph->yaxis-> title->Set("Number" ); $a = $report->getDates(); $graph->xaxis->SetTickLabels($a); $graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetLabelAngle(50); $barplot =new BarPlot($datos); $barplot->SetColor("orange"); $barplot->SetFillColor('blue'); $barplot->SetValuePos('center'); $barplot->value->Show(); $graph->Add($barplot); $graph->Stroke();*/ // Se define el array de datos $datosy = array(25, 16, 24, 5, 8, 31); // Creamos el grafico $grafico = new Graph(500, 250); $grafico->SetScale('textlin'); // Ajustamos los margenes del grafico----- (left,right,top,bottom) $grafico->SetMargin(40, 30, 30, 40); // Creamos barras de datos a partir del array de datos $bplot = new BarPlot($datosy); // Configuramos color de las barras $bplot->SetFillColor('#479CC9'); //Añadimos barra de datos al grafico $grafico->Add($bplot); // Queremos mostrar el valor numerico de la barra $bplot->value->Show(); // Configuracion de los titulos $grafico->title->Set('Mi primer grafico de barras'); $grafico->xaxis->title->Set('Titulo eje X'); $grafico->yaxis->title->Set('Titulo eje Y'); $grafico->title->SetFont(FF_FONT1, FS_BOLD); $grafico->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $grafico->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$marks[] = "MARK_FLASH"; //$datay1 = array(20,15,23,15); //$datay2 = array(12,9,42,8); //$datay3 = array(5,17,32,24); $datay1 = $jpgraph_data[1]; $datay2 = $jpgraph_data[2]; $datay3 = $jpgraph_data[3]; // Setup the graph $graph = new Graph(960, 640); $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(true); //$graph->title->Set('Filled Y-grid'); $graph->SetBox(false); $graph->SetMargin(35, 0, 0, 0); $graph->img->SetAntiAliasing(); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); //$graph->xaxis->SetTickLabels(array('A','B','C','D')); $graph->xgrid->SetColor('#E3E3E3'); $i = 0; foreach ($jpgraph_data as $key => $value) { //echo "KEY: $key <br>"; // Create the first line $p[$key] = new LinePlot($value); //$graph->Add($p[$key]); //$p[$key]->SetColor("#6495ED");
<?php // content="text/plain; charset=utf-8" // Contour plot example 04 require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_contour.php'; $data = array(array(12, 12, 10, 10, 8, 4), array(10, 10, 8, 14, 10, 3), array(7, 7, 13, 17, 12, 8), array(4, 5, 8, 12, 7, 6), array(10, 8, 7, 8, 10, 4)); // Setup a basic graph context with some generous margins to be able // to fit the legend $graph = new Graph(500, 380); $graph->SetMargin(40, 140, 60, 40); $graph->title->Set("Example of interpolated contour plot"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); $graph->title->SetMargin(10); // For contour plots it is custom to use a box style ofr the axis $graph->legend->SetPos(0.05, 0.5, 'right', 'center'); $graph->SetScale('intint'); // Setup axis and grids $graph->SetAxisStyle(AXSTYLE_BOXOUT); $graph->xgrid->SetLineStyle('dashed'); $graph->xgrid->Show(true); $graph->ygrid->SetLineStyle('dashed'); $graph->ygrid->Show(true); // A simple contour plot with 10 isobar lines and flipped Y-coordinates // Make the data smoother by interpolate the original matrice by a factor of two // which will make each grid cell half the original size $cp = new ContourPlot($data, 10, 2); $cp->UseHighContrastColor(true); // Display the legend $cp->ShowLegend(); // Make the isobar lines slightly thicker
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; $datay1 = array(20, 15, 23, 15); $datay2 = array(12, 9, 42, 8); $datay3 = array(5, 17, 32, 24); // Setup the graph $graph = new Graph(300, 200); $graph->SetMarginColor('white'); $graph->SetScale("textlin"); $graph->SetFrame(false); $graph->SetMargin(30, 50, 30, 30); $graph->title->Set('Filled Y-grid'); $graph->yaxis->HideZeroLabel(); $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5'); $graph->xgrid->Show(); $graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth()); // Create the first line $p1 = new LinePlot($datay1); $p1->SetColor("navy"); $p1->SetLegend('Line 1'); $graph->Add($p1); // Create the second line $p2 = new LinePlot($datay2); $p2->SetColor("red"); $p2->SetLegend('Line 2'); $graph->Add($p2); // Create the third line $p3 = new LinePlot($datay3);
require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; require_once 'jpgraph/jpgraph_scatter.php'; require_once 'jpgraph/jpgraph_regstat.php'; // Original data points $xdata = array(1, 3, 5, 7, 9, 12, 15, 17.1); $ydata = array(5, 1, 9, 6, 4, 3, 19, 12); // Get the interpolated values by creating // a new Spline object. $spline = new Spline($xdata, $ydata); // For the new data set we want 40 points to // get a smooth curve. list($newx, $newy) = $spline->Get(50); // Create the graph $g = new Graph(300, 200); $g->SetMargin(30, 20, 40, 30); $g->title->Set("Natural cubic splines"); $g->title->SetFont(FF_ARIAL, FS_NORMAL, 12); $g->subtitle->Set('(Control points shown in red)'); $g->subtitle->SetColor('darkred'); $g->SetMarginColor('lightblue'); //$g->img->SetAntiAliasing(); // We need a linlin scale since we provide both // x and y coordinates for the data points. $g->SetScale('linlin'); // We want 1 decimal for the X-label $g->xaxis->SetLabelFormat('%1.1f'); // We use a scatterplot to illustrate the original // contro points. $splot = new ScatterPlot($ydata, $xdata); //
// content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; require_once 'jpgraph/jpgraph_date.php'; // Create a data set in range (50,70) and X-positions DEFINE('NDATAPOINTS', 360); DEFINE('SAMPLERATE', 240); $start = time(); $end = $start + NDATAPOINTS * SAMPLERATE; $data = array(); $xdata = array(); for ($i = 0; $i < NDATAPOINTS; ++$i) { $data[$i] = rand(50, 70); $xdata[$i] = $start + $i * SAMPLERATE; } // Create the new graph $graph = new Graph(540, 300); // Slightly larger than normal margins at the bottom to have room for // the x-axis labels $graph->SetMargin(40, 40, 30, 130); // Fix the Y-scale to go between [0,100] and use date for the x-axis $graph->SetScale('datlin', 0, 100); $graph->title->Set("Example on Date scale"); // Set the angle for the labels to 90 degrees $graph->xaxis->SetLabelAngle(90); $line = new LinePlot($data, $xdata); $line->SetLegend('Year 2005'); $line->SetFillColor('lightblue@0.5'); $graph->Add($line); $graph->Stroke();
// for the correct values in the callback function $format[strval($datax[$i])][strval($datay[$i])] = array($data[$i][2], $data[$i][3]); } // Callback for markers // Must return array(width,border_color,fill_color,filename,imgscale) // If any of the returned values are '' then the // default value for that parameter will be used (possible empty) function FCallback($aYVal, $aXVal) { global $format; return array($format[strval($aXVal)][strval($aYVal)][0], '', $format[strval($aXVal)][strval($aYVal)][1], '', ''); } // Setup a basic graph $graph = new Graph(450, 300, 'auto'); $graph->SetScale("intlin"); $graph->SetMargin(40, 40, 40, 40); $graph->SetMarginColor('wheat'); $graph->title->Set("Example of ballon scatter plot with X,Y callback"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 20); $graph->title->SetMargin(10); // Use a lot of grace to get large scales since the ballon have // size and we don't want them to collide with the X-axis $graph->yaxis->scale->SetGrace(50, 10); $graph->xaxis->scale->SetGrace(50, 10); // Make sure X-axis as at the bottom of the graph and not at the default Y=0 $graph->xaxis->SetPos('min'); // Set X-scale to start at 0 $graph->xscale->SetAutoMin(0); // Create the scatter plot $sp1 = new ScatterPlot($datay, $datax); $sp1->mark->SetType(MARK_FILLEDCIRCLE);
<?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(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 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();
<?php // content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_line.php'; require_once 'jpgraph/jpgraph_scatter.php'; $datay1 = array(4, 26, 15, 44); // Setup the graph $graph = new Graph(300, 200); $graph->SetMarginColor('white'); $graph->SetScale("textlin"); $graph->SetFrame(false); $graph->SetMargin(30, 5, 25, 20); // Setup the tab $graph->tabtitle->Set(' Year 2003 '); $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 13); $graph->tabtitle->SetColor('darkred', '#E1E1FF'); // Enable X-grid as well $graph->xgrid->Show(); // Use months as X-labels $graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth()); // Create the plot $p1 = new LinePlot($datay1); $p1->SetColor("navy"); $p1->SetCSIMTargets(array('#1', '#2', '#3', '#4', '#5')); // Use an image of favourite car as $p1->mark->SetType(MARK_IMG, 'saab_95.jpg', 0.5); //$p1->mark->SetType(MARK_SQUARE); // Displayes value on top of marker image $p1->value->SetFormat('%d mil'); $p1->value->Show();
<?php // content="text/plain; charset=utf-8" require_once "jpgraph/jpgraph.php"; require_once "jpgraph/jpgraph_bar.php"; $datay = array(10, 29, 3, 6); // Create the graph. $graph = new Graph(200, 200); $graph->SetScale('textlin'); $graph->SetMargin(25, 10, 20, 25); $graph->SetBox(true); // Add 10% grace ("space") at top and botton of Y-scale. $graph->yscale->SetGrace(10); // Create a bar pot $bplot = new BarPlot($datay); $bplot->SetFillColor("lightblue"); $graph->ygrid->Show(false); // .. and add the plot to the graph $graph->Add($bplot); // Add band $band = new PlotBand(HORIZONTAL, BAND_3DPLANE, 15, 35, 'khaki4'); $band->SetDensity(10); $band->ShowFrame(true); $graph->AddBand($band); // Set title $graph->title->SetFont(FF_ARIAL, FS_BOLD, 10); $graph->title->SetColor('darkred'); $graph->title->Set('BAND_3DPLANE, Density=10'); $graph->Stroke();
$crhour = 0; } $crmin = $crmin - 60; } $x[$i] = str_pad($crhour, 2, $hr_pad, STR_PAD_LEFT) . ":" . str_pad($crmin, 2, "0", STR_PAD_LEFT); } $datax = $x; // Create the graph. These two calls are always required $graph = new Graph($xsize, $ysize, "auto", 30); $graph->SetScale("textlin"); $graph->yaxis->scale->SetGrace(10); $graph->SetMarginColor("{$margincolour}"); // Add a drop shadow $graph->SetShadow(); // Adjust the margin a bit to make more room for titles $graph->SetMargin($lm, $rm, $tm, $bm); // Create a line plot $lplot = new LinePlot($datay); $lplot->SetWeight(2); $lplot->SetColor("{$speed_col}"); $graph->Add($lplot); // titles $graph->title->SetFont(FF_ARIAL, FS_BOLD, 10); $graph->title->Set("{$txt_wind_sp} {$txt_60m} ({$speed_unit})"); $graph->title->SetColor("{$textcolour}"); //x-axis $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 8); $graph->xaxis->SetFont(FF_ARIAL, FS_BOLD, 8); $graph->xaxis->SetTitlemargin(25); $graph->xaxis->SetLabelMargin(10); $graph->xaxis->SetTickLabels($datax);