/**
  * @return Chart
  */
 public function buildGraph()
 {
     require_once 'common/chart/Chart.class.php';
     if ($this->error == NULL) {
         if ($this->width == 0) {
             $this->width = count($this->data) * self::WIDTH_PER_POINT + self::MARGIN;
         }
         if ($this->scale == GraphOnTrackersV5_Chart_CumulativeFlow::SCALE_DAY) {
             foreach ($this->data as $date => $label) {
                 $dates[] = date('M-d', $date);
             }
         } else {
             foreach ($this->data as $date => $label) {
                 $dates[] = date('M-Y', $date);
             }
         }
         $this->graph = new Chart($this->width, $this->height);
         $colors = $this->getColors();
         $this->graph->SetScale("datlin");
         $this->graph->title->Set($this->title);
         $this->graph->xaxis->SetTickLabels($dates);
         $this->graph->yaxis->scale->SetAutoMin(0);
         if (is_null($this->description)) {
             $this->description = "";
         }
         $this->graph->subtitle->Set($this->description);
         $this->keys = array_keys($this->data[$this->start_date]);
         $this->nbOpt = count($this->keys);
         $this->stackDataCount();
         $this->graph->ygrid->SetFill(true, '#F3FFFF@0.5', '#FFFFFF@0.5');
         for ($i = $this->nbOpt - 1; $i >= 0; $i--) {
             $lineData = array();
             foreach ($this->data as $data => $row) {
                 $lineData[] = $row[$this->keys[$i]];
             }
             $line = new LinePlot($lineData);
             $line->SetFillColor($colors[$this->keys[$i]]);
             $line->SetColor('#000');
             $line->SetLegend($this->keys[$i]);
             $this->graph->Add($line);
         }
         try {
             $legend_line_height = 20;
             $graph_margin_bottom = 70;
             $margin_size = $this->nbOpt * $legend_line_height + $graph_margin_bottom;
             $this->graph->img->SetMargin(70, 30, 30, $margin_size);
         } catch (Exception $e) {
             // do nothing, JPGraph displays the error by itself
         }
         $this->graph->legend->SetAbsPos(0, $this->height, 'left', 'bottom');
     } else {
         $this->graph = $this->error;
     }
     return $this->graph;
 }
Exemplo n.º 2
0
 public function renderGraph()
 {
     require_once 'libs/jpgraph/jpgraph.php';
     require_once 'libs/jpgraph/jpgraph_bar.php';
     require_once 'libs/jpgraph/jpgraph_line.php';
     $graph = new Graph(300, 200, 'auto');
     $graph->SetMarginColor('white');
     $graph->SetFrame(false);
     $graph->SetScale("textlin");
     $graph->SetY2Scale("lin");
     $graph->img->SetMargin(0, 30, 20, 65);
     $graph->yaxis->HideLabels();
     $graph->yaxis->HideTicks();
     $graph->yaxis->scale->SetGrace(20);
     $graph->y2axis->SetColor("black", "red");
     $graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
     $labelsy = array();
     $datay = array();
     $datay2 = array();
     switch ($this->_controllerAction->getRequest()->getParam('type')) {
         case 'year':
             $this->_populateYearData($labelsy, $datay, $datay2);
             break;
         default:
             $this->_populateWeekData($labelsy, $datay, $datay2);
     }
     $graph->xaxis->SetTickLabels($labelsy);
     $locale = Zend_Registry::get('Zend_Locale');
     if ($locale == 'ja') {
         // the ttf file for FF_MINCHO is already encoded in utf-8
         $legend1 = $this->view->translate('Trusted sites');
         $legend2 = $this->view->translate('Sites per user');
     } else {
         // default ttf files are latin-1 encoded
         $legend1 = utf8_decode($this->view->translate('Trusted sites'));
         $legend2 = utf8_decode($this->view->translate('Sites per user'));
     }
     $bplot = new BarPlot($datay);
     $bplot->setLegend($legend1);
     $bplot->SetFillGradient("navy", "lightsteelblue", GRAD_WIDE_MIDVER);
     $bplot->value->Show();
     $bplot->value->SetFormat('%d');
     $p1 = new LinePlot($datay2);
     $p1->SetColor("red");
     $p1->SetLegend($legend2);
     $graph->Add($bplot);
     $graph->AddY2($p1);
     $graph->legend->SetLayout(LEGEND_HOR);
     if ($locale == 'ja') {
         $graph->legend->setFont(FF_MINCHO, FS_NORMAL);
     }
     $graph->legend->Pos(0.5, 0.99, "center", "bottom");
     $graph->Stroke();
 }
function LineGraph($w, $h, $title, $data1, $data2, $datax, $output)
{
    // Create the graph. These two calls are always required
    $graph = new Graph($w, $h, "auto");
    $graph->SetScale("textlin");
    $graph->SetMarginColor('white');
    $graph->SetFrame(true);
    // Adjust the margin
    $graph->img->SetMargin(40, 100, 20, 40);
    $graph->SetShadow(false);
    // Create the linear plot
    $lineplot = new LinePlot($data1);
    $lineplot->SetWeight(2);
    $lineplot->SetColor("blue");
    $lineplot->mark->SetType(MARK_DIAMOND);
    $lineplot->mark->SetWidth(5);
    $lineplot->mark->SetFillColor('blue');
    $lineplot->value->SetMargin(-20);
    $lineplot->value->show();
    $lineplot->value->SetColor('blue');
    $lineplot->value->SetFormat('%0.0f');
    $lineplot->SetLegend($_SESSION[Tahun1]);
    $lineplot2 = new LinePlot($data2);
    $lineplot2->SetColor("green");
    $lineplot2->SetWeight(2);
    $lineplot2->mark->SetType(MARK_FILLEDCIRCLE);
    $lineplot2->mark->SetWidth(3);
    $lineplot2->mark->SetFillColor('green');
    $lineplot2->value->show();
    $lineplot2->value->SetColor('darkgreen');
    $lineplot2->value->SetFormat('%0.0f');
    $lineplot2->SetLegend($_SESSION[Tahun2]);
    // Add the plot to the graph
    $graph->Add($lineplot);
    $graph->xaxis->SetTickLabels($datax);
    $graph->title->Set($title);
    $graph->xaxis->title->Set("");
    $graph->yaxis->title->Set("");
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->Add($lineplot2);
    $graph->legend->SetShadow(false);
    $graph->legend->SetFillColor('white');
    $graph->legend->SetPos(0.01, 0.88, 'right', 'center');
    // Display the graph
    $graph->Stroke($output);
}
Exemplo n.º 4
0
function draw_bmi($actual, $graph_details)
{
    $arr_bmi_bound = get_bmi_bound();
    $arr_xlabel = $_SESSION["consult_date"];
    $arr_under = $arr_bmi_bound["Underweight"];
    $arr_normal = $arr_bmi_bound["Normal"];
    $arr_over = $arr_bmi_bound["Overweight"];
    $arr_obese = $arr_bmi_bound["Obese"];
    $w = 400;
    $h = 300;
    $graph = new Graph($w, $h);
    $graph->SetScale('intlin', 0, 50);
    $graph->SetMargin(40, 40, 40, 60);
    $graph->title->Set($graph_details[0] . ' of ' . get_px_name());
    $graph->xaxis->title->Set($graph_details[1]);
    $graph->yaxis->title->Set($graph_details[2]);
    $graph->xaxis->SetTickLabels($arr_xlabel);
    $lineplot = new LinePlot($actual);
    $lineplot->SetColor('blue');
    $lineplot->SetWeight(2);
    $lineplot->value->Show();
    $bmi_under = new LinePlot($arr_under);
    $bmi_under->SetColor('yellow');
    $bmi_under->SetWeight(3);
    $bmi_normal = new LinePlot($arr_normal);
    $bmi_normal->SetColor('green');
    $bmi_normal->SetWeight(3);
    $bmi_over = new LinePlot($arr_over);
    $bmi_over->SetColor('red');
    $bmi_over->SetWeight(3);
    $lineplot->SetLegend('Actual BMI');
    $bmi_under->SetLegend('Normal');
    $bmi_normal->SetLegend('Overweight');
    $bmi_over->SetLegend('Obese');
    $graph->legend->SetLayout(LEGEND_HOR);
    $graph->legend->Pos(0.5, 0.99, 'center', 'bottom');
    $graph->Add($bmi_under);
    $graph->Add($bmi_normal);
    $graph->Add($bmi_over);
    $graph->Add($lineplot);
    $graph->Stroke();
}
Exemplo n.º 5
0
Arquivo: image.php Projeto: ztobs/wsf
function draw_graph($datay, $data2y, $label_x)
{
    include_once "src/jpgraph.php";
    include_once "src/jpgraph_line.php";
    // A nice graph with anti-aliasing
    $graph = new Graph(800, 600, "auto");
    $graph->img->SetMargin(40, 180, 40, 40);
    $graph->img->SetAntiAliasing("white");
    $graph->SetScale("textlin");
    $graph->SetShadow();
    $graph->title->Set("Nodes and Comment Count By Duration");
    $graph->xaxis->SetTickLabels($label_x);
    // Use built in font
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    // Slightly adjust the legend from it's default position in the
    // top right corner.
    $graph->legend->Pos(0.05, 0.5, "right", "center");
    // Create the first line
    if ($datay) {
        $p1 = new LinePlot($datay);
        $p1->mark->SetType(MARK_FILLEDCIRCLE);
        $p1->mark->SetFillColor("blue");
        $p1->mark->SetWidth(4);
        $p1->SetColor("blue");
        $p1->SetCenter();
        $p1->SetLegend("Nodes Count");
        $graph->Add($p1);
    }
    // ... and the second
    if ($data2y) {
        $p2 = new LinePlot($data2y);
        $p2->mark->SetType(MARK_STAR);
        $p2->mark->SetFillColor("red");
        $p2->mark->SetWidth(4);
        $p2->SetColor("red");
        $p2->SetCenter();
        $p2->SetLegend("Comments Count");
        $graph->Add($p2);
    }
    // Output line
    $graph->Stroke();
}
Exemplo n.º 6
0
 /**
  * @return Chart
  */
 public function buildGraph()
 {
     $graph = new Chart($this->width, $this->height);
     $graph->SetScale("datlin");
     $graph->title->Set($this->title);
     $graph->subtitle->Set($this->description);
     $colors = $graph->getThemedColors();
     $graph->xaxis->SetTickLabels($this->burndown_data->getHumanReadableDates());
     $remaining_effort = new LinePlot($this->burndown_data->getRemainingEffort());
     $remaining_effort->SetColor($colors[1] . ':0.7');
     $remaining_effort->SetWeight(2);
     $remaining_effort->SetLegend('Remaining effort');
     $remaining_effort->mark->SetType(MARK_FILLEDCIRCLE);
     $remaining_effort->mark->SetColor($colors[1] . ':0.7');
     $remaining_effort->mark->SetFillColor($colors[1]);
     $remaining_effort->mark->SetSize(3);
     $graph->Add($remaining_effort);
     $ideal_burndown = new LinePlot($this->burndown_data->getIdealEffort());
     $ideal_burndown->SetColor($colors[0] . ':1.25');
     $ideal_burndown->SetLegend('Ideal Burndown');
     $graph->Add($ideal_burndown);
     return $graph;
 }
Exemplo n.º 7
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_date.php';
// Create a data set in range (50,70) and X-positions
DEFINE('NDATAPOINTS', 360);
DEFINE('SAMPLERATE', 240);
$start = time();
$end = $start + NDATAPOINTS * SAMPLERATE;
$data = array();
$xdata = array();
for ($i = 0; $i < NDATAPOINTS; ++$i) {
    $data[$i] = rand(50, 70);
    $xdata[$i] = $start + $i * SAMPLERATE;
}
// Create the new graph
$graph = new Graph(540, 300);
// Slightly larger than normal margins at the bottom to have room for
// the x-axis labels
$graph->SetMargin(40, 40, 30, 130);
// Fix the Y-scale to go between [0,100] and use date for the x-axis
$graph->SetScale('datlin', 0, 100);
$graph->title->Set("Example on Date scale");
// Set the angle for the labels to 90 degrees
$graph->xaxis->SetLabelAngle(90);
$line = new LinePlot($data, $xdata);
$line->SetLegend('Year 2005');
$line->SetFillColor('lightblue@0.5');
$graph->Add($line);
$graph->Stroke();
Exemplo n.º 8
0
<?php

include "../jpgraph.php";
include "../jpgraph_line.php";
$ydata = array(12, 17, 22, 19, 5, 15);
$graph = new Graph(270, 170);
$graph->SetMargin(30, 90, 30, 30);
$graph->SetScale("textlin");
$graph->img->SetAngle(90);
$graph->img->SetCenter(floor(270 / 2), floor(170 / 2));
$line = new LinePlot($ydata);
$line->SetLegend('2002');
$line->SetColor('darkred');
$line->SetWeight(2);
$graph->Add($line);
// Output graph
$graph->Stroke();
?>


Exemplo n.º 9
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.º 10
0
$graph->SetMargin(75, 30, 30, 45);
$graph->legend->SetFont(FF_FONT1, FS_NORMAL);
$lineplot = new LinePlot($tot_data, $ticks);
$lineplot->SetLegend('Traffic total');
$lineplot->SetColor('#d5d5d5');
$lineplot->SetFillColor('#d5d5d5@0.5');
// $lineplot2 = new LinePlot($tot_data_inv, $ticks);
// $lineplot2->SetColor("#d5d5d5");
// $lineplot2->SetFillColor("#d5d5d5@0.5");
$lineplot_in = new LinePlot($in_data, $ticks);
$lineplot_in->SetLegend('Traffic In');
$lineplot_in->SetColor('darkgreen');
$lineplot_in->SetFillColor('lightgreen@0.4');
$lineplot_in->SetWeight(1);
$lineplot_out = new LinePlot($out_data_inv, $ticks);
$lineplot_out->SetLegend('Traffic Out');
$lineplot_out->SetColor('darkblue');
$lineplot_out->SetFillColor('lightblue@0.4');
$lineplot_out->SetWeight(1);
if ($_GET['95th']) {
    $lineplot_95th = new LinePlot($per_data, $ticks);
    $lineplot_95th->SetColor('red');
}
if ($_GET['ave']) {
    $lineplot_ave = new LinePlot($ave_data, $ticks);
    $lineplot_ave->SetColor('red');
}
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.52, 0.9, 'center');
$graph->Add($lineplot);
// $graph->Add($lineplot2);
Exemplo n.º 11
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.º 12
0
function graph_cumulative_bydate($p_metrics, $p_graph_width = 300, $p_graph_height = 380)
{
    $t_graph_font = graph_get_font();
    error_check(is_array($p_metrics) ? count($p_metrics) : 0, plugin_lang_get('cumulative') . ' ' . lang_get('by_date'));
    if (plugin_config_get('eczlibrary') == ON) {
        $graph = new ezcGraphLineChart();
        $graph->background->color = '#FFFFFF';
        $graph->xAxis = new ezcGraphChartElementNumericAxis();
        $graph->data[0] = new ezcGraphArrayDataSet($p_metrics[0]);
        $graph->data[0]->label = plugin_lang_get('legend_reported');
        $graph->data[0]->color = '#FF0000';
        $graph->data[1] = new ezcGraphArrayDataSet($p_metrics[1]);
        $graph->data[1]->label = plugin_lang_get('legend_resolved');
        $graph->data[1]->color = '#0000FF';
        $graph->data[2] = new ezcGraphArrayDataSet($p_metrics[2]);
        $graph->data[2]->label = plugin_lang_get('legend_still_open');
        $graph->data[2]->color = '#000000';
        $graph->additionalAxis[2] = $nAxis = new ezcGraphChartElementNumericAxis();
        $nAxis->chartPosition = 1;
        $nAxis->background = '#005500';
        $nAxis->border = '#005500';
        $nAxis->position = ezcGraph::BOTTOM;
        $graph->data[2]->yAxis = $nAxis;
        $graph->xAxis->labelCallback = 'graph_date_format';
        $graph->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedLabelRenderer();
        $graph->xAxis->axisLabelRenderer->angle = -45;
        $graph->legend->position = ezcGraph::BOTTOM;
        $graph->legend->background = '#FFFFFF80';
        $graph->driver = new ezcGraphGdDriver();
        //$graph->driver->options->supersampling = 1;
        $graph->driver->options->jpegQuality = 100;
        $graph->driver->options->imageFormat = IMG_JPEG;
        $graph->title = plugin_lang_get('cumulative') . ' ' . lang_get('by_date');
        $graph->options->font = $t_graph_font;
        $graph->renderToOutput($p_graph_width, $p_graph_height);
    } else {
        foreach ($p_metrics[0] as $i => $vals) {
            if ($i > 0) {
                $plot_date[] = $i;
                $reported_plot[] = $p_metrics[0][$i];
                $resolved_plot[] = $p_metrics[1][$i];
                $still_open_plot[] = $p_metrics[2][$i];
            }
        }
        $graph = new Graph($p_graph_width, $p_graph_height);
        $graph->img->SetMargin(40, 40, 40, 170);
        if (ON == plugin_config_get('jpgraph_antialias')) {
            $graph->img->SetAntiAliasing();
        }
        $graph->SetScale('linlin');
        $graph->yaxis->SetColor("red");
        $graph->SetY2Scale("lin");
        $graph->SetMarginColor('white');
        $graph->SetFrame(false);
        $graph->title->Set(plugin_lang_get('cumulative') . ' ' . lang_get('by_date'));
        $graph->title->SetFont($t_graph_font, FS_BOLD);
        $graph->legend->Pos(0.05, 0.9, 'right', 'bottom');
        $graph->legend->SetShadow(false);
        $graph->legend->SetFillColor('white');
        $graph->legend->SetLayout(LEGEND_HOR);
        $graph->legend->SetFont($t_graph_font);
        $graph->yaxis->scale->ticks->SetDirection(-1);
        $graph->yaxis->SetFont($t_graph_font);
        $graph->y2axis->SetFont($t_graph_font);
        if (FF_FONT2 <= $t_graph_font) {
            $graph->xaxis->SetLabelAngle(60);
        } else {
            $graph->xaxis->SetLabelAngle(90);
            # can't rotate non truetype fonts
        }
        $graph->xaxis->SetLabelFormatCallback('graph_date_format');
        $graph->xaxis->SetFont($t_graph_font);
        $p1 = new LinePlot($reported_plot, $plot_date);
        $p1->SetColor('blue');
        $p1->SetCenter();
        $p1->SetLegend(plugin_lang_get('legend_reported'));
        $graph->AddY2($p1);
        $p3 = new LinePlot($still_open_plot, $plot_date);
        $p3->SetColor('red');
        $p3->SetCenter();
        $p3->SetLegend(plugin_lang_get('legend_still_open'));
        $graph->Add($p3);
        $p2 = new LinePlot($resolved_plot, $plot_date);
        $p2->SetColor('black');
        $p2->SetCenter();
        $p2->SetLegend(plugin_lang_get('legend_resolved'));
        $graph->AddY2($p2);
        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.º 13
0
$lineplot2->SetWeight(1);
// SET LINE THICKNESS
if ($xmarks == 1) {
    $lineplot2->mark->SetType(MARK_X, 0.3);
    // POINTS STYLE
    $lineplot2->mark->SetColor("red");
    // POINTS COLOUR
    $lineplot2->mark->Show();
    // SET THEM TO DISPLAY
}
$lineplot3->SetColor("blue");
// LINE COLOUR
$lineplot3->SetWeight(1);
// SET LINE THICKNESS
if ($xmarks == 1) {
    $lineplot3->mark->SetType(MARK_X, 0.3);
    // POINTS STYLE
    $lineplot3->mark->SetColor("blue");
    // POINTS COLOUR
    $lineplot3->mark->Show();
    // SET THEM TO DISPLAY
}
$lineplot->SetLegend("Light");
$lineplot2->SetLegend("Exp. Temp");
$lineplot3->SetLegend("Shl. Temp");
// Add the plot to the graph
$graph->Add($lineplot);
$graph->AddY2($lineplot2);
$graph->AddY2($lineplot3);
// Display the graph
$graph->Stroke();
Exemplo n.º 14
0
    $lineplot2->SetColor("blue");
    $lineplot2->SetLegend($labels["NSTL10"]);
    $lineplot2->SetWeight(2);
    $graph->Add($lineplot2);
}
// Create the linear plot
if (sizeof($data["NSTLNSPR"]) > 1) {
    $lineplot3 = new LinePlot($data["NSTLNSPR"], $times["NSTLNSPR"]);
    $lineplot3->SetColor("black");
    $lineplot3->SetLegend($labels["NSTLNSPR"]);
    $lineplot3->SetWeight(2);
    $graph->Add($lineplot3);
}
// Create the linear plot
if (sizeof($data["NSTL30FT"]) > 1) {
    $lineplot4 = new LinePlot($data["NSTL30FT"], $times["NSTL30FT"]);
    $lineplot4->SetColor("green");
    $lineplot4->SetLegend($labels["NSTL30FT"]);
    $lineplot4->SetWeight(2);
    $graph->Add($lineplot4);
}
// Create the linear plot
if (sizeof($data["NSTL110"]) > 1) {
    $lineplot5 = new LinePlot($data["NSTL110"], $times["NSTL110"]);
    $lineplot5->SetColor("brown");
    $lineplot5->SetLegend($labels["NSTL110"]);
    $lineplot5->SetWeight(2);
    $graph->Add($lineplot5);
}
// Display the graph
$graph->Stroke();
//$Threads_running[] = $rs_a[$i]['Threads_running'];
//Threads_cached
$p1 = new LinePlot($Threads_cached);
$p1->SetColor("blue");
$p1->SetCenter();
$p1->SetLegend("Cached AVG:{$Threads_cached_avg}");
$graph->Add($p1);
//Threads_connected
$p2 = new LinePlot($Threads_connected);
$p2->SetColor("red");
$p2->SetCenter();
$p2->SetLegend("Connected AVG:{$Threads_connected_avg}");
$graph->Add($p2);
//Threads_connected
//$p3 = new LinePlot($Threads_created);
//$p3->SetColor("orange");
//$p3->SetCenter();
//$p3->SetLegend("Threads_created AVG:$Threads_created_avg");
//$graph->Add($p3);
//Threads_connected
$p4 = new LinePlot($Threads_running);
$p4->SetColor("green");
$p4->SetCenter();
$p4->SetLegend("Running AVG:{$Threads_running_avg}");
$graph->Add($p4);
// Output line
$graph->Stroke();
?>


Exemplo n.º 16
0
//$graph->ynaxis[1]->SetFont(FF_FONT1,FS_BOLD);
//$graph->ynaxis[1]->scale->ticks->Set(0.01,0.005);
$graph->ynaxis[1]->SetTitle("Pressure");
$graph->ynaxis[1]->title->SetFont(FF_FONT1, FS_BOLD, 12);
$graph->ynaxis[1]->SetTitleMargin(45);
$graph->ynaxis[1]->SetColor("black", "black");
$graph->ynaxis[1]->SetLabelFormat('%0.3f');
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.01, 0.05);
$graph->legend->SetFont(FF_FONT1, FS_BOLD, 14);
// Create the linear plot
$lineplot = new LinePlot($mph, $times);
$lineplot->SetLegend("Instant Wind Speed");
$lineplot->SetColor("red");
$lineplot2 = new LinePlot($alti, $times);
$lineplot2->SetLegend("Pressure");
$lineplot2->SetColor("black");
//if ($hasgust == 1){
// Create the linear plot
//  $lp1=new LinePlot($gust);
//  $lp1->SetLegend("Peak Wind Gust");
//  $lp1->SetColor("black");
//}
// Create the linear plot
$sp1 = new ScatterPlot($drct, $times);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
$sp1->mark->SetFillColor("blue");
$sp1->mark->SetWidth(3);
$sp1->SetLegend("Wind Direction");
$graph->Add($sp1);
$graph->AddY(0, $lineplot);
Exemplo n.º 17
0
function draw_usage()
{
    $w = 400;
    $h = 300;
    $graph = new Graph($w, $h);
    $graph->SetScale('intlin', 0, 50);
    $graph->SetMargin(40, 40, 40, 60);
    $graph->title->Set('Data Usage');
    $graph->xaxis->title->Set('User');
    $graph->yaxis->title->Set('Usage');
    $graph->xaxis->SetTickLabels(array('1', '2', '3'));
    $lineplot = new LinePlot(array('10', '12', '14'));
    $lineplot->SetColor('blue');
    $lineplot->SetWeight(2);
    $lineplot->value->Show();
    $bmi_under = new LinePlot(array('15', '25', '30'));
    $bmi_under->SetColor('yellow');
    $bmi_under->SetWeight(3);
    $bmi_normal = new LinePlot(array('15', '25', '30'));
    $bmi_normal->SetColor('green');
    $bmi_normal->SetWeight(3);
    $bmi_over = new LinePlot(array('10', '40', '45'));
    $bmi_over->SetColor('red');
    $bmi_over->SetWeight(3);
    $lineplot->SetLegend('Actual BMI');
    $bmi_under->SetLegend('Normal');
    $bmi_normal->SetLegend('Overweight');
    $bmi_over->SetLegend('Obese');
    $graph->legend->SetLayout(LEGEND_HOR);
    $graph->legend->Pos(0.5, 0.99, 'center', 'bottom');
    $graph->Add($bmi_under);
    $graph->Add($bmi_normal);
    $graph->Add($bmi_over);
    $graph->Add($lineplot);
    $graph->Stroke();
}
Exemplo n.º 18
0
// 载入jpgraph内库文件
require_once './jpgraph-3.5.0b1/src/jpgraph.php';
require_once './jpgraph-3.5.0b1/src/jpgraph_line.php';
// 获取graph对象,填写画布宽高
$graph = new Graph(400, 400);
// 设置X和Y轴样式
$graph->SetScale("textint");
// 设置图像标题
$graph->title->SetFont(FF_CHINESE);
$graph->title->Set('This is jasongjiang Test');
// 设置数据
$data = array(0 => 21, 1 => 21, 2 => 45, 3 => 88, 4 => 55);
// 得到实例
$linePlot = new LinePlot($data);
$linePlot->SetLegend('测试中文');
// 将曲线加入到画布中
$graph->Add($linePlot);
// 修改线条颜色
$linePlot->SetColor('red');
$AT = $graph->stroke();
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title><?php 
?>
</title>
</head>
<body>
Exemplo n.º 19
0
function graph_cumulative_bydate($p_metrics, $p_graph_width = 300, $p_graph_height = 380)
{
    $t_graph_font = graph_get_font();
    error_check(is_array($p_metrics) ? count($p_metrics) : 0, lang_get('cumulative') . ' ' . lang_get('by_date'));
    foreach ($p_metrics as $i => $vals) {
        if ($i > 0) {
            $plot_date[] = $i;
            $reported_plot[] = $p_metrics[$i][0];
            $resolved_plot[] = $p_metrics[$i][1];
            $still_open_plot[] = $p_metrics[$i][2];
        }
    }
    $graph = new Graph($p_graph_width, $p_graph_height);
    $graph->img->SetMargin(40, 40, 40, 170);
    if (ON == config_get_global('jpgraph_antialias')) {
        $graph->img->SetAntiAliasing();
    }
    $graph->SetScale('linlin');
    $graph->SetMarginColor('white');
    $graph->SetFrame(false);
    $graph->title->Set(lang_get('cumulative') . ' ' . lang_get('by_date'));
    $graph->title->SetFont($t_graph_font, FS_BOLD);
    $graph->legend->Pos(0.05, 0.9, 'right', 'bottom');
    $graph->legend->SetShadow(false);
    $graph->legend->SetFillColor('white');
    $graph->legend->SetLayout(LEGEND_HOR);
    $graph->legend->SetFont($t_graph_font);
    $graph->yaxis->scale->ticks->SetDirection(-1);
    $graph->yaxis->SetFont($t_graph_font);
    if (FF_FONT2 <= $t_graph_font) {
        $graph->xaxis->SetLabelAngle(60);
    } else {
        $graph->xaxis->SetLabelAngle(90);
        # can't rotate non truetype fonts
    }
    $graph->xaxis->SetLabelFormatCallback('graph_date_format');
    $graph->xaxis->SetFont($t_graph_font);
    $p1 = new LinePlot($reported_plot, $plot_date);
    $p1->SetColor('blue');
    $p1->SetCenter();
    $p1->SetLegend(lang_get('legend_reported'));
    $graph->Add($p1);
    $p3 = new LinePlot($still_open_plot, $plot_date);
    $p3->SetColor('red');
    $p3->SetCenter();
    $p3->SetLegend(lang_get('legend_still_open'));
    $graph->Add($p3);
    $p2 = new LinePlot($resolved_plot, $plot_date);
    $p2->SetColor('black');
    $p2->SetCenter();
    $p2->SetLegend(lang_get('legend_resolved'));
    $graph->Add($p2);
    if (helper_show_queries()) {
        $graph->subtitle->Set(db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique) (' . db_time_queries() . 'sec)');
        $graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8);
    }
    $graph->Stroke();
}
Exemplo n.º 20
0
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
$y2data = array(354, 200, 265, 99, 111, 91, 198, 225, 293, 251);
// Create the graph and specify the scale for both Y-axis
$graph = new Graph(300, 240, "auto");
$graph->SetScale("textlin");
$graph->SetShadow();
// Adjust the margin
$graph->img->SetMargin(40, 40, 20, 70);
// Create the two linear plot
$lineplot = new LinePlot($ydata);
$lineplot->SetStepStyle();
// Adjust the axis color
$graph->yaxis->SetColor("blue");
$graph->title->Set("Example 6.2");
$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);
// Set the colors for the plots
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
// Set the legends for the plots
$lineplot->SetLegend("Plot 1");
// Add the plot to the graph
$graph->Add($lineplot);
// Adjust the legend position
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.4, 0.95, "center", "bottom");
// Display the graph
$graph->Stroke();
Exemplo n.º 21
0
$graph->SetMargin(75, 30, 30, 45);
$graph->legend->SetFont(FF_FONT1, FS_NORMAL);
$lineplot = new LinePlot($tot_data, $ticks);
$lineplot->SetLegend("Traffic total");
$lineplot->SetColor("#d5d5d5");
$lineplot->SetFillColor("#d5d5d5@0.5");
#$lineplot2 = new LinePlot($tot_data_inv, $ticks);
#$lineplot2->SetColor("#d5d5d5");
#$lineplot2->SetFillColor("#d5d5d5@0.5");
$lineplot_in = new LinePlot($in_data, $ticks);
$lineplot_in->SetLegend("Traffic In");
$lineplot_in->SetColor('darkgreen');
$lineplot_in->SetFillColor('lightgreen@0.4');
$lineplot_in->SetWeight(1);
$lineplot_out = new LinePlot($out_data_inv, $ticks);
$lineplot_out->SetLegend("Traffic Out");
$lineplot_out->SetColor('darkblue');
$lineplot_out->SetFillColor('lightblue@0.4');
$lineplot_out->SetWeight(1);
if ($_GET['95th']) {
    $lineplot_95th = new LinePlot($per_data, $ticks);
    $lineplot_95th->SetColor("red");
}
if ($_GET['ave']) {
    $lineplot_ave = new LinePlot($ave_data, $ticks);
    $lineplot_ave->SetColor("red");
}
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.52, 0.9, 'center');
$graph->Add($lineplot);
#$graph->Add($lineplot2);
Exemplo n.º 22
0
$graph->SetShadow();
$graph->title->Set("Background image");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Slightly adjust the legend from it's default position in the
// top right corner.
$graph->legend->Pos(0.05, 0.5, "right", "center");
// Create the first line
$p1 = new LinePlot($datay);
$p1->mark->SetType(MARK_FILLEDCIRCLE);
$p1->mark->SetFillColor("red");
$p1->mark->SetWidth(4);
$p1->SetColor("blue");
$p1->SetCenter();
$p1->SetLegend("Triumph Tiger -98");
$graph->Add($p1);
// ... and the second
$p2 = new LinePlot($data2y);
$p2->mark->SetType(MARK_STAR);
$p2->mark->SetFillColor("red");
$p2->mark->SetWidth(4);
$p2->SetColor("red");
$p2->SetCenter();
$p2->SetLegend("New tiger -99");
$graph->Add($p2);
// Output line
$graph->Stroke();
?>


Exemplo n.º 23
0
include "../../../include/jpgraph/jpgraph.php";
include "../../../include/jpgraph/jpgraph_line.php";
include "../../../include/jpgraph/jpgraph_date.php";
// Create the graph. These two calls are always required
$graph = new Graph(600, 300, "example1");
$graph->SetScale("datelin");
$graph->img->SetMargin(55, 40, 55, 60);
//$graph->xaxis->SetFont(FONT1,FS_BOLD);
$graph->title->Set(" Time Series");
$graph->subtitle->Set($titleDate);
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.01, 0.08);
//$graph->yaxis->scale->ticks->SetPrecision(2);
$graph->yscale->SetGrace(10);
$graph->yaxis->SetColor("blue");
$graph->xaxis->SetLabelAngle(90);
$graph->title->SetFont(FF_FONT1, FS_BOLD, 14);
$graph->yaxis->SetTitle("Accumulated Precipitation [inches]");
$graph->xaxis->SetTitle("Valid Local Time");
$graph->xaxis->SetTitleMargin(30);
$graph->yaxis->SetTitleMargin(43);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD, 12);
//$graph->SetAxisStyle(AXSTYLE_YBOXIN);
$graph->xaxis->SetPos("min");
// Create the linear plot
$lineplot = new LinePlot($prec, $valid);
$lineplot->SetLegend("Daily Precipitation");
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
$graph->Add($lineplot);
$graph->Stroke();
Exemplo n.º 24
0
$graph->SetScale("textlin");
$graph->SetFrame(false);
$graph->SetMargin(30, 50, 30, 30);
$graph->title->Set('Filled Y-grid');
$graph->yaxis->HideZeroLabel();
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
$graph->xgrid->Show();
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
// Create the first line
$p1 = new LinePlot($datay1);
$p1->SetColor("navy");
$p1->SetLegend('Line 1');
$graph->Add($p1);
// Create the second line
$p2 = new LinePlot($datay2);
$p2->SetColor("red");
$p2->SetLegend('Line 2');
$graph->Add($p2);
// Create the third line
$p3 = new LinePlot($datay3);
$p3->SetColor("orange");
$p3->SetLegend('Line 3');
$graph->Add($p3);
$graph->legend->SetShadow('gray@0.4', 5);
$graph->legend->SetPos(0.1, 0.1, 'right', 'top');
// Output line
$graph->Stroke();
?>


Exemplo n.º 25
0
<?php

include "../jpgraph.php";
include "../jpgraph_line.php";
// create the graph
$graph = new Graph(400, 250, "auto");
$ydata = array(5, 10, 15, 20, 15, 10);
$graph->SetScale("textlin");
$graph->SetShadow(true);
$graph->SetMarginColor("antiquewhite");
$graph->img->SetMargin(60, 40, 40, 50);
$graph->img->setTransparent("white");
$graph->xaxis->SetFont(FF_FONT1);
$graph->xaxis->setTextTickInterval(1);
$graph->xaxis->SetTextLabelInterval(1);
$graph->legend->SetFillColor("antiquewhite");
$graph->legend->SetShadow(true);
$graph->legend->SetLayout(LEGEND_VERT);
$graph->legend->Pos(0.02, 0.01);
$graph->title->Set("Step Styled Example");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$lineplot = new LinePlot($ydata);
$lineplot->SetColor("black");
$lineplot->setFillColor("gray7");
$lineplot->SetStepStyle();
$lineplot->SetLegend(" 2002 ");
// add plot to the graph
$graph->Add($lineplot);
$graph->ygrid->show(false, false);
// display graph
$graph->Stroke();
Exemplo n.º 26
0
<?php

// content="text/plain; charset=utf-8"
require_once '../jpgraph.php';
require_once '../jpgraph_line.php';
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Create the graph. These two calls are always required
$graph = new Graph(300, 200);
$graph->SetScale("textlin");
$graph->img->SetMargin(50, 90, 40, 50);
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
$graph->title->Set("Examples for graph");
// Create the linear plot
$lineplot = new LinePlot($ydata);
$lineplot->SetLegend("Test 1");
$lineplot->SetColor("blue");
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
 /**
  *
  * @param Integer $groupId
  * @param Array   $services
  * @param String  $groupBy
  * @param Date    $startDate
  * @param Date    $endDate
  * @param Boolean $absolute Is y-axis relative to data set or absolute (starting from 0)
  */
 function displayProjectGraph($groupId, $services, $groupBy, $startDate, $endDate, $absolute = true, $accumulative = true, $siteAdminView = true)
 {
     $graph = new Chart(750, 450, "auto");
     $graph->SetScale("textint");
     $graph->title->Set("Project by service growth over the time");
     $graph->yaxis->title->Set("Size");
     $graph->yaxis->SetTitleMargin(60);
     $graph->yaxis->setLabelFormatCallback(array($this, 'sizeReadable'));
     if ($absolute) {
         $graph->yaxis->scale->SetAutoMin(0);
     }
     $servicesList = $this->_dum->getProjectServices($siteAdminView);
     $data = $this->_dum->getWeeklyEvolutionProjectData($services, $groupId, $groupBy, $startDate, $endDate);
     if (is_array($data) && count($data)) {
         $lineplots = array();
         $dates = array();
         $lineAdded = false;
         foreach ($servicesList as $service => $serviceName) {
             if (array_key_exists($service, $data) && is_array($data[$service]) && count($data[$service]) > 1) {
                 $values = $data[$service];
                 $ydata = array();
                 foreach ($values as $date => $size) {
                     $dates[] = $date;
                     $ydata[] = $size;
                 }
                 $lineplot = new LinePlot($ydata);
                 $color = $this->_dum->getServiceColor($service);
                 $lineplot->SetColor($color);
                 $lineplot->SetFillColor($color . ':1.5');
                 $lineplot->SetLegend($serviceName);
                 //$lineplot->value->show();
                 $lineplot->value->SetFont($graph->getFont(), FS_NORMAL, 8);
                 $lineplot->value->setFormatCallback(array($this, 'sizeReadable'));
                 if ($accumulative) {
                     //$lineplots[] = $lineplot;
                     // Reverse order
                     $lineAdded = true;
                     array_unshift($lineplots, $lineplot);
                 } else {
                     $lineAdded = true;
                     $graph->Add($lineplot);
                 }
             }
         }
         if ($accumulative && count($lineplots)) {
             $accLineplot = new AccLinePlot($lineplots);
             $graph->Add($accLineplot);
         }
         if ($lineAdded) {
             $graph->legend->SetReverse();
             $graph->xaxis->title->Set($groupBy . "s");
             $graph->xaxis->SetTitleMargin(35);
             $graph->xaxis->SetTickLabels($dates);
             $graph->Stroke();
         } else {
             $this->displayError($GLOBALS['Language']->getText('plugin_statistics', 'no_data_error'));
         }
     } else {
         $this->displayError($GLOBALS['Language']->getText('plugin_statistics', 'no_data_error'));
     }
 }
Exemplo n.º 28
0
// content="text/plain; charset=utf-8"
require_once "jpgraph/jpgraph.php";
require_once "jpgraph/jpgraph_line.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');
// 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
$l2plot = new LinePlot($l2datay);
$l2plot->SetFillColor('orange');
$l2plot->SetLegend('Result');
// Add the plots to the graph
$graph->Add($l2plot);
$graph->Add($l1plot);
$graph->title->Set('Mixing line and filled line');
$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);
Exemplo n.º 29
0
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetPos(0.01, 0.9399999999999999, 'left', 'top');
$graph->legend->SetLineSpacing(3);
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCEE@0.5');
$graph->ygrid->Show();
$graph->xgrid->Show();
$graph->yaxis->scale->ticks->SetLabelFormat("%5.1f");
$graph->yaxis->scale->ticks->SetLabelFormat("%5.0f");
$graph->y2axis->scale->ticks->Set(100, 25);
$graph->y2axis->scale->ticks->SetLabelFormat("%-4.0f");
// Create the linear plot
$lineplot = new LinePlot($temps, $times);
$lineplot->SetLegend("Temperature");
$lineplot->SetColor("red");
//$lineplot->SetWeight(2);
// Create the linear plot
$lineplot2 = new LinePlot($dewps, $times);
$lineplot2->SetLegend("Dew Point");
$lineplot2->SetColor("blue");
//$lineplot2->SetWeight(2);
// Create the linear plot
$lineplot3 = new LinePlot($srad, $times);
$lineplot3->SetLegend("Solar Rad");
$lineplot3->SetColor("black");
//$lineplot3->SetWeight(2);
$graph->Add($lineplot2);
$graph->Add($lineplot);
if ($station != 'SPEI4') {
    $graph->AddY2($lineplot3);
}
$graph->Stroke();