Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
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();
     */
 }
Exemplo n.º 3
0
$graph->SetColor(array(250, 250, 250));
$graph->img->SetTransparent("white");
$t1 = new Text("This is a text");
$t1->SetPos(0.5, 0.5);
$t1->SetOrientation("h");
$t1->SetFont(FF_FONT1, FS_BOLD);
$t1->SetBox("white", "black", "gray");
$t1->SetColor("black");
$graph->AddText($t1);
// Create the linear error plot
$l1plot = new LinePlot($l1datay);
$l1plot->SetColor("blue");
$l1plot->SetWeight(2);
$l1plot->SetLegend("Prediction");
// Create the bar plot
$l2plot = new BarPlot($l2datay);
$l2plot->SetFillColor("orange");
$l2plot->SetLegend("Result");
// Add the plots to the graph
$graph->Add($l1plot);
$graph->Add($l2plot);
$graph->title->Set("Example 16.3");
$graph->xaxis->title->Set("Month");
$graph->yaxis->title->Set("x10,000 US\$");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetTickLabels($datax);
//$graph->xaxis->SetTextTickInterval(2);
// Display the graph
$graph->Stroke();
Exemplo n.º 4
0
$graph->title->Set('Energi - Energiforbruk ditt areal');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Creates the bars
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);
// Gets the names for the database to be used as legend on the picture
if ($stmt = $mysqli->prepare("SELECT legend1, legend2, legend3 \n                                    FROM legend\n\t\t\t\t\t\t\t\t\tWHERE tabell = 'Energi - Energiforbruk ditt areal - Kristiansand' \n\t\t\t\t\t\t\t\t\tLIMIT 1")) {
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($legend1, $legend2, $legend3);
    $stmt->fetch();
}
$bplot1->SetLegend($legend1);
$bplot2->SetLegend($legend2);
$bplot3->SetLegend($legend3);
// To gather the bar plots close to eachother
$gbarplot = new GroupBarPlot(array($bplot1, $bplot2, $bplot3));
$gbarplot->SetWidth(0.8);
$graph->Add($gbarplot);
// draws the barplots
$bplot1->value->Show();
$bplot2->value->Show();
$bplot3->value->Show();
$bplot1->value->SetFormat('%01d');
$bplot2->value->SetFormat('%01d');
$bplot3->value->SetFormat('%01d');
$bplot1->value->SetFont(FF_ARIAL, FS_BOLD, 10);
$bplot2->value->SetFont(FF_ARIAL, FS_BOLD, 10);
$bplot3->value->SetFont(FF_ARIAL, FS_BOLD, 10);
$bplot1->value->SetAngle(45);
Exemplo n.º 5
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;
 }
Exemplo n.º 6
0
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Make the margin around the plot a little bit bigger
// then default
$graph->img->SetMargin(40, 140, 40, 80);
// Slightly adjust the legend from it's default position in the
// top right corner to middle right side
$graph->legend->Pos(0.05, 0.5, "right", "center");
// Display every 10:th datalabel
$graph->xaxis->SetTextTickInterval(6);
$graph->xaxis->SetTextLabelInterval(2);
$graph->xaxis->SetTickLabels($databarx);
$graph->xaxis->SetLabelAngle(90);
// Create a red line plot
$p1 = new LinePlot($datay);
$p1->SetColor("red");
$p1->SetLegend("Pressure");
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend("Temperature");
$b1->SetAbsWidth(6);
$b1->SetShadow();
// The order the plots are added determines who's ontop
$graph->Add($p1);
$graph->Add($b1);
// Finally output the  image
$graph->Stroke();
?>


Exemplo n.º 7
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
// Some data
for ($i = 0; $i < 12; ++$i) {
    $databary[$i] = rand(1, 20);
}
$months = $gDateLocale->GetShortMonth();
// New graph with a drop shadow
$graph = new Graph(300, 200);
$graph->SetShadow();
// Use a "text" X-scale
$graph->SetScale('textlin');
// Specify X-labels
$graph->xaxis->SetTickLabels($months);
$graph->xaxis->SetTextTickInterval(2, 0);
// Set title and subtitle
$graph->title->Set('Textscale with tickinterval=2');
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Create the bar plot
$b1 = new BarPlot($databary);
$b1->SetLegend('Temperature');
// The order the plots are added determines who's ontop
$graph->Add($b1);
// Finally output the  image
$graph->Stroke();
?>


$graph->img->SetMargin(40, 30, 20, 160);
//Setup Frame
$graph->SetFrame(true, "#ffffff");
// Setup graph title
//$graph->title->Set($title);
//$graph->title->SetFont(FF_FONT1, FS_BOLD);
$bar_array = array();
$i = 0;
foreach ($final_values as $title => $values) {
    $i %= count($color_list);
    $datay = explode(",", $values);
    $bplot = new BarPlot($datay);
    $bplot->SetWidth(0.7);
    $bplot->SetFillColor($color_list[$i] . "@0.5");
    $bplot->SetColor($color_list[$i] . "@1");
    $bplot->SetLegend($title);
    $bar_array[] = $bplot;
    $i++;
}
// Create the grouped bar plot
$gbplot = new AccBarPlot($bar_array);
$gbplot->SetShadow($color . "@0.9", 6, 5);
$gbplot->SetWidth(0.6);
$graph->Add($gbplot);
$graph->xaxis->SetTickLabels($labelx);
$graph->xaxis->title->Set($titley);
$graph->yaxis->title->Set($titlex);
// Adjust the legend position
$graph->legend->SetColumns(3);
$graph->legend->SetPos(0.5, 0.95, 'center', 'bottom');
$graph->legend->SetShadow('#fafafa', 0);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 7);
$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);
//$b4plot = new BarPlot($data4y);
// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot, $b2plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$b1plot->SetColor("white");
$b1plot->SetFillColor("#66cd00");
$b1plot->value->Show();
$b1plot->SetLegend('pos_exercise');
$b2plot->SetColor("white");
$b2plot->SetFillColor("#1c86ee");
$b2plot->value->Show();
$b2plot->SetLegend('mot_exercise');
//$b3plot->SetColor("white");
//$b3plot->SetFillColor("#ee1289");
//$b4plot->SetColor("white");
//$b4plot->SetFillColor("#6600ff");
$graph->title->Set("Weekly Exercise Trends in Warmer Places");
// position the graph
//$mgraph = new MGraph();
//$xpos1=100;$ypos1=3;
//$mgraph->Add($graph,'auto','auto');
// display the graph
$graph->Stroke();
Exemplo n.º 10
0
$available_n_pages[] = @$n_pages_[PROJ_POST_SECOND_AVAILABLE];
$progordone_n_pages[] = @$n_pages_[PROJ_POST_SECOND_CHECKED_OUT];
// ---------------
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(50, 230, 30, 40);
// ------------------------
// Create the bar plots
$unavail_plot = new BarPlot($unavail_n_pages);
$unavail_plot->SetLegend(_('unavailable'));
$waiting_plot = new BarPlot($waiting_n_pages);
$waiting_plot->SetLegend(_('waiting (to be available)'));
$available_plot = new BarPlot($available_n_pages);
$available_plot->SetLegend(_('available'));
$progordone_plot = new BarPlot($progordone_n_pages);
$progordone_plot->SetLegend(_('in progress or done'));
// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($unavail_plot, $waiting_plot, $available_plot, $progordone_plot));
// ...and add it to the graph
$graph->Add($gbplot);
// ------------------------
$graph->title->Set(_("Number of pages in various states"));
$graph->xaxis->title->Set(_("stage"));
// $graph->yaxis->title->Set(_("# pages"));
$graph->xaxis->SetTickLabels($stage_labels);
$graph->title->SetFont($jpgraph_FF, $jpgraph_FS);
$graph->yaxis->title->SetFont($jpgraph_FF, $jpgraph_FS);
$graph->xaxis->title->SetFont($jpgraph_FF, $jpgraph_FS);
// Display the graph
$graph->Stroke();
// vim: sw=4 ts=4 expandtab
Exemplo n.º 11
0
$gbplot = new GroupBarPlot(array($bplot, $bplot1, $bplot2));
// Adjust fill color
$graph->Add($gbplot);
$bplot->SetFillColor('#C40505');
$bplot->SetColor('#C40505');
$bplot->value->Show();
$bplot->value->SetFormat('%d');
$bplot->SetLegend("External");
$bplot1->SetFillColor('#94D239');
$bplot1->SetColor('#94D239');
$bplot1->value->Show();
$bplot1->value->SetFormat('%d');
$bplot1->SetLegend("Internal");
$bplot2->SetFillColor('#3925F8');
$bplot2->SetColor('#3925F8');
$bplot2->value->Show();
$bplot2->value->SetFormat('%d');
$bplot2->SetLegend("From Outside");
// Setup the titles
$graph->title->Set("Last 4 weeks - Total weekly calls breakdown by context");
$graph->xaxis->title->Set("Week year");
$graph->yaxis->title->Set("Calls");
$graph->yaxis->SetLabelAlign('center', 'top');
$graph->legend->SetColumns(3);
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetPos(0.5, 0.14, 'center', 'bottom');
$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();
Exemplo n.º 12
0
$datay = array(12, 26, 9, 17, 31);
// Create the graph.
$graph = new Graph(400, 250);
$graph->SetScale("textlin");
$graph->SetMargin(50, 80, 20, 40);
$graph->yaxis->SetTitleMargin(30);
$graph->yaxis->scale->SetGrace(30);
$graph->SetShadow();
// Create a bar pot
$bplot = new BarPlot($datay);
// Create targets for the bars image maps. One for each column
$targ = array("bar_clsmex1.php#1", "bar_clsmex1.php#2", "bar_clsmex1.php#3", "bar_clsmex1.php#4", "bar_clsmex1.php#5", "bar_clsmex1.php#6");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$bplot->SetCSIMTargets($targ, $alts);
$bplot->SetFillColor("orange");
$bplot->SetLegend('Year 2001 %%', '#kalle ', '%s');
// Display the values on top of each bar
$bplot->SetShadow();
$bplot->value->SetFormat(" \$ %2.1f", 70);
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 9);
$bplot->value->SetColor("blue");
$bplot->value->Show();
$graph->Add($bplot);
// Create a big "button" that has an image map action
$txt1 = new Text("A simple text with\ntwo rows");
$txt1->SetFont(FF_ARIAL);
$txt1->SetBox('lightblue', 'black', 'white@1', 5);
$txt1->SetParagraphAlign('center');
$txt1->SetPos(40, 50);
$txt1->SetCSIMTarget('#88', 'Text element');
$graph->Add($txt1);
Exemplo n.º 13
0
function metric_as_graph($result, $xaxis, $metric, $system, $start_date, $end_date)
{
    set_time_limit(900);
    $myresult = $result;
    $nrows = 0;
    $xmax = 0;
    while ($myresult->fetchInto($row)) {
        $keys = array_keys($row);
        foreach ($keys as $key) {
            $rawdata[$nrows][$key] = $row[$key];
        }
        $nrows++;
    }
    if ($xaxis == 'nproc') {
        for ($i = 0; $i <= nprocs($system); $i++) {
            $x[$i] = "";
            $y[$i] = "";
            $min[$i] = "";
            $max[$i] = "";
            $stddev[$i] = "";
            $max[$i] = "";
            $ysigma[2 * $i] = "";
            $ysigma[2 * $i + 1] = "";
        }
    }
    if ($metric == 'jobcount') {
        for ($i = 0; $i < $nrows; $i++) {
            $x[$i] = $rawdata[$i][0];
            if ($xaxis == 'nproc') {
                if ($x[$i] > $xmax) {
                    $xmax = $x[$i];
                }
                $y[$x[$i]] = $rawdata[$i][1];
            } else {
                $y[$i] = $rawdata[$i][1];
            }
        }
    } elseif ($metric == 'cpuhours' || $metric == 'xfactor' || $metric == 'users' || $metric == 'groups') {
        for ($i = 0; $i < $nrows; $i++) {
            $x[$i] = $rawdata[$i][0];
            if ($xaxis == 'nproc') {
                if ($x[$i] > $xmax) {
                    $xmax = $x[$i];
                }
                $y[$x[$i]] = $rawdata[$i][2];
            } else {
                $y[$i] = $rawdata[$i][2];
            }
        }
    } elseif ($metric == 'backlog') {
        for ($i = 0; $i < $nrows; $i++) {
            $x[$i] = $rawdata[$i][0];
            if ($xaxis == 'nproc') {
                if ($x[$i] > $xmax) {
                    $xmax = $x[$i];
                }
                $y[$x[$i]] = time_to_hrs($rawdata[$i][3]);
                $max[$x[$i]] = time_to_hrs($rawdata[$i][2]);
            } else {
                $y[$i] = time_to_hrs($rawdata[$i][3]);
                $max[$i] = time_to_hrs($rawdata[$i][2]);
            }
        }
    } else {
        for ($i = 0; $i < $nrows; $i++) {
            $x[$i] = $rawdata[$i][0];
            if ($xaxis == 'nproc') {
                if ($x[$i] > $xmax) {
                    $xmax = $x[$i];
                }
                $y[$x[$i]] = $rawdata[$i][4];
                if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $y[$x[$i]])) {
                    $y[$x[$i]] = time_to_hrs($y[$x[$i]]);
                }
                $min[$x[$i]] = $rawdata[$i][2];
                if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $min[$x[$i]])) {
                    $min[$x[$i]] = time_to_hrs($min[$x[$i]]);
                }
                $max[$x[$i]] = $rawdata[$i][3];
                if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $max[$x[$i]])) {
                    $max[$x[$i]] = time_to_hrs($max[$x[$i]]);
                }
                $stddev[$x[$i]] = $rawdata[$i][5];
                if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $stddev[$x[$i]])) {
                    $stddev[$x[$i]] = time_to_hrs($stddev[$x[$i]]);
                }
                $ysigma[2 * $x[$i]] = $y[$x[$i]] - $stddev[$x[$i]];
                if ($ysigma[2 * $x[$i]] < 0.0) {
                    $ysigma[2 * $x[$i]] = 0.0;
                }
                $ysigma[2 * $x[$i] + 1] = $y[$x[$i]] + $stddev[$x[$i]];
            } else {
                $y[$i] = $rawdata[$i][4];
                if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $y[$i])) {
                    $y[$i] = time_to_hrs($y[$i]);
                }
                $min[$i] = $rawdata[$i][2];
                if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $min[$i])) {
                    $min[$i] = time_to_hrs($min[$i]);
                }
                $max[$i] = $rawdata[$i][3];
                if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $max[$i])) {
                    $max[$i] = time_to_hrs($max[$i]);
                }
                $stddev[$i] = $rawdata[$i][5];
                if (preg_match('/^[0-9]+:[0-5][0-9]:[0-5][0-9]$/', $stddev[$i])) {
                    $stddev[$i] = time_to_hrs($stddev[$i]);
                }
                $ysigma[2 * $i] = $y[$i] - $stddev[$i];
                if ($ysigma[2 * $i] < 0.0) {
                    $ysigma[2 * $i] = 0.0;
                }
                $ysigma[2 * $i + 1] = $y[$i] + $stddev[$i];
            }
        }
    }
    $cache = APACHE_CACHE_DIR;
    if (!file_exists("/tmp/" . $cache)) {
        mkdir("/tmp/" . $cache, 0750);
    }
    $plot = $system . "-" . $metric . "_vs_" . $xaxis . "-" . $start_date . "-" . $end_date . ".png";
    //  $graph = new graph(640,480,$plot,2,0);
    $graph = new graph(800, 600, $plot, 2, 0);
    $graph->img->SetMargin(75, 30, 30, 75);
    if ($xaxis == 'nproc') {
        $graph->SetScale("linlin");
        //$graph->xaxis->SetAutoMax(nprocs($system));
    } else {
        $graph->SetScale("textlin");
        $graph->xaxis->SetLabelAngle(90);
        $graph->xaxis->SetTickLabels($x);
    }
    $graph->xaxis->title->Set($xaxis);
    $graph->yaxis->title->Set($metric . units($metric));
    if ($metric == "walltime_acc" || $metric == "cpu_eff") {
        $graph->yscale->SetAutoMax(1.1);
    } elseif ($metric == "xfactor") {
        $graph->yscale->SetAutoMin(1.0);
    }
    if ($metric != "jobcount" && $metric != "cpuhours" && $metric != "backlog" && $metric != "xfactor" && $metric != "users" && $metric != "groups") {
        $maxbar = new BarPlot($max);
        $maxbar->SetWidth(1.0);
        $maxbar->SetFillColor("gray");
        $maxbar->SetLegend("Maximum");
        $graph->Add($maxbar);
    } else {
        if ($metric == "backlog") {
            $maxbar = new BarPlot($max);
            $maxbar->SetWidth(1.0);
            $maxbar->SetFillColor("gray");
            $maxbar->SetLegend("CPU Hours");
            $graph->Add($maxbar);
        }
    }
    $ybar = new BarPlot($y);
    $ybar->SetWidth(1.0);
    if ($metric != "jobcount" && $metric != "cpuhours" && $metric != "backlog" && $metric != "xfactor" && $metric != "users" && $metric != "groups") {
        $ybar->SetLegend("Mean");
    } else {
        if ($metric == "backlog") {
            $ybar->SetLegend("Queue Hours");
        }
    }
    $graph->Add($ybar);
    if ($metric != "jobcount" && $metric != "cpuhours" && $metric != "backlog" && $metric != "xfactor" && $metric != "users" && $metric != "groups") {
        $minbar = new BarPlot($min);
        $minbar->SetWidth(1.0);
        $minbar->SetFillColor("white");
        $minbar->SetLegend("Minimum");
        $graph->Add($minbar);
        $errbars = new ErrorPlot($ysigma);
        $errbars->SetColor("red");
        //$errbars->SetCenter();
        $errbars->SetWeight(2);
        $errbars->SetLegend("Std.Dev.");
        $graph->Add($errbars);
    }
    $graph->Stroke();
    $imgurl = $cache . rawurlencode($plot);
    echo "<img src=\"" . $imgurl . "\">\n";
}
Exemplo n.º 14
0
$graph = new Graph(500, 200);
$graph->img->SetMargin(60, 150, 30, 50);
$graph->SetScale("textlin");
$graph->SetMarginColor("silver");
$graph->SetShadow();
// Set up the title for the graph
$graph->title->Set("Example negative bars");
$graph->title->SetFont(FF_VERDANA, FS_NORMAL, 16);
$graph->title->SetColor("darkred");
// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 10);
$graph->yaxis->SetFont(FF_VERDANA, FS_NORMAL, 10);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// Set X-axis at the minimum value of Y-axis (default will be at 0)
$graph->xaxis->SetPos("min");
// "min" will position the x-axis at the minimum value of the Y-axis
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
$bplot->SetLegend("Result 1999", "blue");
// Setup color for gradient fill style
$bplot->SetFillGradient("navy", "steelblue", GRAD_MIDVER);
// Set color for the frame of each bar
$bplot->SetColor("navy");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
Exemplo n.º 15
0
function graph_group_pct($p_title = '', $p_graph_width = 350, $p_graph_height = 400)
{
    global $enum_name, $enum_name_count;
    global $open_bug_count, $closed_bug_count, $resolved_bug_count;
    error_check($open_bug_count + $closed_bug_count + $resolved_bug_count, $p_title);
    $graph = new Graph(250, 400);
    $graph->img->SetMargin(35, 35, 35, 150);
    if (ON == config_get_global('jpgraph_antialias')) {
        $graph->img->SetAntiAliasing();
    }
    $graph->SetScale('textlin');
    $graph->SetMarginColor('white');
    $graph->SetFrame(false);
    $graph->title->Set($p_title);
    $graph->xaxis->SetTickLabels($enum_name);
    $graph->xaxis->SetLabelAngle(90);
    $graph->yaxis->scale->ticks->SetDirection(-1);
    $p1 = new BarPlot($open_bug_count);
    $p1->SetFillColor('yellow');
    $p1->SetWidth(0.8);
    $p1->SetLegend(lang_get('legend_opened'));
    $p2 = new BarPlot($closed_bug_count);
    $p2->SetFillColor('blue');
    $p2->SetWidth(0.8);
    $p2->SetLegend(lang_get('legend_closed'));
    $p3 = new BarPlot($resolved_bug_count);
    $p3->SetFillColor('red');
    $p3->SetWidth(0.8);
    $p3->SetLegend(lang_get('legend_resolved'));
    $gbplot = new GroupBarPlot(array($p1, $p2, $p3));
    $graph->Add($gbplot);
    if (helper_show_queries()) {
        $graph->subtitle->Set(db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique)');
    }
    $graph->Stroke();
}
Exemplo n.º 16
0
require_once 'jpgraph/jpgraph_bar.php';
$l1datay = array(11, 9, 2, 4, 3, 13, 17);
$l2datay = array(23, 12, 5, 19, 17, 10, 15);
$datax = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug');
// Create the graph.
$graph = new Graph(400, 200);
$graph->SetScale('textlin');
$graph->img->SetMargin(40, 130, 20, 40);
$graph->SetShadow();
// Create the linear error plot
$l1plot = new LinePlot($l1datay);
$l1plot->SetColor('red');
$l1plot->SetWeight(2);
$l1plot->SetLegend('Prediction');
// Create the bar plot
$bplot = new BarPlot($l2datay);
$bplot->SetFillColor('orange');
$bplot->SetLegend('Result');
// Add the plots to t'he graph
$graph->Add($bplot);
$graph->Add($l1plot);
$graph->title->Set('Adding a line plot to a bar graph v1');
$graph->xaxis->title->Set('X-title');
$graph->yaxis->title->Set('Y-title');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->SetTickLabels($datax);
//$graph->xaxis->SetTextTickInterval(2);
// Display the graph
$graph->Stroke();
Exemplo n.º 17
0
//Asigna el titulo al eje x
$grafica->xaxis->SetTitle("Alumnos");
//Asigna el titulo y alineacion al eje y
$grafica->yaxis->SetTitle("Calificaciones", "middle");
//Asigna las etiquetas para los valores del eje x
$grafica->xaxis->SetTickLabels(array("Ana", "Sonia", "Sebastian", "Joel"));
//crea una serie para un grafico de barras
$fisica = new BarPlot(array(9, 8));
//asigna la leyenda para la serie fisica
$fisica->SetLegend("Fisica");
//asigna el color de relleno de las barras en formato hexadecimal
$fisica->SetFillColor("#E234A9");
//crea una serie para el grafico de barras
$matematicas = new BarPlot(array(8, 7));
//asigna la leyenda para la serie matematicas
$matematicas->SetLegend("Matematicas");
//asigna el color de relleno de las barras con el nombre del color
$matematicas->SetFillColor("blue");
// agrupa las series del grafico
$materias = new GroupBarPlot(array($fisica, $matematicas));
//agrega al grafico el grupo de series
$grafica->Add($materias);
//muestra el grafico
$grafica->Stroke();
/*require_once ("jpgraph/src/jpgraph.php");
require_once ("jpgraph/src/jpgraph_pie.php");
 
// Se define el array de valores y el array de la leyenda
$datos = array(40,60,21,33);
$leyenda = array("Morenas","Rubias","Pelirrojas","Otras");
 
Exemplo n.º 18
0
$bplot1->value->show();
// menampilkan diagram batang untuk data wanita dengan warna biru
// pada diagram batang ditampilkan value data
$bplot2 = new BarPlot($dataWanita);
$bplot2->SetFillColor("blue");
$bplot2->value->show();
$bplot3 = new BarPlot($dataPria);
$bplot3->SetFillColor("red");
$bplot3->value->show();
// mengelompokkan grafik batang berdasarkan pria dan wanita
$gbplot = new GroupBarPlot(array($bplot1, $bplot2, $bplot3));
$graph->Add($gbplot);
// membuat legend untuk keterangan pria dan wanita
$bplot1->SetLegend("Pria");
$bplot2->SetLegend("Wanita");
$bplot3->SetLegend("Bencong");
$graph->legend->Pos(0.05, 0.5, "right", "center");
// mengatur margin image
$graph->img->SetMargin(40, 110, 20, 40);
// menampilkan title grafik dan nama masing-masing sumbu
$graph->title->Set("Grafik Jumlah Penduduk Negara Th 1990");
$graph->xaxis->title->Set("Negara");
$graph->yaxis->title->Set("Jumlah");
// menampilkan nama negara ke sumbu x
$graph->xaxis->SetTickLabels($dataNegara);
// format font title grafik
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// menampilkan efek shadow pada image
$graph->SetShadow();
// menampilkan image ke browser
$graph->Stroke();
Exemplo n.º 19
0
}
$graph = new Graph($width, $height, "auto");
$graph->SetScale("textlin");
$graph->SetFrame(false);
//$graph->SetAntiAliasing();
// Create the bar plots
$fvPlot = new BarPlot($fvValues);
$fvPlot->SetFillColor("#009900");
$fvPlot->value->Show();
$fvPlot->value->SetFormat('%d');
$fvPlot->value->SetFont(FF_FONT1, FS_NORMAL, 9);
$fvPlot->SetLegend('First View');
$rvPlot = new BarPlot($rvValues);
$rvPlot->SetFillColor("#000099");
$rvPlot->value->Show();
$rvPlot->value->SetFormat('%d');
$rvPlot->value->SetFont(FF_FONT1, FS_NORMAL, 9);
$rvPlot->SetLegend('Repeat View');
// Create the grouped bar plot
$bars = new GroupBarPlot(array($fvPlot, $rvPlot));
// set other options
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, $fontSize);
$graph->title->Set($chartType);
$graph->xaxis->SetTickLabels($labels);
$graph->yaxis->SetFont(FF_FONT1, FS_NORMAL, 9);
$graph->xaxis->SetFont(FF_FONT1, FS_NORMAL, 9);
$graph->xaxis->SetLabelAngle(90);
$graph->img->SetMargin(20, 20, 50, 200);
// ...and add it to the graPH
$graph->Add($bars);
$graph->Stroke();
$gbplot = new GroupBarPlot(array($b1plot, $b2plot, $b3plot, $b4plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$b1plot->SetColor("white");
$b1plot->SetFillColor("#66cd00");
$b1plot->SetLegend('People who consume #Alcohol - #partynight#drunk#hangover');
$b1plot->value->Show();
$b2plot->SetColor("white");
$b2plot->SetFillColor("#1c86ee");
$b2plot->SetLegend('People who want to #Quit alcohol #needMotivation - NEVER EVER drinking again #hangover#quit#booze');
$b2plot->value->Show();
$b3plot->SetColor("white");
$b3plot->SetFillColor("#ee1289");
$b3plot->SetLegend('People who #Smoke - #smoking and #drinking');
$b3plot->value->Show();
$b4plot->SetColor("white");
$b4plot->SetFillColor("#6600ff");
//$b4plot->SetLegend('People who want to #Quit Smoking #needMotivation' ) ;
$b4plot->SetLegend('People who want to #quit smoking-#I want to actually #quit#smoking');
$b4plot->value->Show();
$graph->title->Set("Weekly Alcohol & Smoking Trends");
$graph->legend->SetFrameWeight(1);
$graph->legend->SetPos(0.01, 0.85, 'centre');
$graph->legend->SetColumns(1);
$graph->legend->SetLayout(LEGEND_VERT);
// position the graph
//$mgraph = new MGraph();
//$xpos1=100;$ypos1=3;
//$mgraph->Add($graph,'auto','auto');
// display the graph
$graph->Stroke();
Exemplo n.º 21
0
 private function _renderPlotBar($groupID, $dimensions = '2d')
 {
     $rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
     //	Rotate for bar rather than column chart
     if ($groupID == 0 && $rotation == 'bar') {
         $this->_graph->Set90AndMargin();
     }
     $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
     $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
     if ($labelCount > 0) {
         $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
         $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation);
         //	Rotate for bar rather than column chart
         if ($rotation == 'bar') {
             $datasetLabels = array_reverse($datasetLabels);
             $this->_graph->yaxis->SetPos('max');
             $this->_graph->yaxis->SetLabelAlign('center', 'top');
             $this->_graph->yaxis->SetLabelSide(SIDE_RIGHT);
         }
         $this->_graph->xaxis->SetTickLabels($datasetLabels);
     }
     $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
     $seriesPlots = array();
     if ($grouping == 'percentStacked') {
         $sumValues = $this->_percentageSumCalculation($groupID, $seriesCount);
     }
     //	Loop through each data series in turn
     for ($j = 0; $j < $seriesCount; ++$j) {
         $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
         if ($grouping == 'percentStacked') {
             $dataValues = $this->_percentageAdjustValues($dataValues, $sumValues);
         }
         //	Fill in any missing values in the $dataValues array
         $testCurrentIndex = 0;
         foreach ($dataValues as $k => $dataValue) {
             while ($k != $testCurrentIndex) {
                 $dataValues[$testCurrentIndex] = null;
                 ++$testCurrentIndex;
             }
             ++$testCurrentIndex;
         }
         //	Reverse the $dataValues order for bar rather than column chart
         if ($rotation == 'bar') {
             $dataValues = array_reverse($dataValues);
         }
         $seriesPlot = new BarPlot($dataValues);
         $seriesPlot->SetColor('black');
         $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
         if ($dimensions == '3d') {
             $seriesPlot->SetShadow();
         }
         if (!$this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)) {
             $dataLabel = '';
         } else {
             $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)->getDataValue();
         }
         $seriesPlot->SetLegend($dataLabel);
         $seriesPlots[] = $seriesPlot;
     }
     //	Reverse the plot order for bar rather than column chart
     if ($rotation == 'bar' && !($grouping == 'percentStacked')) {
         $seriesPlots = array_reverse($seriesPlots);
     }
     if ($grouping == 'clustered') {
         $groupPlot = new GroupBarPlot($seriesPlots);
     } elseif ($grouping == 'standard') {
         $groupPlot = new GroupBarPlot($seriesPlots);
     } else {
         $groupPlot = new AccBarPlot($seriesPlots);
         if ($dimensions == '3d') {
             $groupPlot->SetShadow();
         }
     }
     $this->_graph->Add($groupPlot);
 }
<?php

$graph = (require 'barGraph.php');
$datay = array(137, 136, 132, 126, 142, 267, 267, 253, 310, 303, 2791, 2802, 2727, 2771, 3403);
$bplot = new BarPlot($datay);
$bplot->SetFillColor('blue');
$bplot->SetLegend('PHPDFS');
$graph->Add($bplot);
$graph->Stroke();
Exemplo n.º 23
0
$graph->yaxis->title->Set('(%)');
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->ygrid->SetColor('black');
$graph->yaxis->SetTitleMargin(45);
$graph->yaxis->scale->SetGrace(30);
// TITRE: texte
$graph->title->Set("Pass and Fail rate");
// TITRE: marge et apparence
$graph->title->SetFont(FF_FONT1, FS_BOLD, 10);
// Couleurs et transparence par histogramme
$aColors = array('pink', 'teal', 'navy', 'lightblue', 'red', 'green');
$i = 0;
$aGroupBarPlot = array();
foreach ($data1 as $key => $value) {
    $bplot = new BarPlot($data1[$key]);
    $bplot->SetFillColor($aColors[$i++]);
    $bplot->value->Show();
    $bplot->value->SetFormat('%01.2f');
    $bplot->value->SetColor("black", "darkred");
    $bplot->SetLegend($key);
    $bplot->SetShadow('black');
    $bplot->SetWidth(0.2);
    $aGroupBarPlot[] = $bplot;
}
// Création de l'objet qui regroupe nos histogrammes
$gbarplot = new GroupBarPlot($aGroupBarPlot);
$gbarplot->SetWidth(0.5);
// Ajouter au graphique
$graph->Add($gbarplot);
// Afficher
$graph->Stroke();
Exemplo n.º 24
0
function graph_group($p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_height = 400, $p_baseline = 100)
{
    # $p_metrics is an array of three arrays
    #   $p_metrics['open'] = array( 'enum' => value, ...)
    #   $p_metrics['resolved']
    #   $p_metrics['closed']
    $t_graph_font = graph_get_font();
    # count up array portions that are set
    $t_count = 0;
    foreach (array('open', 'resolved', 'closed') as $t_label) {
        if (isset($p_metrics[$t_label]) && is_array($p_metrics[$t_label])) {
            $t_count += array_sum($p_metrics[$t_label]);
        }
    }
    error_check($t_count, $p_title);
    # calculate totals
    $total = graph_total_metrics($p_metrics);
    if (plugin_config_get('eczlibrary') == ON) {
        $graph = new ezcGraphBarChart();
        $graph->title = $p_title;
        $graph->background->color = '#FFFFFF';
        $graph->options->font = $t_graph_font;
        $graph->options->font->maxFontSize = 12;
        $graph->legend = false;
        foreach (array('open', 'resolved', 'closed') as $t_label) {
            $graph->data[$t_label] = new ezcGraphArrayDataSet($p_metrics[$t_label]);
        }
        $graph->data['total'] = new ezcGraphArrayDataSet($total);
        //$graph->data['total']->displayType = ezcGraph::LINE;
        //$graph->data['total']->barMargin = -20;
        $graph->options->fillLines = 210;
        $graph->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedLabelRenderer();
        $graph->xAxis->axisLabelRenderer->angle = 45;
        $graph->driver = new ezcGraphGdDriver();
        //$graph->driver->options->supersampling = 1;
        $graph->driver->options->jpegQuality = 100;
        $graph->driver->options->imageFormat = IMG_JPEG;
        $graph->renderer->options->syncAxisFonts = false;
        $graph->renderToOutput($p_graph_width, $p_graph_height);
    } else {
        # defines margin according to height
        $graph = new Graph($p_graph_width, $p_graph_height);
        $graph->img->SetMargin(45, 35, 35, $p_baseline);
        if (ON == plugin_config_get('jpgraph_antialias')) {
            $graph->img->SetAntiAliasing();
        }
        $graph->SetScale('textlin');
        $graph->SetMarginColor('white');
        $graph->SetFrame(false);
        $graph->title->SetFont($t_graph_font, FS_BOLD);
        $graph->title->Set($p_title);
        $graph->xaxis->SetTickLabels(array_keys($p_metrics['open']));
        if (FF_FONT2 <= $t_graph_font) {
            $graph->xaxis->SetLabelAngle(60);
        } else {
            $graph->xaxis->SetLabelAngle(90);
            # can't rotate non truetype fonts
        }
        $graph->xaxis->SetFont($t_graph_font);
        $graph->legend->Pos(0.05, 0.08);
        $graph->legend->SetFont($t_graph_font);
        $graph->yaxis->scale->ticks->SetDirection(-1);
        $graph->yaxis->SetFont($t_graph_font);
        $graph->yscale->SetGrace(10);
        # adds on the same graph
        $tot = new BarPlot(array_values($total));
        $tot->SetFillColor('lightblue');
        $tot->SetWidth(0.7);
        $tot->SetLegend(plugin_lang_get('legend_total'));
        $graph->Add($tot);
        $p1 = new BarPlot(array_values($p_metrics['open']));
        $p1->SetFillColor('yellow');
        $p1->SetWidth(1);
        $p1->SetLegend(plugin_lang_get('legend_opened'));
        $p2 = new BarPlot(array_values($p_metrics['closed']));
        $p2->SetFillColor('blue');
        $p2->SetWidth(1);
        $p2->SetLegend(plugin_lang_get('legend_closed'));
        $p3 = new BarPlot(array_values($p_metrics['resolved']));
        $p3->SetFillColor('red');
        $p3->SetWidth(1);
        $p3->SetLegend(plugin_lang_get('legend_resolved'));
        $gbplot = new GroupBarPlot(array($p1, $p3, $p2));
        $graph->Add($gbplot);
        if (helper_show_query_count()) {
            $graph->subtitle->Set(db_count_queries() . ' queries (' . db_time_queries() . 'sec)');
            $graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8);
        }
        $graph->Stroke();
    }
}
Exemplo n.º 25
0
    }
    $gbplot = new GroupBarPlot(array($bar1, $abar1));
    $graph->Add($gbplot);
    $graph->AddY2($line1);
    $bar1->SetColor('blue');
    $bar1->SetFillColor('blue');
    $bar1->SetLegend('Mail');
    $bar2->SetColor('orange');
    $bar2->SetFillColor('orange');
    $bar2->SetLegend('Viruses');
    $bar3->SetColor('red');
    $bar3->SetFillColor('red');
    $bar3->SetLegend('Spam');
    if ($is_MCP_enabled === true) {
        $bar4->SetFillColor('lightblue');
        $bar4->SetLegend('MCP');
    }
    $line1->SetColor('lightgreen');
    $line1->SetFillColor('lightgreen');
    $line1->SetLegend('Volume (' . $size_info['shortdesc'] . ')');
    $line1->SetCenter();
    $graph->Stroke($filename);
}
// HTML Code to display the graph
echo "<TABLE BORDER=\"0\" CELLPADDING=\"10\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
echo " <TR><TD ALIGN=\"CENTER\"><IMG SRC=\"" . IMAGES_DIR . "mailscannerlogo.gif\" ALT=\"MailScanner Logo\"></TD></TR>";
echo " <TR>\n";
//  Check Permissions to see if the file has been written and that apache to read it.
if (is_readable($filename)) {
    echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . $filename . "\" ALT=\"Graph\"></TD>";
} else {
Exemplo n.º 26
0
$graph->yaxis->SetColor('navy');
//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');
// Setup graph title
$graph->title->Set('Using a country flag background');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
// Create the three var series we will combine
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);
// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('yellow@0.4');
$bplot2->SetFillColor('red@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
// Setup legends
$bplot1->SetLegend('Label 1');
$bplot2->SetLegend('Label 2');
$bplot3->SetLegend('Label 3');
// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$gbarplot = new GroupBarPlot(array($bplot1, $bplot2, $bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
?>

Exemplo n.º 27
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();
Exemplo n.º 28
0
/**
 * Método que sirve de reemplazo al mecanismo de paloSantoGraph y paloSantoGraphLib
 * para generar gráficos a partir de una clase que devuelve datos.
 *
 * @param   string  $module     Módulo que contiene la clase fuente de datos
 * @param   string  $class      Clase a instanciar para obtener fuente de datos
 * @param   string  $function   Método a llamar en la clase para obtener datos
 * @param   array   $arrParameters  Lista de parámetros para la invocación 
 * @param   string  $functionCB 
 */
function displayGraph($G_MODULE, $G_CLASS, $G_FUNCTION, $G_PARAMETERS, $G_FUNCTIONCB = "")
{
    //------- PARAMETROS DEL GRAPH -------
    $G_TYPE = null;
    //tipo de grafica
    $G_TITLE = null;
    //titulo
    $G_COLOR = null;
    //colores
    $G_LABEL = array();
    //etiquetas
    $G_SIZE = array();
    //tamaño
    $G_MARGIN = array();
    //margen
    $G_LEYEND_NUM_COLUMN = 1;
    $G_LEYEND_POS = array(0.05, 0.5);
    //posicion de las leyendas
    $_MSJ_ERROR = null;
    //$_MSJ_ERROR   = "Sin mensaje ERROR";
    global $_MSJ_NOTHING;
    //$_MSJ_NOTHING = "Sin mensaje NOTHING";
    $G_YDATAS = array();
    $G_ARR_COLOR = array();
    $G_ARR_FILL_COLOR = array();
    $G_ARR_LEYEND = array();
    $G_ARR_STEP = array();
    $G_SHADOW = false;
    $G_LABEL_Y = null;
    //ESTATICOS
    $G_SCALE = "textlin";
    $G_WEIGHT = 1;
    if ($G_MODULE != '') {
        require_once "modules/{$G_MODULE}/libs/{$G_CLASS}.class.php";
        //lib del modulo
        require_once "modules/{$G_MODULE}/configs/default.conf.php";
        //archivo configuracion del modulo
        global $arrConfModule;
        $dsn = isset($arrConfModule["dsn_conn_database"]) ? $arrConfModule["dsn_conn_database"] : "";
    } else {
        require_once "libs/{$G_CLASS}.class.php";
        //lib del modulo
        require_once "configs/default.conf.php";
        //archivo configuracion del modulo
        global $arrConf;
        $dsn = isset($arrConf["dsn_conn_database"]) ? $arrConf["dsn_conn_database"] : "";
    }
    $oPaloClass = new $G_CLASS($dsn);
    $arrParam = $G_PARAMETERS;
    $result = call_user_func_array(array(&$oPaloClass, $G_FUNCTION), $arrParam);
    global $globalCB;
    $globalCB = NULL;
    if ($G_FUNCTIONCB != '') {
        $globalCB = array($oPaloClass, $G_FUNCTIONCB);
    }
    //------------------- CONTRUCCION DEL ARREGLO PARA X & Y -------------------
    global $xData;
    $xData = array();
    $yData = array();
    if (sizeof($result) != 0) {
        $isX_array = false;
        //usado en LINEPLOT, PLOT3D, BARPLOT, LINEPLOT_MULTIAXIS
        foreach ($result as $att => $arrXY) {
            //------------------ ATTRIBUTES ------------------
            if ($att == 'ATTRIBUTES') {
                foreach ($arrXY as $key => $values) {
                    //VARIABLES NECESARIAS
                    if ($key == 'LABEL_X') {
                        $G_LABEL[0] = $values;
                    } else {
                        if ($key == 'LABEL_Y') {
                            $G_LABEL[1] = $values;
                        } else {
                            if ($key == 'TITLE') {
                                $G_TITLE = $values;
                            } else {
                                if ($key == 'TYPE') {
                                    $G_TYPE = $values;
                                } else {
                                    if ($key == 'SIZE') {
                                        $G_SIZE = explode(',', $values);
                                    } else {
                                        if ($key == 'MARGIN') {
                                            $G_MARGIN = explode(',', $values);
                                        } else {
                                            if ($key == 'COLOR') {
                                                $G_COLOR = $values;
                                            } else {
                                                if ($key == 'POS_LEYEND') {
                                                    $G_LEYEND_POS = explode(',', $values);
                                                } else {
                                                    if ($key == 'NUM_COL_LEYEND') {
                                                        $G_LEYEND_NUM_COLUMN = $values;
                                                    } else {
                                                        if ($key == 'SHADOW') {
                                                            $G_SHADOW = $values;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } else {
                if ($att == 'MESSAGES') {
                    foreach ($arrXY as $key => $values) {
                        if ($key == 'ERROR') {
                            $_MSJ_ERROR = $values;
                        } else {
                            if ($key == 'NOTHING_SHOW') {
                                $_MSJ_NOTHING = $values;
                            }
                        }
                    }
                } else {
                    if ($att == 'DATA') {
                        foreach ($arrXY as $DAT_N => $MODES) {
                            foreach ($MODES as $key => $values) {
                                /************************************************************/
                                if ($G_TYPE == 'lineplot' || $G_TYPE == 'barplot' || $G_TYPE == 'lineplot_multiaxis') {
                                    if ($key == 'VALUES') {
                                        $yData = array();
                                        foreach ($values as $x => $y) {
                                            if ($isX_array == false) {
                                                $xData[] = $x;
                                            }
                                            $yData[] = $y;
                                        }
                                        $isX_array = is_array($xData) ? true : false;
                                        $G_YDATAS[] = $yData;
                                    } else {
                                        if ($key == 'STYLE') {
                                            foreach ($values as $x => $y) {
                                                if ($x == 'COLOR') {
                                                    $G_ARR_COLOR[] = $y;
                                                } else {
                                                    if ($x == 'LEYEND') {
                                                        $G_ARR_LEYEND[] = $y;
                                                    } else {
                                                        if ($x == 'STYLE_STEP') {
                                                            $G_ARR_STEP[] = $y;
                                                        } else {
                                                            if ($x == 'FILL_COLOR') {
                                                                $G_ARR_FILL_COLOR[] = $y;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                } else {
                                    if ($G_TYPE == 'plot3d' || $G_TYPE == 'plot3d2') {
                                        if ($key == 'VALUES') {
                                            foreach ($values as $x => $y) {
                                                $yData[] = $y;
                                            }
                                            $G_YDATAS[0] = $yData;
                                        } else {
                                            if ($key == 'STYLE') {
                                                foreach ($values as $x => $y) {
                                                    if ($x == 'COLOR') {
                                                        $G_ARR_COLOR[] = $y;
                                                    } else {
                                                        if ($x == 'LEYEND') {
                                                            $xData[] = $y;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    } else {
                                        if ($G_TYPE == 'bar' || $G_TYPE == 'gauge') {
                                            if ($key == 'VALUES') {
                                                foreach ($values as $x => $y) {
                                                    $G_YDATAS[] = $y;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //*****************************************//
    //      ***** ***** ***** ***** *   *      //
    //      *     *   * *   * *   * *   *      //
    //      * *** ***** ***** ***** *****      //
    //      *   * * *   *   * *     *   *      //
    //      ***** *   * *   * *     *   *      //
    //*****************************************//
    // L I N E P L O T
    if (sizeof($G_YDATAS) >= 1) {
        // true no funciona porque cada cadena u otro valor que se retorne es valor "valido o verdadero"
        // y equivale a true, entonces para diferenciarlo verdaderamente se compara con 'true'
        $str = checkAttributes($G_TITLE, $G_TYPE, $G_LABEL_Y, $_MSJ_ERROR, $_MSJ_NOTHING);
        if ($str != 'true') {
            showError($str, $G_SIZE);
            return;
        }
        if ($G_TYPE == 'lineplot') {
            $graph = new Graph($G_SIZE[0], $G_SIZE[1], "auto");
            if ($G_SHADOW) {
                $graph->SetShadow();
            }
            $graph->SetScale($G_SCALE);
            $graph->SetMarginColor($G_COLOR);
            $graph->title->Set($G_TITLE);
            $graph->SetFrame(true, '#999999');
            $graph->img->SetMargin($G_MARGIN[0], $G_MARGIN[1], $G_MARGIN[2], $G_MARGIN[3]);
            $graph->img->SetAntiAliasing();
            $graph->xaxis->SetLabelFormatCallback("CallBack");
            $graph->xaxis->SetLabelAngle(90);
            $graph->xaxis->title->Set($G_LABEL[0]);
            $graph->yaxis->title->Set($G_LABEL[1]);
            $graph->xgrid->Show();
            $graph->legend->SetFillColor("#fafafa");
            $graph->legend->Pos($G_LEYEND_POS[0], $G_LEYEND_POS[1], "right", "center");
            $graph->legend->SetColumns($G_LEYEND_NUM_COLUMN);
            $graph->legend->SetColor("#444444", "#999999");
            $arr_lineplot = array();
            foreach ($G_YDATAS as $num => $yDatas) {
                $lineplot = new LinePlot($yDatas);
                if ($G_ARR_STEP[$num] == true) {
                    $lineplot->SetStepStyle();
                }
                if ($G_ARR_FILL_COLOR[$num] == true) {
                    $lineplot->SetFillColor($G_ARR_COLOR[$num]);
                }
                $lineplot->SetColor($G_ARR_COLOR[$num]);
                $lineplot->SetWeight($G_WEIGHT);
                $lineplot->SetLegend($G_ARR_LEYEND[$num]);
                $arr_lineplot[] = $lineplot;
            }
            foreach ($arr_lineplot as $num => $yDatas) {
                $graph->Add($yDatas);
            }
            if (sizeof($xData) > 100) {
                $graph->xaxis->SetTextTickInterval((int) (sizeof($xData) / 10));
            }
            $graph->Stroke();
        } else {
            if ($G_TYPE == 'plot3d') {
                $graph = new PieGraph($G_SIZE[0], $G_SIZE[1], "auto");
                if ($G_SHADOW) {
                    $graph->SetShadow();
                }
                $dataMarginColor = isset($result["ATTRIBUTES"]["MARGIN_COLOR"]) ? $result["ATTRIBUTES"]["MARGIN_COLOR"] : "#999999";
                $dataSizePie = isset($result["ATTRIBUTES"]["SIZE_PIE"]) ? $result["ATTRIBUTES"]["SIZE_PIE"] : "80";
                $graph->SetMarginColor($G_COLOR);
                $graph->SetFrame(true, $dataMarginColor);
                $graph->legend->Pos($G_LEYEND_POS[0], $G_LEYEND_POS[1], "right", "center");
                $graph->legend->SetFillColor("#fafafa");
                $graph->legend->SetColor("#444444", "#999999");
                $graph->legend->SetShadow('gray@0.6', 4);
                $graph->legend->SetColumns($G_LEYEND_NUM_COLUMN);
                $graph->title->Set($G_TITLE);
                $pieplot3d = new PiePlot3d($G_YDATAS[0]);
                $pieplot3d->SetSliceColors($G_ARR_COLOR);
                $pieplot3d->SetCenter(0.4);
                $pieplot3d->SetSize($dataSizePie);
                $pieplot3d->SetAngle(45);
                $pieplot3d->SetStartAngle(45);
                $pieplot3d->value->SetColor('black');
                //color a los porcentages
                $pieplot3d->SetEdge('black');
                //da color al contorno y separacion del pastel
                $pieplot3d->SetLegends($xData);
                $graph->Add($pieplot3d);
                $graph->Stroke();
            } else {
                if ($G_TYPE == 'plot3d2') {
                    if (!function_exists('displayGraph_draw_pie3d')) {
                        function displayGraph_draw_pie3d($canvasx, $ydata, $arrcolor)
                        {
                            $canvasy = $canvasx;
                            $escala = $canvasx / 320.0;
                            $iAnchoPastel = 256 * $escala;
                            $iAltoPastel = 155 * $escala;
                            $iPosCentroX = 141 * $escala;
                            $iPosCentroY = 91 * $escala;
                            $thumb = imagecreatetruecolor($canvasx * 284 / 320, $canvasy * 250 / 320);
                            $transparent = imagecolorallocatealpha($thumb, 200, 200, 200, 127);
                            imagefill($thumb, 0, 0, $transparent);
                            // Asignar colores de imagen
                            $imgcolor = array();
                            foreach ($arrcolor as $i => $sHtmlColor) {
                                $r = $g = $b = 0;
                                sscanf($sHtmlColor, "#%02x%02x%02x", $r, $g, $b);
                                $imgcolor[$i] = imagecolorallocate($thumb, $r, $g, $b);
                            }
                            $colorTexto = imagecolorallocate($thumb, 0, 0, 0);
                            // Mostrar el gráfico de pastel
                            if (!function_exists('displayGraph_pie')) {
                                function displayGraph_pie($thumb, $x, $y, $w, $h, $ydata, $G_ARR_COLOR, $colorTexto)
                                {
                                    $iTotal = array_sum($ydata);
                                    $iFraccion = 0;
                                    $etiquetas = array();
                                    for ($i = 0; $i < count($ydata); $i++) {
                                        if ($ydata[$i] >= $iTotal) {
                                            imagefilledellipse($thumb, $x, $y, $w, $h, $G_ARR_COLOR[$i]);
                                        } else {
                                            $degInicio = 360 - 45 - (int) (360.0 * ($iFraccion + $ydata[$i]) / $iTotal);
                                            $degFinal = 360 - 45 - (int) (360.0 * $iFraccion / $iTotal);
                                            imagefilledarc($thumb, $x, $y, $w, $h, $degInicio, $degFinal, $G_ARR_COLOR[$i], IMG_ARC_PIE);
                                        }
                                        $iFraccion += $ydata[$i];
                                        $degMitad = ($degInicio + $degFinal) / 2;
                                        $iPosTextoX = $x + 0.5 * ($w / 2.0) * cos(deg2rad($degMitad));
                                        $iPosTextoY = $y + 0.5 * ($h / 2.0) * sin(deg2rad($degMitad));
                                        $etiquetas[] = array($iPosTextoX, $iPosTextoY, sprintf('%.1f %%', 100.0 * $ydata[$i] / $iTotal));
                                    }
                                    /*
                                                            if (!is_null($colorTexto)) {
                                                                for ($i = 0; $i < count($ydata); $i++)
                                                                    imagestring($thumb, 5, $etiquetas[$i][0], $etiquetas[$i][1], $etiquetas[$i][2], $colorTexto);
                                                            }
                                    */
                                }
                            }
                            for ($i = (int) (60 * $escala); $i > 0; $i--) {
                                displayGraph_pie($thumb, $iPosCentroX, $iPosCentroY + $i, $iAnchoPastel, $iAltoPastel, $ydata, $imgcolor, NULL);
                            }
                            displayGraph_pie($thumb, $iPosCentroX, $iPosCentroY, $iAnchoPastel, $iAltoPastel, $ydata, $imgcolor, $colorTexto);
                            imagealphablending($thumb, true);
                            imagesavealpha($thumb, true);
                            $source2 = imagecreatefrompng("images/pie_alpha.png");
                            imagealphablending($source2, true);
                            imagecopyresampled($thumb, $source2, 0, 0, 0, 0, 290 * $escala, 294 * $escala, 290, 294);
                            header("Content-Type: image/png");
                            imagepng($thumb);
                        }
                    }
                    displayGraph_draw_pie3d($G_SIZE[0], $G_YDATAS[0], $G_ARR_COLOR);
                } else {
                    if ($G_TYPE == 'barplot') {
                        $graph = new Graph($G_SIZE[0], $G_SIZE[1], "auto");
                        if ($G_SHADOW) {
                            $graph->SetShadow();
                        }
                        $graph->SetScale($G_SCALE);
                        $graph->SetMarginColor($G_COLOR);
                        $graph->img->SetMargin($G_MARGIN[0], $G_MARGIN[1], $G_MARGIN[2], $G_MARGIN[3]);
                        $graph->title->Set($G_TITLE);
                        $graph->xaxis->title->Set($G_LABEL[0]);
                        $graph->xaxis->SetLabelFormatCallback("CallBack");
                        $graph->xaxis->SetLabelAngle(90);
                        //$graph->xaxis->SetTickLabels($xData);
                        $graph->yaxis->title->Set($G_LABEL[1]);
                        $graph->legend->SetFillColor("#fafafa");
                        $graph->legend->Pos($G_LEYEND_POS[0], $G_LEYEND_POS[1], "right", "center");
                        $graph->legend->SetColumns($G_LEYEND_NUM_COLUMN);
                        $arr_barplot = array();
                        foreach ($G_YDATAS as $num => $yDatas) {
                            $barplot = new BarPlot($yDatas);
                            $barplot->SetFillColor($G_ARR_COLOR[$num]);
                            $barplot->SetLegend($G_ARR_LEYEND[$num]);
                            $arr_barplot[] = $barplot;
                        }
                        $gbarplot = new GroupBarPlot($arr_barplot);
                        $gbarplot->SetWidth(0.6);
                        $graph->Add($gbarplot);
                        $graph->Stroke();
                    } else {
                        if ($G_TYPE == 'lineplot_multiaxis') {
                            $graph = new Graph($G_SIZE[0], $G_SIZE[1], "auto");
                            if ($G_SHADOW) {
                                $graph->SetShadow();
                            }
                            $inc = sizeof($G_YDATAS);
                            $graph->SetScale($G_SCALE);
                            $graph->SetFrame(true, '#999999');
                            $graph->title->Set($G_TITLE);
                            $graph->img->SetAntiAliasing();
                            $graph->xaxis->SetLabelFormatCallback("CallBack");
                            $graph->img->SetMargin($G_MARGIN[0], $G_MARGIN[1], $G_MARGIN[2], $G_MARGIN[3]);
                            $graph->SetMarginColor($G_COLOR);
                            $graph->legend->SetFillColor("#fafafa");
                            $graph->legend->Pos($G_LEYEND_POS[0], $G_LEYEND_POS[1], "right", "center");
                            $graph->xaxis->SetLabelAngle(90);
                            $graph->legend->SetColor("#444444", "#999999");
                            $graph->legend->SetShadow('gray@0.6', 4);
                            $graph->legend->SetColumns($G_LEYEND_NUM_COLUMN);
                            foreach ($G_YDATAS as $num => $yData) {
                                $lineplot = new LinePlot($yData);
                                $lineplot->SetWeight($G_WEIGHT);
                                $lineplot->SetLegend($G_ARR_LEYEND[$num]);
                                if ($G_ARR_STEP[$num] == true) {
                                    $lineplot->SetStepStyle();
                                }
                                if ($G_ARR_FILL_COLOR[$num] == true) {
                                    $lineplot->SetFillColor($G_ARR_COLOR[$num]);
                                }
                                if ($num == 0) {
                                    $lineplot->SetColor($G_ARR_COLOR[$num]);
                                    $graph->yaxis->SetColor($G_ARR_COLOR[$num]);
                                    $graph->Add($lineplot);
                                } else {
                                    $lineplot->SetColor($G_ARR_COLOR[$num]);
                                    $graph->SetYScale($num - 1, 'lin');
                                    $graph->ynaxis[$num - 1]->SetColor($G_ARR_COLOR[$num]);
                                    $graph->ynaxis[$num - 1]->SetPosAbsDelta($G_MARGIN[1] + 49 * ($num - 1));
                                    //mueve el eje Y
                                    $graph->AddY($num - 1, $lineplot);
                                }
                            }
                            if (sizeof($xData) > 100) {
                                //$graph->xaxis->SetTextLabelInterval( (int)(sizeof($xData)/8) );
                                $graph->xaxis->SetTextTickInterval((int) (sizeof($xData) / 10));
                                //$graph->xaxis->SetTextTickInterval( 9*(int)(log(sizeof($xData))-1) );
                            }
                            $graph->Stroke();
                        } else {
                            if ($G_TYPE == 'bar') {
                                $g = new CanvasGraph(91, 21, 'auto');
                                $g->SetMargin(0, 0, 0, 0);
                                $g->InitFrame();
                                $xmax = 20;
                                $ymax = 20;
                                $scale = new CanvasScale($g);
                                $scale->Set(0, $G_SIZE[0], 0, $G_SIZE[1]);
                                //DUBUJA LA BARRA
                                $alto = $G_SIZE[1];
                                $ancho = $G_SIZE[0];
                                $coor_x = 0;
                                $coor_y = 0;
                                $porcentage = $G_YDATAS[0];
                                $valor = 90 * (1 - $porcentage);
                                $g->img->Line($coor_x, $coor_y, $coor_x + $ancho, $coor_y);
                                $g->img->Line($coor_x, $coor_y, $coor_x, $coor_y + $alto);
                                $g->img->Line($coor_x + $ancho, $coor_y, $coor_x + $ancho, $coor_y + $alto);
                                $g->img->Line($coor_x, $coor_y + $alto, $coor_x + $ancho, $coor_y + $alto);
                                for ($i = 0; $i < $alto; $i++) {
                                    $g->img->SetColor(array(95 - 3 * $i, 138 - 3 * $i, 203 - 3 * $i));
                                    //para hacerlo 3D, degradacion
                                    $g->img->Line($coor_x, $coor_y + $i + 1, $coor_x + $ancho - $valor - 1, $coor_y + $i + 1);
                                }
                                $g->Stroke();
                            } else {
                                if ($G_TYPE == 'gauge') {
                                    if (!function_exists('displayGraph_draw_gauge')) {
                                        function displayGraph_draw_gauge($canvasx, $percent)
                                        {
                                            $escala = $canvasx / 320.0;
                                            $thumb = imagecreatetruecolor($canvasx * 284 / 320, $canvasx * 284 / 320);
                                            if ($percent > 100) {
                                                $percent = 100.0;
                                            }
                                            if ($percent < 0) {
                                                $percent = 0.0;
                                            }
                                            $angle = -135.0 + 270 * $percent / 100.0;
                                            // COLORES
                                            $blanco = imagecolorallocate($thumb, 255, 255, 255);
                                            $dred = imagecolorallocate($thumb, 180, 0, 0);
                                            $lred = imagecolorallocate($thumb, 100, 0, 0);
                                            $transparent = imagecolorallocatealpha($thumb, 200, 200, 200, 127);
                                            imagefill($thumb, 0, 0, $transparent);
                                            imagealphablending($thumb, true);
                                            imagesavealpha($thumb, true);
                                            $source = imagecreatefrompng("images/gauge_base.png");
                                            imagealphablending($source, true);
                                            imagecopyresampled($thumb, $source, 0, 0, 0, 0, 285 * $escala, 285 * $escala, 285, 285);
                                            $radius = 100 * $escala;
                                            $radius_min = 12 * $escala;
                                            $centrox = 142 * $escala;
                                            $centroy = 141 * $escala;
                                            $x1 = $centrox + sin(deg2rad($angle)) * $radius;
                                            // x coord farest
                                            $x2 = $centrox + sin(deg2rad($angle - 90)) * $radius_min;
                                            $x3 = $centrox + sin(deg2rad($angle + 90)) * $radius_min;
                                            $y1 = $centroy - cos(deg2rad($angle)) * $radius;
                                            $y2 = $centroy - cos(deg2rad($angle - 90)) * $radius_min;
                                            $y3 = $centroy - cos(deg2rad($angle + 90)) * $radius_min;
                                            $arrTriangle1 = array($centrox, $centroy, $x1, $y1, $x2, $y2);
                                            $arrTriangle2 = array($centrox, $centroy, $x1, $y1, $x3, $y3);
                                            imagefilledpolygon($thumb, $arrTriangle1, 3, $lred);
                                            imagefilledpolygon($thumb, $arrTriangle2, 3, $dred);
                                            $source2 = imagecreatefrompng("images/gauge_center.png");
                                            imagealphablending($source2, true);
                                            imagecopyresampled($thumb, $source2, 121 * $escala, 120 * $escala, 0, 0, 44 * $escala, 44 * $escala, 44, 44);
                                            header("Content-Type: image/png");
                                            imagepng($thumb);
                                        }
                                    }
                                    displayGraph_draw_gauge($G_SIZE[0], $G_YDATAS[0] * 100.0);
                                } else {
                                    if ($G_TYPE == 'bar2') {
                                        $alto = 20;
                                        $ancho = 90;
                                        $coor_x = 100;
                                        $coor_y = 10;
                                        $porcentage = 0.67;
                                        $valor = 90 * (1 - $porcentage);
                                        $g = new CanvasGraph($G_LEN_X, 40, 'auto');
                                        $g->SetMargin(1, 1, 31, 9);
                                        $g->SetMarginColor('#fafafa');
                                        $g->SetColor(array(250, 250, 250));
                                        $g->InitFrame();
                                        $xmax = 20;
                                        $ymax = 20;
                                        $scale = new CanvasScale($g);
                                        $scale->Set(0, $G_LEN_X, 0, $G_LEN_Y);
                                        //DUBUJA LA BARRA
                                        $g->img->Line($coor_x, $coor_y, $coor_x + $ancho, $coor_y);
                                        $g->img->Line($coor_x, $coor_y, $coor_x, $coor_y + $alto);
                                        $g->img->Line($coor_x + $ancho, $coor_y, $coor_x + $ancho, $coor_y + $alto);
                                        $g->img->Line($coor_x, $coor_y + $alto, $coor_x + $ancho, $coor_y + $alto);
                                        for ($i = 0; $i < $alto; $i++) {
                                            $g->img->SetColor(array(95 - 4 * $i, 138 - 4 * $i, 203 - 4 * $i));
                                            //para hacerlo 3D, degradacion
                                            $g->img->Line($coor_x, $coor_y + $i, $coor_x + $ancho - $valor - 1, $coor_y + $i);
                                        }
                                        //AGREGA LABEL 1
                                        $txt = "Uso de CPU";
                                        $t = new Text($txt, 10, 12);
                                        $t->font_style = FS_BOLD;
                                        $t->Stroke($g->img);
                                        //AGREGA LABEL 2
                                        $txt = "67.64% used of 2,200.00 MHz";
                                        $t = new Text($txt, 200, 12);
                                        $t->font_style = FS_BOLD;
                                        $t->Stroke($g->img);
                                        $g->Stroke();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
        showError('nothing', $G_SIZE, $G_TITLE);
    }
}
Exemplo n.º 29
0
 /**
  * Build a JpGraph barPlot object with retrived data.
  *
  * @return BarPlot
  */
 private function displayRepositoryPushesByWeek()
 {
     $nbRepo = count($this->repoList);
     $colors = array_slice($GLOBALS['HTML']->getChartColors(), 0, $nbRepo);
     $nbColors = count($colors);
     $i = 0;
     $bplot = array();
     foreach ($this->repoList as $repository) {
         $this->legend = null;
         $pushes = $this->getRepositoryPushesByWeek($repository);
         if ($this->displayChart) {
             $b2plot = new BarPlot($pushes);
             $color = $colors[$i++ % $nbColors];
             $b2plot->SetColor($color . ':0.7');
             $b2plot->setFillColor($color);
             if (!empty($this->legend)) {
                 $b2plot->SetLegend($this->legend);
             }
             $bplot[] = $b2plot;
         }
     }
     return $bplot;
 }
Exemplo n.º 30
0
 $dateLocale = new DateLocale();
 // Create the graph. These two calls are always required
 $graph = new Graph(400, 200);
 $graph->SetScale("textlin");
 $graph->SetShadow();
 $graph->img->SetMargin(50, 30, 30, 55);
 // Create the bar plots
 $b1plot = new BarPlot($y1);
 $b1plot->SetFillColor("chartreuse3");
 $b2plot = new BarPlot($y2);
 $b2plot->SetFillColor("chocolate2");
 // Set the legends for the plots
 $fn = tr('found');
 $dnf = tr('not_found');
 $b1plot->SetLegend($fn);
 $b2plot->SetLegend($dnf);
 // Adjust the legend position
 $graph->legend->SetLayout(LEGEND_HOR);
 $graph->legend->Pos(0.5, 0.9399999999999999, "center", "bottom");
 $graph->legend->SetLineWeight(8);
 // Create the grouped bar plot
 $gbplot = new GroupBarPlot(array($b1plot, $b2plot));
 // ...and add it to the graPH
 $graph->Add($gbplot);
 $le = "";
 $graph->title->Set($describe);
 $graph->xaxis->title->Set($xtitle);
 $graph->yaxis->title->Set($le);
 $graph->title->SetFont(FF_ARIAL, FS_NORMAL);
 $graph->yaxis->title->SetFont(FF_COURIER, FS_BOLD);
 $graph->xaxis->title->SetFont(FF_COURIER, FS_BOLD);