function LineGraph($w, $h, $title, $data1, $data2, $datax, $output) { // Create the graph. These two calls are always required $graph = new Graph($w, $h, "auto"); $graph->SetScale("textlin"); $graph->SetMarginColor('white'); $graph->SetFrame(true); // Adjust the margin $graph->img->SetMargin(40, 100, 20, 40); $graph->SetShadow(false); // Create the linear plot $lineplot = new LinePlot($data1); $lineplot->SetWeight(2); $lineplot->SetColor("blue"); $lineplot->mark->SetType(MARK_DIAMOND); $lineplot->mark->SetWidth(5); $lineplot->mark->SetFillColor('blue'); $lineplot->value->SetMargin(-20); $lineplot->value->show(); $lineplot->value->SetColor('blue'); $lineplot->value->SetFormat('%0.0f'); $lineplot->SetLegend($_SESSION[Tahun1]); $lineplot2 = new LinePlot($data2); $lineplot2->SetColor("green"); $lineplot2->SetWeight(2); $lineplot2->mark->SetType(MARK_FILLEDCIRCLE); $lineplot2->mark->SetWidth(3); $lineplot2->mark->SetFillColor('green'); $lineplot2->value->show(); $lineplot2->value->SetColor('darkgreen'); $lineplot2->value->SetFormat('%0.0f'); $lineplot2->SetLegend($_SESSION[Tahun2]); // Add the plot to the graph $graph->Add($lineplot); $graph->xaxis->SetTickLabels($datax); $graph->title->Set($title); $graph->xaxis->title->Set(""); $graph->yaxis->title->Set(""); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->Add($lineplot2); $graph->legend->SetShadow(false); $graph->legend->SetFillColor('white'); $graph->legend->SetPos(0.01, 0.88, 'right', 'center'); // Display the graph $graph->Stroke($output); }
public function renderGraph() { require_once 'libs/jpgraph/jpgraph.php'; require_once 'libs/jpgraph/jpgraph_bar.php'; $graph = new Graph($this->_controllerAction->getRequest()->getParam('type') == 'month' ? 400 : 300, 200, 'auto'); $graph->SetMarginColor('white'); $graph->SetFrame(false); $graph->SetScale("textlin"); $graph->img->SetMargin(0, 30, 20, 40); $graph->yaxis->scale->SetGrace(20); $graph->yaxis->HideLabels(); $graph->yaxis->HideTicks(); $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5'); $labelsy = array(); $datay = array(); switch ($this->_controllerAction->getRequest()->getParam('type')) { case 'month': $this->_populateMonthData($labelsy, $datay); break; case 'year': $this->_populateYearData($labelsy, $datay); break; default: $this->_populateWeekData($labelsy, $datay); } $graph->xaxis->SetTickLabels($labelsy); $bplot = new BarPlot($datay); $bplot->SetFillGradient("navy", "lightsteelblue", GRAD_WIDE_MIDVER); $bplot->value->Show(); $bplot->value->SetFormat('%d'); $graph->Add($bplot); $graph->Stroke(); }
public function executeGetFunctionGraph(sfWebRequest $request) { $this->getUrlParameters($request); $this->fct_id = $request->getParameter('function_id'); $this->fct_ref = $request->getParameter('function_ref'); //récupération du nom pour les affichages. $this->node = Doctrine_Core::getTable('EiTree')->findOneByRefObjAndObjIdAndType($this->fct_ref, $this->fct_id, 'Function'); //récupération des temps d'execution $this->times = Doctrine_Core::getTable('EiFonction')->getTimeStats($this->project_id, $this->project_ref, $this->fct_id, $this->fct_ref); // Width and height of the graph $width = 700; $height = 300; // Create a graph instance $graph = new Graph($width, $height); $graph->SetScale('intint'); $graph->title->Set($this->node->getName() . " 's execution time evolution."); $graph->xaxis->title->Set('Execution'); $graph->yaxis->title->Set('Time (ms)'); $exec = array(); //récupération des durées uniquement foreach ($this->times as $t => $time) { $exec[] = $time['l_duree']; } $lineplot = new LinePlot($exec); $graph->Add($lineplot); $graph->Stroke(); return sfView::NONE; }
function monthchart($xdata, $ydata, $title = 'Line Chart') { // Create the graph. These two calls are always required $graph = new Graph(600, 250, "auto", 60); $graph->img->SetAntiAliasing(false); $graph->SetScale("textlin"); $graph->xaxis->SetTickLabels($xdata); $graph->xgrid->SetColor('#E3E3E3'); $graph->legend->SetFrameWeight(1); // Setup title $graph->title->Set($title); foreach ($ydata as $item) { // Create the linear plot if (count($item['values']) != count($xdata)) { continue; } $lineplot = new LinePlot($item['values'], $xdata); $lineplot->SetColor($item['color']); if (count($ydata) == 1) { $lineplot->SetFillColor($item['color']); } // Add the plot to the graph $graph->Add($lineplot); $lineplot->SetLegend($item['legend']); } return $graph; }
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); }
public function graficofecha($gestion) { if (Conectar::con()) { //$gestion='2013'; $objetoanalisis = new classAnalisis(); $anio = $gestion; for ($i = 0; $i < 12; $i++) { $dat[] = $objetoanalisis->ventamensual($anio, $i); } $datos = $dat; //$datos =array('1','4','3','3','5'); $grafico = new Graph(400, 300, "auto"); $grafico->SetScale("textlin"); $grafico->title->Set("Resumen de ventas por gestion"); $grafico->xaxis->title->Set(""); $grafico->yaxis->title->Set(""); // Un gradiente Horizontal de rojo a azul // 25 pixeles de ancho para cada barra $lineplot = new LinePlot($datos); $lineplot->SetColor("green"); $lineplot->SetWeight(2); $grafico->Add($lineplot); return $grafico->Stroke(); } }
function showimg($value, $clock, $key) { $datay1 = $value; $graph = new Graph(1000, 400); $graph->SetScale("textlin"); //设置图片外边距(左,右,上,下) $graph->img->SetMargin(100, 20, 20, 60); $graph->title->Set($key); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); //x轴文字 $graph->xaxis->SetTickLabels($clock); $graph->xaxis->SetLabelAngle(90); //x轴颜色 $graph->xgrid->SetColor('#E3E3E3'); // Create the first line $p1 = new LinePlot($datay1); $graph->Add($p1); $p1->SetColor("#6495ED"); $graph->legend->SetFrameWeight(1); // Output line $graph->Stroke(); }
static function graphs($name, $close) { // Setup the graph $graph = new Graph(1000, 653, 'auto'); $graph->SetScale("textlin"); $theme_class = new UniversalTheme(); $graph->SetTheme($theme_class); $graph->img->SetAntiAliasing(false); $graph->title->SetFont(FF_FONT2, FS_BOLD, 20); $graph->title->Set("Stock Performance History for " . $name); $graph->SetBox(false); $graph->yaxis->HideZeroLabel(); $graph->yaxis->HideLine(false); $graph->yaxis->HideTicks(false, false); $graph->yaxis->title->SetFont(FF_FONT2, FS_BOLD, 20); $graph->yaxis->title->Set('Close Price'); $graph->xgrid->Show(); $graph->xgrid->SetLineStyle("solid"); $graph->xaxis->SetTickPositions(array(0, 20, 40, 61, 82, 103, 124, 143)); $graph->xaxis->SetTickLabels(array('Nov 2014', 'Dec 2014', 'Jan 2015', 'Feb 2015', 'March 2015', 'April 2015', 'May 2015', 'June 2015')); $graph->xaxis->title->SetFont(FF_FONT2, FS_BOLD, 20); $graph->xaxis->title->Set('Dates'); $graph->xgrid->SetColor('#E3E3E3'); // Create the first line $p1 = new LinePlot($close); $graph->Add($p1); $p1->SetColor("#6495ED"); $graph->legend->SetFrameWeight(2); // Output line $graph->Stroke(); }
function plot($pid) { $this->_setValues($pid); $graph = new Graph(600, 400); $graph->img->SetMargin(60, 95, 40, 40); $graph->SetShadow(); $graph->SetScale("textlog"); $colors = array("hotpink", "green", "blue", "gold", "blueviolet", "deepskyblue", "brown", "cadetblue", "darksalmon", "cornflowerblue", "darkslateblue", "limegreen", "yellow", "navy", "slategray"); srand(1); for ($i = 0; $i < sizeof($this->_data); $i++) { $bplot[$i] = new BarPlot($this->_data[$i]); if ($i < sizeof($colors)) { $color = $colors[$i]; } else { $r = rand(0, 255); $g = rand(0, 255); $b = rand(0, 255); $color = array($r, $g, $b); } $bplot[$i]->SetFillColor($color); $bplot[$i]->SetLegend($this->_legend[$i]); } $gbplot = new GroupBarPlot($bplot); $graph->Add($gbplot); $graph->title->Set("# of Visited Articles per Month (log scale)"); $graph->title->SetFont(FONT2_BOLD); $graph->xaxis->SetTickLabels($this->_months); $graph->ygrid->Show(true, true); $graph->xaxis->SetFont(FONT1_BOLD); $graph->yaxis->SetFont(FONT1_BOLD); $graph->Stroke(); }
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 build() { $path = APPPATH; require_once $path . 'libraries/jpgraph/src/jpgraph.php'; require_once $path . 'libraries/jpgraph/src/jpgraph_bar.php'; // $datay = array(62, 105, 85, 50); $datay = $this->parameters; // Create the graph. These two calls are always required // $graph = new Graph(350, 220, 'auto'); $graph = new 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 BarPlot($datay); $b1plot = new 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 $d['grafica'] = $graph->Stroke("jacobo.png"); $d['path'] = $path; return $d; }
function graficarBarras() { require_once "jpgraph/src/jpgraph.php"; require_once "jpgraph/src/jpgraph_bar.php"; $datos = array($_GET['pos'], $_GET['neg']); //Instancia del objeto del tipo Graph en donde como parametro // se le pasan los valore de ancho y altura $grafica = new Graph(400, 300); $grafica->SetScale("textlin"); $grafica->SetBox(false); //Nombre de las columnas $columnas = array($_GET['lab1'], $_GET['lab2']); $grafica->xaxis->SetTickLabels($columnas); //Objeto del tipo BarPlot que se le enviara a la grafica y el cual //recibe como parametros los datos a graficar $barras = new BarPlot($datos); $grafica->Add($barras); //Color de los bordes //Color de borde de las barras $barras->SetColor("white"); //Color de relleno de las barras $barras->SetFillColor("#4B0082"); //Ancho de las barras $barras->SetWidth(45); // $grafica->title->Set("Gráfica de Barras"); $grafica->title->SetFont(FF_TIMES, FS_ITALIC, 18); $grafica->Stroke(); }
/** * 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); }
function plot($pid) { $this->_setValues($pid); $graph = new Graph(600, 400); $graph->img->SetMargin(60, 95, 40, 40); $graph->SetShadow(); $graph->SetScale("textlog"); $colors = array("yellow", "green", "blue", "red"); srand(1); for ($i = 0; $i < sizeof($this->_data); $i++) { $bplot[$i] = new BarPlot($this->_data[$i]); $color = $colors[$i]; $bplot[$i]->SetFillColor($color); $bplot[$i]->SetLegend($this->_legend[$i]); } $gbplot = new GroupBarPlot($bplot); $graph->Add($gbplot); $graph->title->Set("# of Visited Articles per Language (log scale)"); $graph->title->SetFont(FONT2_BOLD); $graph->xaxis->SetTickLabels($this->_years); $graph->ygrid->Show(true, true); $graph->xaxis->SetFont(FONT1_BOLD); $graph->yaxis->SetFont(FONT1_BOLD); $graph->Stroke(); }
public function index() { // We want a bar graph, so use JpGraph's bar chart library require_once APPPATH . '/libraries/JpGraph/jpgraph_bar.php'; // Example data (04/2015) $json = '[{"Hogwarts Academy":{"Yield":"19021 kWh","Yield specific":"127.01 kWh\\/kWp","Target yield":"16069.23 kWh","Current-target yield %":"<span style=\\"color: #3ab121\\">118.37 %<span>"}},{"cols": [{"id":"","label":"Time","pattern":"","type":"string"},{"id":"","label":"Hogwarts Academy (AC)","pattern":"","type":"number"},{"id":"","label":"Target values","pattern":"","type":"number"}], "rows": [{"c":[{"v":"01/04","f":null}, {"v":615.8,"f":"615,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"02/04","f":null}, {"v":712.5,"f":"712,50 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"03/04","f":null}, {"v":171,"f":"171,00 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"04/04","f":null}, {"v":382.3,"f":"382,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"05/04","f":null}, {"v":606.3,"f":"606,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"06/04","f":null}, {"v":774.5,"f":"774,50 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"07/04","f":null}, {"v":570.6,"f":"570,60 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"08/04","f":null}, {"v":726.8,"f":"726,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"09/04","f":null}, {"v":789.2,"f":"789,20 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"10/04","f":null}, {"v":592.9,"f":"592,90 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"11/04","f":null}, {"v":677.1,"f":"677,10 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"12/04","f":null}, {"v":244.5,"f":"244,50 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"13/04","f":null}, {"v":457.4,"f":"457,40 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"14/04","f":null}, {"v":340.8,"f":"340,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"15/04","f":null}, {"v":425.3,"f":"425,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"16/04","f":null}, {"v":828.8,"f":"828,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"17/04","f":null}, {"v":616.8,"f":"616,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"18/04","f":null}, {"v":660.3,"f":"660,30 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"19/04","f":null}, {"v":453.2,"f":"453,20 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"20/04","f":null}, {"v":691.9,"f":"691,90 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"21/04","f":null}, {"v":904.4,"f":"904,40 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"22/04","f":null}, {"v":879.1,"f":"879,10 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"23/04","f":null}, {"v":824.8,"f":"824,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"24/04","f":null}, {"v":777.9,"f":"777,90 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"25/04","f":null}, {"v":413.8,"f":"413,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"26/04","f":null}, {"v":834.8,"f":"834,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"27/04","f":null}, {"v":920.8,"f":"920,80 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"28/04","f":null}, {"v":751,"f":"751,00 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"29/04","f":null}, {"v":737.7,"f":"737,70 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]},{"c":[{"v":"30/04","f":null}, {"v":638.7,"f":"638,70 kWh"}, {"v":535.640966432,"f":"535,64 kWh"}]}]}]'; // Turn string into object $obj = json_decode($json); // Stores for graph data $xdata = array(); $ydata = array(); // Get coords data from object $obj_data = $obj[1]->rows; $counter = 1; // Add it to each of our storage arrays foreach ($obj_data as $data) { // only plot when there is a kW value if (isset($data->c[1]->v)) { $xdata[] = $data->c[0]->v; // date $ydata[] = $data->c[1]->v; // kw } } // Create the graph. // One minute timeout for the cached image // INLINE_NO means don't stream it back to the browser. $graph = new Graph(600, 350, 'auto'); $graph->SetScale("textlin"); $graph->img->SetMargin(60, 30, 20, 40); $graph->yaxis->SetTitleMargin(45); $graph->yaxis->scale->SetGrace(30); $graph->SetShadow(); // Turn the tickmarks $graph->xaxis->SetTickSide(SIDE_DOWN); $graph->yaxis->SetTickSide(SIDE_LEFT); // Create a bar pot $bplot = new BarPlot($ydata); $bplot->SetFillColor("orange"); // Use a shadow on the bar graphs (just use the default settings) $bplot->SetShadow(); $bplot->value->SetFormat(" %2.1f kW", 70); $bplot->value->SetFont(FF_VERDANA, FS_NORMAL, 8); $bplot->value->SetColor("blue"); $bplot->value->Show(); $graph->Add($bplot); $graph->title->Set("Hogwarts Academy"); $graph->xaxis->title->Set("Day"); $graph->yaxis->title->Set("Yield in kilowatt hours"); $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(); }
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(); }
function draw_graph($datay, $data2y, $label_x) { include_once "src/jpgraph.php"; include_once "src/jpgraph_line.php"; // A nice graph with anti-aliasing $graph = new Graph(800, 600, "auto"); $graph->img->SetMargin(40, 180, 40, 40); $graph->img->SetAntiAliasing("white"); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->title->Set("Nodes and Comment Count By Duration"); $graph->xaxis->SetTickLabels($label_x); // 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 if ($datay) { $p1 = new LinePlot($datay); $p1->mark->SetType(MARK_FILLEDCIRCLE); $p1->mark->SetFillColor("blue"); $p1->mark->SetWidth(4); $p1->SetColor("blue"); $p1->SetCenter(); $p1->SetLegend("Nodes Count"); $graph->Add($p1); } // ... and the second if ($data2y) { $p2 = new LinePlot($data2y); $p2->mark->SetType(MARK_STAR); $p2->mark->SetFillColor("red"); $p2->mark->SetWidth(4); $p2->SetColor("red"); $p2->SetCenter(); $p2->SetLegend("Comments Count"); $graph->Add($p2); } // Output line $graph->Stroke(); }
public function renderGraph() { require_once 'libs/jpgraph/jpgraph.php'; require_once 'libs/jpgraph/jpgraph_bar.php'; require_once 'libs/jpgraph/jpgraph_line.php'; $graph = new Graph(300, 200, 'auto'); $graph->SetMarginColor('white'); $graph->SetFrame(false); $graph->SetScale("textlin"); $graph->SetY2Scale("lin"); $graph->img->SetMargin(0, 30, 20, 65); $graph->yaxis->HideLabels(); $graph->yaxis->HideTicks(); $graph->yaxis->scale->SetGrace(20); $graph->y2axis->SetColor("black", "red"); $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5'); $labelsy = array(); $datay = array(); $datay2 = array(); switch ($this->_controllerAction->getRequest()->getParam('type')) { case 'year': $this->_populateYearData($labelsy, $datay, $datay2); break; default: $this->_populateWeekData($labelsy, $datay, $datay2); } $graph->xaxis->SetTickLabels($labelsy); $locale = Zend_Registry::get('Zend_Locale'); if ($locale == 'ja') { // the ttf file for FF_MINCHO is already encoded in utf-8 $legend1 = $this->view->translate('Trusted sites'); $legend2 = $this->view->translate('Sites per user'); } else { // default ttf files are latin-1 encoded $legend1 = utf8_decode($this->view->translate('Trusted sites')); $legend2 = utf8_decode($this->view->translate('Sites per user')); } $bplot = new BarPlot($datay); $bplot->setLegend($legend1); $bplot->SetFillGradient("navy", "lightsteelblue", GRAD_WIDE_MIDVER); $bplot->value->Show(); $bplot->value->SetFormat('%d'); $p1 = new LinePlot($datay2); $p1->SetColor("red"); $p1->SetLegend($legend2); $graph->Add($bplot); $graph->AddY2($p1); $graph->legend->SetLayout(LEGEND_HOR); if ($locale == 'ja') { $graph->legend->setFont(FF_MINCHO, FS_NORMAL); } $graph->legend->Pos(0.5, 0.99, "center", "bottom"); $graph->Stroke(); }
function makeGraph($x_data, $y_data, $num_results, $title = "Statistics", $graph_type = "bar", $graph_scale = "textint") { // default graph info $width = 600; $height = 500; $top = 60; $bottom = 30; $left = 80; $right = 30; if ($graph_type != 'csv' && $num_results == 0) { header('Content-type: image/png'); readfile($GLOBALS['BASE_DIR'] . '/images/no-calls.png'); exit; } // Set the basic parameters of the graph switch ($graph_type) { case "line": //do line graph here break; // not really a graph, returns comma seperated values // not really a graph, returns comma seperated values case "csv": header("content-type: text/csv"); header('Content-Disposition: attachment; filename="statistics.csv"'); $columns = implode(',', $x_data); $rows = implode(',', $y_data); echo $columns . "\n" . $rows; break; case "bar": default: // bar is default $graph = new Graph($width, 90 + 10 * $num_results, 'auto'); $graph->SetScale($graph_scale); // Nice shadow $graph->SetShadow(); $graph->Set90AndMargin($left, $right, $top, $bottom); // Setup labels $graph->xaxis->SetTickLabels($x_data); // Label align for X-axis $graph->xaxis->SetLabelAlign('right', 'center', 'right'); // Label align for Y-axis $graph->yaxis->SetLabelAlign('center', 'bottom'); // Create a bar pot $bplot = new BarPlot($y_data); $bplot->SetFillColor("#708090"); $bplot->SetWidth(0.5); $bplot->SetYMin(0); //$bplot->SetYMin(1990); $graph->title->Set($title); $graph->Add($bplot); $graph->Stroke(); } }
/** * */ public function summary($id) { $iterationAux; //try { $project = Project::findOrFail($id); $iterations = Iterations::where('projectid', '=', $id)->get(); //foreach($iterations as $var){ // $iterationAux = $iterationAux . var_dump($var); //} //}catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) { //} //die; JpGraph\JpGraph::load(); JpGraph\JpGraph::module('bar'); JpGraph\JpGraph::module('line'); $datay = array(20, 30, 50, 80); $datay2 = array(30, 95, 70, 40); $datazero = array(0, 0, 0, 0); // Create the graph. $graph = new Graph(800, 500); $graph->title->Set('Example with 2 scale bars : ' . $project->name . ' : ' . $id . ' : ' . sizeof($iterations)); // 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 BarPlot($datazero); // Create the "Y" axis group $ybplot1 = new BarPlot($datay); $ybplot1->value->Show(); $ybplot = new GroupBarPlot(array($ybplot1, $bplotzero)); // Create the "Y2" axis group $ybplot2 = new BarPlot($datay2); $ybplot2->value->Show(); $ybplot2->value->SetColor('darkred'); $ybplot2->SetFillColor('darkred'); $y2bplot = new GroupBarPlot(array($bplotzero, $ybplot2)); // Add the grouped bar plots to the graph $graph->Add($ybplot); $graph->AddY2($y2bplot); $datax = array('A', 'B', 'C', 'D'); $graph->xaxis->SetTickLabels($datax); // .. and finally stroke the image back to browser $graph->Stroke(); }
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 linechart($ydata, $title = 'Line Chart') { require_once APPPATH . 'third_party/jpgraph-3.5.0b1/src/jpgraph.php'; require_once APPPATH . 'third_party/jpgraph-3.5.0b1/src/jpgraph_line.php'; // Create the graph. These two calls are always required $graph = new Graph(350, 250, "auto", 60); $graph->SetScale("textlin"); // Setup title $graph->title->Set($title); // Create the linear plot $lineplot = new LinePlot($ydata); $lineplot->SetColor("blue"); // Add the plot to the graph $graph->Add($lineplot); return $graph; // does PHP5 return a reference automatically? }
function draw_graph($xarr, $arr) { require_once "jpgraph/jpgraph.php"; require_once "jpgraph/jpgraph_line.php"; require_once "jpgraph/jpgraph_bar.php"; require_once "jpgraph/jpgraph_log.php"; // Create the graph. These two calls are always required $graph = new Graph(350, 250, "auto"); //$graph->SetScale("lin"); //$graph->SetScale("textlin"); $graph->SetScale("loglin"); // Create the linear plot $lineplot = new BarPlot($arr, $xarr); $lineplot->SetColor("blue"); // Add the plot to the graph $graph->Add($lineplot); // Display the graph $graph->Stroke(); }
function plot() { $this->_setValues(); $graph = new Graph(380, 250); $graph->img->SetMargin(50, 30, 40, 40); $graph->SetShadow(); $graph->SetColor("lightyellow"); $graph->SetScale("textlin"); $graph->title->Set($this->_graphTitle); $graph->yaxis->SetColor("blue"); $graph->xaxis->SetColor("blue"); $graph->title->SetFont(FONT1_BOLD); $graph->xaxis->SetTickLabels($this->_xaxisValues); $lineplot = new LinePlot($this->_yaxisValues); $lineplot->SetColor("red"); // Add the plot to the graph $graph->Add($lineplot); // Display the graph $graph->Stroke(); }
function grafico_barra() { $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(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 BarPlot($data1y); $b2plot = new BarPlot($data2y); $b3plot = new BarPlot($data3y); // Create the grouped bar plot $gbplot = new 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_temp_directory = 'temp'; // in the webroot (add directory to .htaccess exclude) $graph_file_name = 'test.png'; $graph_file_location = $graph_temp_directory . '/' . $graph_file_name; $graph->Stroke($graph_file_location); // create the graph and write to file $data['graph'] = $graph_file_location; $this->load->view('supervisor/prueba', $data); }
public function executeBarGraph() { //Set the response header to a image JPEG datastream $this->getResponse()->setContent('image/jpeg'); // Change this defines to where Your fonts are stored DEFINE("TTF_DIR", "/usr/share/fonts/truetype/freefont/"); // Change this define to a font file that You know that You have DEFINE("TTF_SANS", "FreeSans.ttf"); $util = new util(); $dataDVDrip = $util->getTotalFormat('DVDrip', 'movies'); $dataHDrip = $util->getTotalFormat('HDrip', 'movies'); $data720p = $util->getTotalFormat('720p', 'movies'); $data1080p = $util->getTotalFormat('1080p', 'movies'); $datay = array($dataDVDrip, $dataHDrip, $data720p, $data1080p); $graph = new Graph(199, 145); $graph->SetScale('textlin'); $graph->SetColor('black'); $graph->SetMarginColor('#393939'); $graph->SetFrame(true, '#393939'); $top = 25; $bottom = 20; $left = 50; $right = 20; $graph->Set90AndMargin($left, $right, $top, $bottom); // Setup labels $lbl = array("DVDrip", "HDrip", "720p", "1080p"); $graph->xaxis->SetTickLabels($lbl); $graph->xaxis->SetColor('white'); $graph->xaxis->SetLabelAlign('right', 'center', 'right'); $graph->yaxis->SetLabelAlign('center', 'bottom'); $graph->yaxis->SetColor('white'); // Create a bar pot $bplot = new BarPlot($datay); $bplot->SetWidth(0.5); $bplot->SetFillGradient(array(250, 2, 2), array(109, 2, 2), GRAD_VERT); $graph->Add($bplot); $graph->Stroke(); return sfView::NONE; }
public function drawGraph() { // generate graphic $graph = new Graph($this->width, $this->height, "auto"); $graph->SetScale("textlin"); $graph->img->SetMargin(0, 0, 1, 0); //$graph->SetFrame(true); // generate bars $bplot = new BarPlot($this->data); $graph->Add($bplot); // format bars $bplot->SetFillColor('gray'); //show background image if file exists if (false === empty($this->bgImg) && file_exists($this->bgImg)) { $graph->SetBackgroundImage($this->bgImg, BGIMG_FILLFRAME); } $bplot->SetFillGradient("gray", "darkgray", GRAD_HOR); $graph->yaxis->HideTicks(true, true); $graph->xaxis->HideLabels(true); // show graphic $graph->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; }
function generate_image() { global $percent, $legend; // Create the graph. These two calls are always required $graph = new Graph(550, 250); $graph->SetScale("textlin"); $graph->yaxis->scale->SetGrace(20); $graph->xaxis->SetLabelmargin(5); $graph->xaxis->SetTickLabels($legend); $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5'); // Add a drop shadow $graph->SetShadow(); // Adjust the margin a bit to make more room for titles $graph->img->SetMargin(50, 30, 20, 40); // Create a bar pot $bplot = new BarPlot($percent); // Adjust fill color $bplot->SetFillColor('#9999CC'); $bplot->SetShadow(); $bplot->value->Show(); $bplot->value->SetFont(FF_ARIAL, FS_BOLD, 10); $bplot->value->SetAngle(45); $bplot->value->SetFormat('%0.0f'); // Width $bplot->SetWidth(0.6); $graph->Add($bplot); // Setup the titles $graph->title->Set("PHP documentation"); $graph->xaxis->title->Set("Language"); $graph->yaxis->title->Set("Files up to date (%)"); $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('../www/images/revcheck/info_revcheck_php_all_lang.png'); }