Beispiel #1
0
 public function grafico_2_bd()
 {
     require_once APPPATH . '/libraries/JpGraph/jpgraph_bar.php';
     $data1y = $this->id_asignacionprueba;
     $data2y = $this->curso_id_curso;
     $graph = new Graph(700, 360, "auto");
     $graph->SetScale("textlin");
     $graph->img->SetMargin(30, 30, 20, 65);
     $graph->ygrid->SetFill(true, '#fff', '#DDDDDD@0.5');
     $graph->SetMarginColor("#fff");
     $graph->SetFrame(true, '#fff', 1);
     $graph->SetBox(false);
     //$columnas_2 = array('Ext. Info Explicita','Ext. Info Implicita','Ref. Contenido Texto','Ref. Sobre Texto');
     //$graph->xaxis->SetTickLabels($columnas_2);
     $b1plot = new BarPlot($data1y);
     $b1plot->SetWeight(0);
     $b1plot->SetFillColor("#61A9F3");
     $b1plot->SetLegend("id asignacion");
     $b1plot->SetValuePos('center');
     $b2plot = new BarPlot($data2y);
     $b2plot->SetWeight(0);
     $b2plot->SetFillColor("#F381B9");
     $b2plot->SetLegend("id curso");
     $b2plot->SetValuePos('center');
     $gbplot = new AccBarPlot(array($b1plot, $b2plot));
     $graph->Add($gbplot);
     $b1plot->value->Show();
     $b2plot->value->Show();
     $b1plot->value->SetFormat('%d');
     $b2plot->value->SetFormat('%d');
     $graph->title->Set("Grafico 2 - de barras compuestas");
     $graph->legend->SetPos(0.5, 0.99, 'center', 'bottom');
     $graph->legend->SetFrameWeight(1);
     $graph->Stroke(_IMG_HANDLER);
     global $fileName_bd_2;
     $this->fileName_bd_2 = "assets/images/grafica_muestra_bd_2.jpg";
     $graph->img->Stream($this->fileName_bd_2);
     /*
     $graph->img->Headers();
     $graph->img->Stream();
     */
 }
Beispiel #2
0
<?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();
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->y2axis->SetTickSide(SIDE_RIGHT);
$graph->y2axis->SetColor('black', 'blue');
$graph->y2axis->SetLabelFormat('%3d.0%%');
// Create a bar pot
$bplot = new BarPlot($data_freq);
// Create targets and alt texts for the image maps. One for each bar
// (In this example this is just "dummy" targets)
$targ = array("#1", "#2", "#3", "#4", "#5", "#6", "#7");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$bplot->SetCSIMTargets($targ, $alts);
// Create accumulative graph
$lplot = new LinePlot($data_accfreq);
// We want the line plot data point in the middle of the bars
$lplot->SetBarCenter();
// Use transperancy
$lplot->SetFillColor('lightblue@0.6');
$lplot->SetColor('blue@0.6');
//$lplot->SetColor('blue');
$graph->AddY2($lplot);
// Setup the bars
$bplot->SetFillColor("orange@0.2");
$bplot->SetValuePos('center');
$bplot->value->SetFormat("%d");
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 9);
$bplot->value->Show();
// Add it to the graph
$graph->Add($bplot);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();
Beispiel #4
0
$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 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();
}
$datax[] = $_REQUEST["actual"];
$datay[] = "Prima Actual";
$datax[] = $_REQUEST["provart"];
$datay[] = "Prima Provincia ART";
$graph = new Graph(400, 256, "auto");
$graph->SetScale("textlin", $min, $max);
$graph->SetShadow();
$graph->img->SetMargin(40, 30, 20, 40);
$graph->xaxis->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->xaxis->SetLabelAlign("center", "bottom");
$graph->xaxis->SetLabelAngle(0);
$graph->xaxis->SetLabelMargin(16);
$graph->xaxis->SetTickLabels($datay);
$graph->yaxis->SetLabelMargin(1);
if ($leyenda) {
    $txt = new Text(" (En miles)");
    $txt->SetColor("red");
    $graph->AddText($txt);
}
$bplot = new BarPlot($datax);
//$bplot->SetColor("gray");
//$bplot->SetFillColor("orange");
$bplot->SetFillGradient("#00a4e4", "#00a4e4", GRAD_VER);
$bplot->SetShadow("black", 8, 4);
$bplot->SetValuePos("bottom");
$bplot->SetWidth(0.3);
$graph->Add($bplot);
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->Stroke(GRAFICO_CARTA_COTIZACION . $_REQUEST["archivo"]);
//$graph->Stroke();
//print_r2($xAxis);
//print_r2($yAxis);
$graph = new Graph(1200, 280);
$graph->img->SetMargin(40, 40, 40, 40);
$graph->img->SetAntiAliasing();
$graph->SetScale('textlin');
$graph->SetShadow();
// Title
$graph->title->Set('Letzte Sensorwerte ' . $locationName);
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->subtitle->Set($lastTime->format('d.m.y H:i:s'));
// X-Axis
$graph->xaxis->SetTickLabels($xAxis);
$graph->xaxis->SetTitle('Sensor', 'middle');
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
// Y-Axis
$graph->yaxis->SetTitle($unit, 'middle');
$graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 10);
// Use 20% "grace" to get slightly larger scale then min/max of
// data
$graph->yscale->SetGrace(0);
$bar = new BarPlot($yAxis);
$bar->SetValuePos('top');
$bar->value->SetFont(FF_ARIAL);
$bar->value->SetColor('black');
$bar->value->SetFormat('%.1f °C');
// print_r2($bar);
$graph->Add($bar);
$bar->value->Show();
$graph->Stroke();
Beispiel #7
0
 private function createStackedBarGraph($xdata, $data1, $data2, $ytitle)
 {
     // Create the graph.
     $graph = new Graph($this->width, $this->height, "auto");
     $graph->SetScale("textlin");
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->SetFrame(false);
     if ($this->shadow) {
         $graph->SetShadow();
     }
     // Create the bar plots
     $b1plot = new BarPlot($data1);
     $b1plot->SetFillColor("khaki");
     $b1plot->value->Show();
     $b1plot->value->SetFormat('%d');
     $b1plot->value->SetColor("black");
     $b1plot->SetValuePos('center');
     $b1plot->SetLegend($this->legend[0]);
     $b2plot = new BarPlot($data2);
     $b2plot->SetFillColor("orange");
     $b2plot->value->Show();
     $b2plot->value->SetFormat('%d');
     $b2plot->value->SetColor("black");
     $b2plot->SetValuePos('center');
     $b2plot->SetLegend($this->legend[1]);
     // Create the stacked bar plot...
     $gbplot = new AccBarPlot(array($b1plot, $b2plot));
     // ... and add it to the graph
     $graph->Add($gbplot);
     $graph->xaxis->title->Set($this->title);
     $graph->xaxis->SetTickLabels($xdata);
     $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->yaxis->title->Set($ytitle);
     $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->yaxis->SetLabelMargin(5);
     $graph->yaxis->scale->SetGrace(10);
     $graph->yaxis->HideZeroLabel();
     $graph->ygrid->SetFill(true, '#f2f2f2@0.5', '#cacaca@0.5');
     return $graph;
 }
Beispiel #8
0
 private static function mbars($datasets, $labels, $lengends, $title, $xlabel, $ylabel, $opts = array())
 {
     /*
         Types:
             datasets: array('KEY1' => array(1,2,3,4),   'KEY2' => array(1,2,3,4),   ...)
             lengends: array('KEY1' => 'color1',         'KEY2' => 'color2',         ...)
             labels:   array('Jan', '02', 'whatever', ...)
             opts:     array('xdim' => int, 'ydim' => int, 'retObj' => bool, 'scale' => 'scale string')
     */
     // Options
     $retObj = array_key_exists('retObj', $opts) && $opts['retObj'];
     $dim['x'] = array_key_exists('xdim', $opts) ? $opts['xdim'] : 800;
     $dim['y'] = array_key_exists('ydim', $opts) ? $opts['ydim'] : 600;
     $scale = array_key_exists('scale', $opts) ? $opts['scale'] : "textint";
     $format = preg_match('/lin/', $scale) ? '%.1f' : '%d';
     // Ready graph object.
     $graph = new Graph($dim['x'], $dim['y'], "auto");
     $graph->SetScale($scale);
     $graph->SetShadow();
     $graph->img->SetMargin(40, 30, 20, 40);
     $graph->xaxis->SetTickLabels($labels);
     // Create the bar plots
     $bplots = array();
     foreach ($lengends as $key => $color) {
         $bplot = new BarPlot($datasets[$key]);
         $bplot->SetFillColor($color);
         $bplot->value->Show();
         $bplot->value->SetFormat($format);
         $bplot->value->SetFont(FF_FONT1, FS_BOLD);
         $bplot->value->SetColor('white');
         $bplot->SetValuePos('center');
         $bplot->SetLegend($key);
         $bplots[] = $bplot;
     }
     // Create the grouped bar plot
     $plot = new GroupBarPlot($bplots);
     $graph->Add($plot);
     $graph->title->Set($title);
     $graph->xaxis->title->Set($xlabel);
     $graph->yaxis->title->Set($ylabel);
     return $retObj ? $graph : $graph->Stroke();
 }
 private function barHPlot($question, $datax, $datay, $width, $height)
 {
     include_once BASE . "jpgraph.php";
     include_once BASE . "jpgraph_bar.php";
     $tFontSize = 11;
     $xFontSize = 6 + $height / $this->amountOfVariants / 30;
     $maxX = 0;
     foreach ($datax as $x) {
         if (($t = strlen($x)) > $maxX) {
             $maxX = $t;
         }
     }
     for ($i = 0; $i < $this->amountOfVariants; $i++) {
         $x =& $datax[$i];
         if (($t = strlen($x)) >= MAXCHARSPERLINE) {
             $index = strrpos(substr($x, 0, MAXCHARSPERLINE - 1), ' ');
             if ($index === false) {
                 $index = MAXCHARSPERLINE - 3;
             }
             $x[$index] = "\n";
             if ($t > $index + MAXCHARSPERLINE) {
                 $x = substr($x, 0, $index + MAXCHARSPERLINE - 3) . "...";
             }
         }
     }
     unset($x);
     // Set the basic parame graph
     $graph = new Graph($width, $height, 'auto');
     $graph->SetScale("textlin", 0, 100);
     //if (amountOfVariants>5) $xFontSize--;
     $lm = 0;
     foreach ($datax as $x) {
         $linia = strtok($x, "\n");
         while ($linia != '') {
             $t = new Text($linia);
             $t->SetFont(FF_COMIC, FS_NORMAL, $xFontSize);
             $lineWidth = $t->GetWidth($graph->img);
             if ($lineWidth > $lm) {
                 $lm = $lineWidth;
             }
             //echo $linia.$lineWidth."<BR>";
             $linia = strtok("\n");
         }
     }
     // Rotate graph 90 degrees and set margin
     $graph->Set90AndMargin($lm + 10, 20, 40, 30);
     // Set white margin color
     $graph->SetMarginColor('gray@0.95');
     // Setup title
     $graph->title->Set($question);
     $graph->title->SetMargin(10);
     $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize);
     $tWidth = $graph->title->GetWidth($graph->img);
     //if ($graph->title->GetWidth($graph->img)>$width) $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize-2);
     if ($tWidth > $width) {
         $index = strrpos(substr($question, 0, ($len = strlen($question)) / 2 + 5), ' ');
         //echo $index;
         if ($index === false) {
             $index = $len / 2 - 3;
         }
         $question[$index] = "\n";
         $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize -= 2);
         $graph->title->Set($question);
     }
     //$graph->subtitle->Set("(Non optimized)");
     // Setup X-axis
     $graph->xaxis->SetFont(FF_COMIC, FS_NORMAL, $xFontSize);
     $graph->xaxis->SetTickLabels($datax);
     $graph->xaxis->SetColor('black');
     // Some extra margin looks nicer
     $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(5);
     $graph->yaxis->SetPos('max');
     $graph->yaxis->SetLabelAlign('center', 'top');
     $graph->yaxis->SetLabelSide('SIDE_RIGHT');
     $graph->yaxis->SetLabelFormat('%2d%%');
     // Now create a bar pot
     $bplot = new BarPlot($datay);
     $bplot->SetWidth(0.4);
     // We want to display the value of each bar at the top
     $bplot->value->Show();
     $bplot->value->SetFont(FF_VERDANA, FS_BOLD, $xFontSize - 1);
     //$bplot->SetShadow("black@0.1",2,2);
     $bplot->value->SetAlign('right', 'center');
     $bplot->value->SetColor("yellow");
     $bplot->value->SetFormat('%d%%');
     $bplot->value->HideZero();
     $bplot->SetValuePos('max');
     //$graph->SetMarginColor('green');
     // Box around plotarea
     $graph->SetBox();
     $graph->SetFrame();
     $graph->SetShadow();
     // Setup the X and Y grid
     $graph->ygrid->SetFill(true, '#DDDDDD@0.5', '#BBBBBB@0.5');
     $graph->ygrid->SetLineStyle('dashed');
     $graph->ygrid->SetColor('gray');
     $graph->xgrid->Show();
     $graph->xgrid->SetLineStyle('dashed');
     $graph->xgrid->SetColor('gray');
     $fcol = '#440000';
     $tcol = '#FF9090';
     $bplot->SetFillGradient($fcol, $tcol, GRAD_LEFT_REFLECTION);
     // Set line weigth to 0 so that there are no border
     // around each bar
     $bplot->SetWeight(0);
     $graph->Add($bplot);
     // .. and stroke the graph
     return $graph->Stroke("images/raporty/{$this->id_pytanie}H.png");
 }
Beispiel #10
0
$bplot1->value->Show();
$bplot1->value->SetFormat('%.0f');
$bplot1->value->SetColor('white');
$bplot1->value->SetAngle(90);
$bplot1->value->SetFont(FF_FONT1, FS_BOLD);
$bplot1->SetValuePos('bottom');
$bplot1->SetWidth(0.7);
$bplot2 = new BarPlot($lows);
$bplot2->SetFillColor('blue');
$bplot2->SetLegend("Low");
$bplot2->value->Show();
$bplot2->value->SetFormat('%.0f');
$bplot2->value->SetColor('white');
$bplot2->value->SetAngle(90);
$bplot2->value->SetFont(FF_FONT1, FS_BOLD);
$bplot2->SetValuePos('bottom');
$bplot2->SetWidth(0.7);
$gbarplot = new GroupBarPlot(array($bplot1, $bplot2));
$gbarplot->SetWidth(0.6);
if ($hasclimate) {
    $l1plot = new LinePlot($alows);
    $l1plot->SetColor("black");
    $l1plot->mark->SetType(MARK_FILLEDCIRCLE);
    $l1plot->mark->SetFillColor("lightblue");
    $l1plot->mark->SetWidth(4);
    $l1plot->SetWeight(2);
    $l1plot->SetLegend("Avg Low");
    $l1plot->SetBarCenter();
    $l2plot = new LinePlot($ahighs);
    $l2plot->SetColor("black");
    $l2plot->mark->SetType(MARK_FILLEDCIRCLE);
 private function createBarGraph()
 {
     // Create the graph.
     $graph = new Graph($this->width, $this->height, "auto");
     $graph->SetScale("textlin");
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->SetFrame(false);
     // ... and add it to the graph
     //$graph->xaxis->title->Set(Prado::localize('title'));
     //$graph->xaxis->SetTickLabels($this->xdata);
     //$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
     // First make the labels look right
     $graph->yaxis->SetLabelFormat('%d');
     $graph->yaxis->SetLabelSide(SIDE_LEFT);
     $graph->yaxis->SetLabelMargin(5);
     $graph->yaxis->scale->SetGrace(0.1);
     $graph->yaxis->HideZeroLabel();
     $graph->ygrid->SetFill(true, '#f2f2f2@0.5', '#cacaca@0.5');
     if ($this->shadow) {
         $graph->SetShadow();
     }
     // Create the bar plot
     $tmpArray = array();
     if ($this->numberdimensions > 1) {
         for ($ii = 1; $ii <= $this->numberpivots; $ii++) {
             for ($jj = 0; $jj < $this->numberchildren; $jj++) {
                 ${'tmpArray' . $ii . $jj} = array();
                 /*${'bplot'.$jj} = new BarPlot($this->ydata[$ii][$jj]);
                   ${'bplot'.$jj}->SetFillColor($this->colorarray[$jj]);
                   ${'bplot'.$jj}->value->Show();
                   ${'bplot'.$jj}->value->SetFormat('%d');
                   ${'bplot'.$jj}->value->SetColor("black");
                   ${'bplot'.$jj}->SetValuePos('top');
                   array_push(${'tmpArray'.$ii},${'bplot'.$jj});*/
                 array_push(${'tmpArray' . $ii . $jj}, $this->ydata[$ii][$jj]);
                 ${'bplot' . $ii . $jj} = new BarPlot(${'tmpArray' . $ii . $jj});
                 ${'bplot' . $ii . $jj}->SetFillColor($this->colorarray[$jj]);
                 ${'bplot' . $ii . $jj}->value->Show();
                 ${'bplot' . $ii . $jj}->value->SetFormat('%d');
                 ${'bplot' . $ii . $jj}->value->SetColor("black");
                 ${'bplot' . $ii . $jj}->SetValuePos('top');
                 //array_push($tmpArray,${'tmpArray'.$ii});
                 array_push($tmpArray, ${'bplot' . $ii . $jj});
             }
         }
         $gbplot = new GroupBarPlot($tmpArray);
         $gbplot->setWidth(0.9);
         $gbplot->SetLegend(Prado::localize($this->legend));
         $graph->Add($gbplot);
     } else {
         $tmpArray = array();
         for ($ii = 0; $ii < $this->numberpivots; $ii++) {
             array_push($tmpArray, $this->ydata[1][$ii]);
         }
         $bplot = new BarPlot($tmpArray);
         $bplot->value->Show();
         $bplot->value->SetFormat('%d');
         $bplot->value->SetColor("black");
         $bplot->SetValuePos('center');
         $bplot->SetWidth(0.8);
         $bplot->SetLegend(Prado::localize($this->legend));
         $graph->Add($bplot);
     }
     return $graph;
 }
Beispiel #12
0
 function GerarGraficoBarra()
 {
     require_once "../biblioteca/jpgraph/jpgraph.php";
     require_once "../biblioteca/jpgraph/jpgraph_bar.php";
     $grafico = new graph($this->largura, $this->altura, "png");
     /* Margem das partes principais do gráfico (dados), o que está
      * fora da margem fica separado para as labels, títulos, etc
      * Este valor ficará como padrão para todos os gráficos
      */
     $grafico->img->SetMargin(40, 30, 20, 40);
     $grafico->SetScale("textlin");
     $grafico->SetShadow();
     //Define Titulo e Subtitulo
     $grafico->title->Set($this->titulo);
     $grafico->subtitle->Set($this->subtitulo);
     // pedir para mostrar os grides no fundo do gráfico,
     // o ygrid é marcado como true por padrão
     $grafico->ygrid->Show(true);
     $grafico->xgrid->Show(true);
     $gBarras = new BarPlot($this->dados_eixoY);
     $gBarras->SetFillColor($this->cor_barra);
     $gBarras->SetShadow($this->cor_sombra);
     $gBarras->SetAbsWidth($this->largura_barra);
     $gBarras->value->Show();
     $gBarras->value->SetFormat('%d');
     $gBarras->SetValuePos('center');
     $gBarras->value->SetFont(FF_FONT1, FS_BOLD);
     // título dos vértices
     $grafico->yaxis->title->Set($this->label_eixoY);
     $grafico->xaxis->title->Set($this->label_eixoX);
     // título das barras
     $grafico->xaxis->SetTickLabels($this->dados_eixoX);
     $grafico->Add($gBarras);
     $grafico->Stroke("imagens/graficos/" . $this->nome);
 }