Exemplo n.º 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();
     */
 }
for ($i = 0; $i < $INTERVAL_COUNT; $i++) {
    $bucket[$i] = 0;
    $tick_labels[$i] = $i * $range_interval . "+";
    //.((($i+1)*$range_interval)-1);
}
foreach ($humidity as $value) {
    $bucket_pos = floor($value / $range_interval);
    if ($bucket_pos >= $INTERVAL_COUNT) {
        $bucket_pos = $INTERVAL_COUNT - 1;
    }
    $bucket[$bucket_pos]++;
    //error_log("item=".$value."||bucket_pos=".$bucket_pos."||count=".$bucket[$bucket_pos]);
}
$humidity_plot = new BarPlot($bucket);
$humidity_plot->SetColor('dodgerblue');
$humidity_plot->SetWeight(2);
$humidity_plot->SetFillColor('dodgerblue');
$graph = new Graph($width, $height);
$graph->SetFrame(false);
$graph->SetBackgroundImage('background_v_40_60.png', BGIMG_FILLPLOT);
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('textlin');
$graph->Add($humidity_plot);
$graph->ygrid->SetColor("azure3");
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetWeight(2);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3);
$graph->xaxis->SetTickLabels($tick_labels);
$graph->yaxis->SetWeight(2);
Exemplo n.º 3
0
$barplot_in = new BarPlot($in_data);
$barplot_in->SetLegend("Traffic In");
$barplot_in->SetColor('#' . $config['graph_colours']['greens'][1]);
$barplot_in->SetFillColor('#' . $config['graph_colours']['greens'][0]);
$barplot_in->SetWeight(1);
$barplot_out = new BarPlot($out_data);
$barplot_out->SetLegend("Traffic Out");
$barplot_out->SetColor('#' . $config['graph_colours']['blues'][0]);
$barplot_out->SetFillColor('#' . $config['graph_colours']['blues'][1]);
$barplot_out->SetWeight(1);
if ($imgtype == "historical") {
    $barplot_over = new BarPlot($overuse_data);
    $barplot_over->SetLegend("Traffic Overusage");
    $barplot_over->SetColor('darkred');
    $barplot_over->SetFillColor('lightred@0.4');
    $barplot_over->SetWeight(1);
    $lineplot_allow = new LinePlot($allow_data);
    $lineplot_allow->SetLegend("Traffic Allowed");
    $lineplot_allow->SetColor('black');
    $lineplot_allow->SetWeight(1);
    $gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out, $barplot_over));
} else {
    $lineplot_allow = new LinePlot($ave_data);
    //$lineplot_allow->SetLegend("Average per ".$imgtype);
    $lineplot_allow->SetLegend("Average");
    $lineplot_allow->SetColor('black');
    $lineplot_allow->SetWeight(1);
    $gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out));
}
$graph->Add($gbplot);
$graph->Add($lineplot_allow);
Exemplo n.º 4
0
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->SetColor('gray');
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle('dashed');
$graph->xgrid->SetColor('gray');
// Setup month as labels on the X-axis
$graph->xaxis->SetTickLabels($months);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph->xaxis->SetLabelAngle(45);
// Create a bar pot
$bplot = new BarPlot($ydata);
$bplot->SetWidth(0.6);
$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);
// Create filled line plot
$lplot = new LinePlot($ydata2);
$lplot->SetFillColor('skyblue@0.5');
$lplot->SetColor('navy@0.7');
$lplot->SetBarCenter();
$lplot->mark->SetType(MARK_SQUARE);
$lplot->mark->SetColor('blue@0.5');
$lplot->mark->SetFillColor('lightblue');
$lplot->mark->SetSize(6);
$graph->Add($lplot);
// .. and finally send it back to the browser
$graph->Stroke();
for ($i = 0; $i < $INTERVAL_COUNT; $i++) {
    $bucket[$i] = 0;
    $tick_labels[$i] = $i * $range_interval . "+";
    //.((($i+1)*$range_interval)-1);
}
foreach ($sewer as $value) {
    $bucket_pos = floor($value / $range_interval);
    if ($bucket_pos >= $INTERVAL_COUNT) {
        $bucket_pos = $INTERVAL_COUNT - 1;
    }
    $bucket[$bucket_pos]++;
    //error_log("item=".$value."||bucket_pos=".$bucket_pos."||count=".$bucket[$bucket_pos]);
}
$sewer_plot = new BarPlot($bucket);
$sewer_plot->SetColor('darkgoldenrod');
$sewer_plot->SetWeight(2);
$sewer_plot->SetFillColor('darkgoldenrod');
$graph = new Graph($width, $height);
$graph->SetFrame(false);
$graph->SetBackgroundImage('background_v_33_66.png', BGIMG_FILLPLOT);
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('textlin');
$graph->Add($sewer_plot);
$graph->ygrid->SetColor("azure3");
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetWeight(2);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3);
$graph->xaxis->SetTickLabels($tick_labels);
$graph->yaxis->SetWeight(2);
Exemplo n.º 6
0
/**
 * Un tableau contenant les moyennes des eleves pour chaque sequences
 * 
 * @param type $moyennes = array()
 */
function genererCourbe($moyennes, $rang, $codeperiode = "S")
{
    try {
        # Donnees de la courbe
        $ydata = $moyennes;
        $ydata2 = $moyennes;
        /* for ($i = 1; $i <= 6; $i++) {
           $r = rand(0, 20);
           $ydata[] = $r;
           $ydata2[] = $r;
           } */
        /** Definition des label de l'axe x */
        if ($codeperiode === "T") {
            $datax = array("TRIM1", "TRIM2", "TRIM3");
        } else {
            $datax = array("seq 1", "seq 2", "seq 3", "seq 4", "seq 5", "seq 6");
        }
        # Creation du graph
        $graph = new Graph(350, 250, 'auto');
        $graph->SetMarginColor('white');
        # Definir le max et le min des valeur X
        $graph->SetScale('textlin', 0, 20);
        #$graph->xaxis->title->Set("Séquences");
        $graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 12);
        $graph->yaxis->title->Set("Moyennes");
        $graph->xaxis->SetTickLabels($datax);
        $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 12);
        if ($codeperiode === "T") {
            $graph->xaxis->SetTitle("Trimestres", "middle");
        } else {
            $graph->xaxis->SetTitle("Séquences", "middle");
        }
        $graph->SetBackgroundGradient('white', 'lightblue', GRAD_HOR, BGRAD_PLOT);
        # Adjuster les margins (left, right, top, bottom)
        $graph->SetMargin(40, 5, 21, 45);
        # Box autour du plotarea
        $graph->SetBox();
        # Un cadre ou frame autour de l'image
        $graph->SetFrame(false);
        # Definir le titre tabulaire
        $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 8);
        $graph->tabtitle->Set($_SESSION['anneeacademique']);
        # Definir le titre du graphe
        $graph->title->SetFont(FF_VERDANA, FS_BOLD, 8);
        $graph->title->SetAlign("right");
        if (count($ydata) > 1) {
            $prev = $ydata[count($ydata) - 2];
            if ($prev < $ydata[count($ydata) - 1]) {
                $graph->title->Set("Performance en hausse");
            } elseif ($prev == $ydata[count($ydata) - 1]) {
                $graph->title->Set("Performance constante");
            } else {
                $graph->title->Set("Performance en baisse");
            }
        }
        # Definir les grid X et Y
        $graph->ygrid->SetFill(true, '#BBBBBB@0.9', '#FFFFFF@0.9');
        //$graph->ygrid->SetLineStyle('dashed');
        //$graph->ygrid->SetColor('gray');
        //$graph->xgrid->SetLineStyle('dashed');
        $graph->xgrid->SetColor('gray');
        $graph->xgrid->Show();
        //$graph->ygrid->Show();
        #$graph->SetBackgroundGradient('blue','navy:0.5',GRAD_HOR,BGRAD_MARGIN);
        $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
        $graph->xaxis->SetLabelAngle(0);
        # Creation d'une bar pot
        $bplot = new BarPlot($ydata);
        $bplot->SetWidth(0.9);
        $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);
        # Create filled line plot
        $lplot = new LinePlot($ydata2);
        $lplot->SetFillColor('skyblue@0.5');
        $lplot->SetStyle(1);
        $lplot->SetColor('navy@0.7');
        $lplot->SetBarCenter();
        $lplot->mark->SetType(MARK_SQUARE);
        $lplot->mark->SetColor('blue@0.5');
        $lplot->mark->SetFillColor('lightblue');
        $lplot->mark->SetSize(5);
        # Afficher les moyenne au dessus des barres
        $accbarplot = new AccBarPlot(array($bplot));
        $accbarplot->value->SetFormat("%.2f");
        $accbarplot->value->Show();
        $graph->Add($accbarplot);
        $graph->SetBackgroundImageMix(50);
        # Definir un fond d'ecran pour l'image
        $background = SITE_ROOT . "public/photos/eleves/" . $rang['PHOTOEL'];
        if (!empty($rang['PHOTOEL']) && file_exists(ROOT . DS . "public" . DS . "photos" . DS . "eleves" . DS . $rang['PHOTOEL'])) {
            $graph->SetBackgroundImage($background, BGIMG_FILLPLOT);
            # $icon = new IconPlot($background, 25, 25, 0.8, 50);
        } else {
            //$graph->SetBackgroundImage(SITE_ROOT . "public/img/". LOGO, BGIMG_FILLPLOT);
            # $icon = new IconPlot(SITE_ROOT . "public/img/ipw.png", 25, 25, 0.8, 50);
        }
        # $icon->SetAnchor('right', 'bottom');
        $graph->Add($lplot);
        // Display the graph
        $filename = ROOT . DS . "public" . DS . "tmp" . DS . $rang['IDELEVE'] . ".png";
        if (file_exists($filename)) {
            unlink($filename);
        }
        $graph->Stroke($filename);
        //echo "<img src='" . SITE_ROOT . "public/tmp/emp.png' />";
    } catch (Exception $e) {
        var_dump($e);
    }
}
Exemplo n.º 7
0
// Balkendiagramme gruppieren
$gbplot = new GroupBarPlot(array($bplot_neu, $bplot_alt));
// Balken- und Liniendiagramme hinzufügen
$graph->Add($gbplot);
$graph->Add($lplot_neu);
$graph->Add($lplot_alt);
// Überschrift und Achsenbeschriftung definieren
$graph->title->Set('Flugstunden und -bewegung(en) im Segelflug');
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 11);
$graph->xaxis->SetTickLabels($flugzeuge);
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 10);
$bplot_neu->SetWeight(0);
$bplot_neu->SetFillColor('#61a9f3');
$bplot_neu->SetFillGradient('#61a9f3', '#c0c0ff', GRAD_HOR);
$bplot_neu->SetLegend(sprintf('Flugstunden %d', date('Y')));
$bplot_alt->SetWeight(0);
$bplot_alt->SetFillColor('orange');
$bplot_alt->SetFillGradient('orange', '#ffff00', GRAD_HOR);
$bplot_alt->SetLegend(sprintf('Flugstunden %d', date('Y') - 1));
// Liniendiagramm definieren für Anzahl der Landungen im aktuellen Jahr
$lplot_neu->SetBarCenter();
$lplot_neu->SetWeight(2);
$lplot_neu->SetColor('#0000ff');
$lplot_neu->SetLegend(sprintf('Flugbewegung(en) %d', date('Y')));
$lplot_neu->mark->SetType(MARK_UTRIANGLE, '', 1.0);
$lplot_neu->mark->SetWeight(2);
$lplot_neu->mark->SetWidth(8);
$lplot_neu->mark->setColor('#0000ff');
$lplot_neu->mark->setFillColor('#0000ff');
// Liniendiagramm definieren für Anzahl der Landungen im Vorjahr
$lplot_alt->SetBarCenter();
Exemplo n.º 8
0
 private function barVPlot($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->SetMargin(35, 20, 40, $lm + 15);
     // 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);
     $graph->tabtitle->Set($question);
     $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, $tFontSize);
     $tWidth = $graph->tabtitle->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->tabtitle->Set($question);
         $graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, $tFontSize -= 2);
     }
     // Setup X-axis
     $graph->xaxis->SetFont(FF_COMIC, FS_NORMAL, $xFontSize);
     $graph->xaxis->SetTickLabels($datax);
     $graph->xaxis->SetColor('black');
     $graph->xaxis->SetLabelAngle(80);
     // Some extra margin looks nicer
     $graph->xaxis->SetLabelMargin(10);
     // Label align for X-axis
     $graph->xaxis->SetLabelAlign('center', 'top');
     // 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(10);
     //$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_NORMAL, $xFontSize);
     //$bplot->SetShadow("black@0.1",2,2);
     //$bplot->value->SetAlign('left','center');
     $bplot->value->SetColor("black");
     $bplot->value->SetFormat('%d%%');
     //$bplot->SetValuePos('max');
     //$graph->SetMarginColor('green');
     // Box around plotarea
     $graph->SetBox();
     $graph->SetFrame(false);
     //	$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}V.png");
     //header("Content-type: image/png");
     //ImagePng($im);
 }
    $bucket[$i] = 0;
    $tick_labels[$i] = $i * $range_interval . "+";
    //.((($i+1)*$range_interval)-1);
}
foreach ($dust as $value) {
    $bucket_pos = floor($value / $range_interval);
    if ($bucket_pos >= $INTERVAL_COUNT) {
        $bucket_pos = $INTERVAL_COUNT - 1;
    }
    $bucket[$bucket_pos]++;
    //error_log("item=".$value."||bucket_pos=".$bucket_pos."||count=".$bucket[$bucket_pos]);
}
// Now draw bar plot
$dust_plot = new BarPlot($bucket);
$dust_plot->SetColor('darkgray');
$dust_plot->SetWeight(2);
$dust_plot->SetFillColor('darkgray');
$graph = new Graph($width, $height);
$graph->SetFrame(false);
$graph->SetBackgroundImage('background_v_33_66.png', BGIMG_FILLPLOT);
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('textlin');
$graph->Add($dust_plot);
$graph->ygrid->SetColor("azure3");
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetWeight(2);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3);
$graph->xaxis->SetTickLabels($tick_labels);
$graph->yaxis->SetWeight(2);
Exemplo n.º 10
0
$datay = $y;
//create timearray for the x-axis
$x = array($clientrawextra['459'], $clientrawextra['460'], $clientrawextra['461'], $clientrawextra['462'], $clientrawextra['463'], $clientrawextra['464'], $clientrawextra['465'], $clientrawextra['466'], $clientrawextra['467'], $clientrawextra['468'], $clientrawextra['469'], $clientrawextra['470'], $clientrawextra['471'], $clientrawextra['472'], $clientrawextra['473'], $clientrawextra['474'], $clientrawextra['475'], $clientrawextra['476'], $clientrawextra['477'], $clientrawextra['478'], $clientrawextra['578'], $clientrawextra['579'], $clientrawextra['580'], $clientrawextra['581']);
$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
$bplot = new BarPlot($datay);
$bplot->SetWeight(2);
$bplot->SetColor("{$light_col}");
$bplot->SetFillGradient("{$light_col}", "#EEEEEE", GRAD_LEFT_REFLECTION);
$graph->Add($bplot);
// titles
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->title->Set("{$txt_lightning} {$txt_24h}");
$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);
$graph->xaxis->SetLabelAngle($label_angle);
$graph->xaxis->SetTextLabelInterval($label_interval);
Exemplo n.º 11
0
 public function createGraphMonthly($params = array(), $params2 = array())
 {
     $em = $this->getDoctrine()->getManager();
     list($param1, $param2, $y_eixo, $k, $nome, $tipo) = $params;
     list($code, $mes_atual, $mes_ini) = $params2;
     $fields = $em->createQuery("SELECT d.volumeIn, d.volumeOut, d.cirIn, d.cirOut, d.cirInRec, d.cirOutRec, d.date FROM CocarBundle:MonthlyPerformance d \n\t\t\t            \t\tWHERE (d.codeInterface = :code\n\t\t\t            \t\t\tAND d.date < :currentMonth AND d.date > :startDate) ORDER BY d.date ASC")->setParameter('code', $code)->setParameter('currentMonth', $mes_atual)->setParameter('startDate', $mes_ini)->getResult();
     foreach ($fields as $f) {
         $p1 = $param1 == 'volume_in' ? $f['volumeIn'] : $f['cirInRec'];
         $p2 = $param2 == 'volume_out' ? $f['volumeOut'] : $f['cirOutRec'];
         $data1y[] = $p1 / $k;
         $data2y[] = $p2 / $k;
         $ydata3[] = $f['cirIn'];
         $ydata4[] = $f['cirOut'];
         $a[] = $f['date']->format('m/Y');
     }
     if (isset($data1y)) {
         // Create the graph. These two calls are always required
         $graph = new \Graph(580, 280, "auto");
         $graph->SetScale("textlin");
         $graph->img->SetMargin(60, 10, 5, 60);
         // Create the bar plots
         $b1plot = new \BarPlot($data1y);
         $b1plot->SetFillColor("green:0.8");
         $b1plot->SetWeight(0);
         $b2plot = new \BarPlot($data2y);
         $b2plot->SetFillColor("blue");
         $b2plot->SetWeight(0);
         $graph->title->Set("{$tipo}");
         $graph->yaxis->title->Set($y_eixo);
         $graph->title->SetFont(FF_FONT1, FS_BOLD);
         $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
         $graph->xaxis->SetTickLabels($a);
         $graph->xaxis->SetLabelAngle(90);
         // Set the legends for the plots
         $b1plot->SetLegend("APS>");
         $b2plot->SetLegend(">APS");
         // Adjust the legend position
         $graph->legend->SetLayout(LEGEND_HOR);
         $graph->legend->Pos(0.01, 0.1, "right", "center");
         $graph->legend->SetFrameWeight(0);
         $graph->legend->SetShadow(0);
         // Create the grouped bar plot
         $gbplot = new \GroupBarPlot(array($b1plot, $b2plot));
         // ...and add it to the graPH
         $graph->Add($gbplot);
         if ($tipo == "CIR Mensal recomendado") {
             //apanha o cir in e cir out
             $lineplot3 = new \LinePlot($ydata3);
             $lineplot4 = new \LinePlot($ydata4);
             $graph->Add($lineplot4);
             $graph->Add($lineplot3);
             $lineplot3->SetColor("green:0.8");
             $lineplot3->SetWeight(1);
             $lineplot4->SetColor("blue");
             $lineplot4->SetWeight(1);
         }
         //Display the graph
         $graph->SetFrame(false);
         $nome_graf = $this->dir . "graficos/monthly/" . $code . "_" . $nome . ".png";
         $graph->Stroke($nome_graf);
     }
 }
Exemplo n.º 12
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
$datay1 = array(13, 8, 19, 7, 17, 6);
$datay2 = array(4, 5, 2, 7, 5, 25);
// Create the graph.
$graph = new Graph(350, 250);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
// Setup title
$graph->title->Set('Acc bar with gradient');
// Create the first bar
$bplot = new BarPlot($datay1);
$bplot->SetFillGradient('AntiqueWhite2', 'AntiqueWhite4:0.8', GRAD_VERT);
$bplot->SetColor('darkred');
$bplot->SetWeight(0);
// Create the second bar
$bplot2 = new BarPlot($datay2);
$bplot2->SetFillGradient('olivedrab1', 'olivedrab4', GRAD_VERT);
$bplot2->SetColor('darkgreen');
$bplot2->SetWeight(0);
// And join them in an accumulated bar
$accbplot = new AccBarPlot(array($bplot, $bplot2));
$accbplot->SetColor('darkgray');
$accbplot->SetWeight(1);
$graph->Add($accbplot);
$graph->Stroke();
Exemplo n.º 13
0
 public function create_graph($width = 600, $height = 200, $data, $title, $xaxis, $yaxis, $type = "bar")
 {
     require_once 'jpgraph/jpgraph.php';
     require_once 'jpgraph/jpgraph_line.php';
     require_once 'jpgraph/jpgraph_bar.php';
     require_once 'jpgraph/jpgraph_pie.php';
     // Create a graph instance
     if ($type == "bar" || $type == "line") {
         $graph = new Graph($width, $height);
     } else {
         if ($type == "pie") {
             $graph = new PieGraph($width, $height);
         }
     }
     // Specify what scale we want to use,
     // int = integer scale for the X-axis
     // int = integer scale for the Y-axis
     $graph->SetScale('intint');
     $graph->SetMarginColor("lightblue:1.1");
     $graph->SetShadow();
     $graph->SetMargin(60, 20, 10, 40);
     // Box around plotarea
     $graph->SetBox();
     // No frame around the image
     $graph->SetFrame(false);
     // Setup a title for the graph
     $graph->title->Set($title);
     $graph->title->SetMargin(8);
     $graph->title->SetColor("darkred");
     // 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');
     // Setup titles and X-axis labels, if it's array, first row is title
     if (is_array($xaxis)) {
         $graph->xaxis->title->Set($xaxis[0]);
         $xaxis = array_slice($xaxis, 1, count($xaxis) - 1);
         $graph->xaxis->SetTickLabels($xaxis);
     } else {
         $graph->xaxis->title->Set($xaxis);
     }
     // no array, just show name
     // Setup Y-axis title
     $graph->yaxis->title->SetMargin(10);
     $graph->yaxis->title->Set($yaxis);
     if ($type == "bar") {
         $plot = new BarPlot($data);
         $plot->SetWidth(0.6);
         $fcol = '#440000';
         $tcol = '#FF9090';
         $plot->SetFillGradient("navy:0.9", "navy:1.85", GRAD_LEFT_REFLECTION);
         //$plot->SetColor("black");
         // Set line weigth to 0 so that there are no border
         // around each bar
         $plot->SetWeight(0);
         // Add the plot to the graph
         $graph->Add($plot);
     } else {
         if ($type == "line") {
             $plot = new LinePlot($data);
             $plot->SetFillColor('skyblue@0.5');
             $plot->SetColor('navy@0.7');
             $plot->mark->SetType(MARK_SQUARE);
             $plot->mark->SetColor('blue@0.5');
             $plot->mark->SetFillColor('lightblue');
             $plot->mark->SetSize(5);
             // Add the plot to the graph
             $graph->Add($plot);
         } else {
             if ($type == "pie") {
                 $plot = new PiePlot($data);
                 $plot->SetCenter(0.5, 0.55);
                 $plot->SetSize(0.2);
                 // Enable and set policy for guide-lines
                 $plot->SetGuideLines();
                 $plot->SetGuideLinesAdjust(1.4);
                 // Setup the labels
                 $plot->SetLabelType(PIE_VALUE_PER);
                 $plot->value->Show();
                 //$plot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
                 $plot->value->SetFormat('%2.1f%%');
                 $plot->ExplodeSlice(1);
                 $plot->SetGuideLines(true);
                 $graph->SetMarginColor("white");
                 $plot->SetLegends($xaxis);
                 // Add the plot to the graph
                 $graph->Add($plot);
             } else {
                 die($type . " is not known graph type");
             }
         }
     }
     // Display the graph
     $fn = strtolower($title);
     $fn = str_replace(" ", "", $fn);
     $filename_relative = "site/web_app/images/dynamic/{$fn}.jpg";
     $filename_full = __DIR__ . "/" . $filename_relative;
     $graph->Stroke($filename_full);
     $imglink = "<img src='{$filename_relative}' title='{$title}' />\n";
     return $imglink;
 }
Exemplo n.º 14
0
// Adjust the margin slightly so that we use the
// entire area (since we don't use a frame)
$graph->SetMargin(30, 1, 20, 5);
// Box around plotarea
$graph->SetBox();
// No frame around the image
$graph->SetFrame(false);
// Setup the tab title
$graph->tabtitle->Set('  ' . $t . '  ');
$graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 12);
// Setup the X and Y grid
$graph->ygrid->SetFill(true, '#FEFEFE@0.5', '#EEEEEE@0.5');
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->SetColor('gray');
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle('dashed');
$graph->xgrid->SetColor('gray');
// Setup $x as labels on the X-axis
$graph->xaxis->SetTickLabels($x);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 7);
$graph->xaxis->SetLabelAngle(60);
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 7);
$graph->yaxis->SetLabelFormat('%d %%');
// Create a bar pot
$bplot = new BarPlot($y);
$bplot->SetWidth(0.6);
$bplot->SetFillColor($c);
$bplot->SetWeight(1);
$bplot->SetShadow('gray@0.25', 2, 2);
$graph->Add($bplot);
$graph->Stroke();
    $bucket[$i] = 0;
    $tick_labels[$i] = $i * $range_interval . "+";
    //.((($i+1)*$range_interval)-1);
}
foreach ($hcho as $value) {
    $bucket_pos = floor($value / $range_interval);
    if ($bucket_pos >= $INTERVAL_COUNT) {
        $bucket_pos = $INTERVAL_COUNT - 1;
    }
    $bucket[$bucket_pos]++;
    //error_log("item=".$value."||bucket_pos=".$bucket_pos."||count=".$bucket[$bucket_pos]);
}
// Now draw bar plot
$hcho_plot = new BarPlot($bucket);
$hcho_plot->SetColor('firebrick4');
$hcho_plot->SetWeight(2);
$hcho_plot->SetFillColor('firebrick4');
$graph = new Graph($width, $height);
$graph->SetFrame(false);
$graph->SetBackgroundImage('background_v_33_66.png', BGIMG_FILLPLOT);
$graph->SetBackgroundImageMix(35);
$graph->SetMargin(60, 60, 40, 50);
$graph->SetMarginColor('white');
$graph->SetScale('textlin');
$graph->Add($hcho_plot);
$graph->ygrid->SetColor("azure3");
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetWeight(2);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, $font_size - 3);
$graph->xaxis->SetTickLabels($tick_labels);
$graph->yaxis->SetWeight(2);
Exemplo n.º 16
0
 /**
  * Draw the XY type plot
  *
  * @param array $data plot data array reference
  * @param array $xmlArr xml array reference
  * @return object refernce XY plot object reference
  */
 public function renderXYPlot(&$data, &$xmlArr)
 {
     $id = $xmlArr['ATTRIBUTES']['ID'];
     $field = $xmlArr['ATTRIBUTES']['FIELD'];
     $chartType = $xmlArr['ATTRIBUTES']['CHARTTYPE'];
     $pointType = $xmlArr['ATTRIBUTES']['POINTTYPE'];
     $weight = $xmlArr['ATTRIBUTES']['WEIGHT'];
     $color = $xmlArr['ATTRIBUTES']['COLOR'];
     $fillColor = $xmlArr['ATTRIBUTES']['FILLCOLOR'];
     $showVal = $xmlArr['ATTRIBUTES']['SHOWVALUE'];
     $legend = $xmlArr['ATTRIBUTES']['LEGENDFIELD'];
     $visible = $xmlArr['ATTRIBUTES']['VISIBLE'];
     if ($chartType == 'Line' or $chartType == 'Bar') {
         if ($chartType == 'Line') {
             include_once JPGRAPH_DIR . '/jpgraph_line.php';
             $plot = new LinePlot($data);
             $this->_drawMark($plot->mark, $xmlArr['POINTMARK']['ATTRIBUTES']['TYPE'], $xmlArr['POINTMARK']['ATTRIBUTES']['COLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['FILLCOLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['SIZE']);
             $plot->SetBarCenter();
             $plot->SetCenter();
         } else {
             if ($chartType == 'Bar') {
                 include_once JPGRAPH_DIR . '/jpgraph_bar.php';
                 $plot = new BarPlot($data);
                 $plot->SetAlign('center');
             }
         }
         if ($color) {
             $plot->SetColor($color);
         }
         if ($fillColor) {
             $plot->SetFillColor($fillColor);
         }
         if ($weight) {
             $plot->SetWeight($weight);
         }
         if ($showVal == 1) {
             $plot->value->Show();
         }
         if ($legend) {
             $plot->SetLegend($legend);
         }
         $this->_drawString($plot->value, $xmlArr['VALUE']['ATTRIBUTES']['FONT'], $xmlArr['VALUE']['ATTRIBUTES']['COLOR']);
     }
     if ($chartType == 'GroupBar' or $chartType == 'AccBar') {
         $children = $xmlArr['ATTRIBUTES']['CHILDREN'];
         $childList = explode(",", $children);
         foreach ($childList as $child) {
             $childPlotList[] = $this->m_PlotList[$child];
         }
         if ($chartType == 'GroupBar') {
             $plot = new GroupBarPlot($childPlotList);
         } else {
             if ($chartType == 'AccBar') {
                 $plot = new AccBarPlot($childPlotList);
             }
         }
     }
     $this->m_PlotList[$id] = $plot;
     if ($visible == 1) {
         return $plot;
     }
     return null;
 }
 /**
  *
  */
 public function iterationSummary($id)
 {
     $iteration = Iterations::findOrFail($id);
     $issues = Issue::where('iterationid', '=', $iteration->id)->get();
     $tasksId = array();
     foreach ($issues as $issue) {
         $tasksId[] = $issue->id;
     }
     $tasks = Task::whereIn('issueid', $tasksId)->get();
     $countTODO = 0;
     $countDOING = 0;
     $countDONE = 0;
     foreach ($tasks as $task) {
         switch ($task->scrumid) {
             case 1:
                 $countTODO++;
                 break;
             case 2:
                 $countDOING++;
                 break;
             case 3:
                 $countDONE++;
                 break;
         }
     }
     JpGraph\JpGraph::load();
     JpGraph\JpGraph::module('bar');
     $l1datay = array($countTODO, $countDOING, $countDONE);
     //$datax=array('TO-DO','DOING','DONE');
     $datax = array('POR HACER', 'HACIENDO', 'HECHAS');
     //Create the graph
     $graph = new Graph(700, 300);
     $graph->SetScale('textlin');
     $graph->img->SetMargin(60, 130, 40, 60);
     $graph->SetShadow();
     // Create the linear error plot
     $l1plot = new BarPlot($l1datay);
     $l1plot->SetColor('red');
     $l1plot->SetWeight(2);
     $l1plot->SetLegend('Avance de iteracion');
     // Add the plots to t'he graph
     $graph->Add($l1plot);
     $graph->xaxis->SetTickLabels($datax);
     $graph->title->Set('Tareas');
     //$graph->xaxis->title->Set('Estados');
     //$graph->yaxis->title->Set('Cantidad');
     $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();
 }