Пример #1
0
 /**
  * Runs the phpOpenTracker API call.
  *
  * @param  array $parameters
  * @return mixed
  * @access public
  */
 function run($parameters)
 {
     global $locale;
     $parameters['api_call'] = 'localizer';
     $parameters['what'] = 'top_localizer';
     $parameters['result_format'] = 'separate_result_arrays';
     list($names, $values, $percent, $total) = phpOpenTracker::get($parameters);
     $title = $locale->get('admin_stat', 'field_top') . ' ' . $parameters['limit'] . ' ' . $locale->get('admin_stat', 'field_countries');
     for ($i = 0, $numValues = sizeof($values); $i < $numValues; $i++) {
         $legend[$i] = sprintf('%s (%s, %s%%%%)', $names[$i], $values[$i], $percent[$i]);
     }
     $graph = new PieGraph($parameters['width'], $parameters['height'], 'auto');
     $graph->SetShadow();
     $graph->title->Set($title);
     $graph->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->title->SetColor('black');
     $graph->legend->Pos(0.1, 0.2);
     $plot = new PiePlot3d($values);
     $plot->SetTheme('sand');
     $plot->SetCenter(0.4);
     $plot->SetAngle(30);
     $plot->value->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size'] - 2);
     $plot->SetLegends($legend);
     $graph->Add($plot);
     $graph->Stroke();
 }
Пример #2
0
 public static function pieChart($data, $legends)
 {
     $graph = new PieGraph(900, 550, 'auto');
     $graph->SetShadow();
     //        $graph->title->Set($topic);
     $graph->title->SetFont(FF_VERDANA, FS_BOLD, 14);
     $graph->legend->Pos(0.1, 0.2);
     // Creating a 3D pie graphic
     $p1 = new PiePlot3d($data);
     $p1->SetTheme("sand");
     $p1->SetLabels($legends);
     $p1->SetLabelPos(1);
     $p1->SetLabelType(PIE_VALUE_PER);
     $p1->value->Show();
     $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 20);
     $p1->value->SetColor('darkgray');
     $p1->SetCenter(0.45, 0.5);
     $p1->SetAngle(45);
     $p1->ExplodeAll(20);
     //        $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 12);
     //        $p1->SetLegends($legends);
     $graph->img->SetImgFormat('png');
     $graph->Add($p1);
     // Showing graphic
     return $graph->Stroke('../graph/3DpieChart.png');
 }
Пример #3
0
function createPie3D($pValues = "")
{
    // Some data
    $values = array("2010" => 1950, "2011" => 750, "2012" => 2100, "2013" => 580, "2014" => 5000, "2015" => 5000, "2016" => 5000, "2017" => 5000);
    if ($pValues) {
        $values = $pValues;
    }
    $total = count($values);
    $data = $total == 0 ? array(360) : array_values($values);
    $keys = $total == 0 ? array("") : array_keys($values);
    // Create the Pie Graph.
    $graph = new PieGraph(380, 400);
    $theme_class = new VividTheme();
    $graph->SetTheme($theme_class);
    // Set A title for the plot
    //$graph->title->Set("A Simple 3D Pie Plot");
    // Create
    $p1 = new PiePlot3D($data);
    $p1->SetLegends($keys);
    $graph->Add($p1);
    $p1->ShowBorder();
    $p1->SetColor('black');
    $p1->ExplodeSlice(1);
    $graph->Stroke();
}
Пример #4
0
 function create_pie_graph()
 {
     $graph = new PieGraph($this->width, $this->height, "auto");
     //instantiate new PieGraph object
     $graph->SetShadow();
     //displayed with shadow
     $graph->title->Set($this->title);
     //setup graph title
     $graph->title->SetFont(FF_VERDANA, FS_BOLD, 10);
     //set up font porperties
     $graph->title->SetColor("darkblue");
     $p1 = new PiePlot3D($this->data);
     //define new 3D image for PieGraph
     $p1->ExplodeAll();
     //explode each sector of the pie
     $p1->SetTheme("sand");
     //set up the theme (Colors)
     $p1->SetCenter(0.45);
     //display on center
     $p1->SetLegends($this->label);
     //set up legend of the graph
     //$p1->SetLabel($this->label);				//set up the labels of each sector of the pie graph
     // Setup the slice values
     $p1->value->SetFont(FF_ARIAL, FS_BOLD, 11);
     $p1->value->SetColor("navy");
     $graph->Add($p1);
     //add 3D pie to PieGraph object
     $graph->Stroke();
     //display grapg
 }
Пример #5
0
 public function graficoPDF($datos = array(), $nombreGrafico = NULL, $ubicacionTamamo = array(), $titulo = NULL)
 {
     //construccion de los arrays de los ejes x e y
     if (!is_array($datos) || !is_array($ubicacionTamamo)) {
         echo "los datos del grafico y la ubicacion deben de ser arreglos";
     } elseif ($nombreGrafico == NULL) {
         echo "debe indicar el nombre del grafico a crear";
     } else {
         #obtenemos los datos del grafico
         //echo json_encode($datos);
         foreach ($datos as $key => $value) {
             if ($value['estatus'] === $value['contador']) {
                 $data[] = $value['contador'];
                 $nombres[] = $value['parroquia'] . ' (' . $value['contador'] . ')';
             } else {
                 if ($value['estatus'] === 'tipo') {
                     $data[] = $value['contador'];
                     $nombres[] = $value['sector'] . ' (' . $value['contador'] . ')';
                 } else {
                     if ($value['estatus'] === 'sector') {
                         $data[] = $value['contador'];
                         $nombres[] = $value['tipo'] . ' (' . $value['contador'] . ')';
                     } else {
                         if ($value['estatus'] != $value['contador']) {
                             $data[] = $value['contador'];
                             $nombres[] = $value['estatus'] . ' (' . $value['contador'] . ')';
                         }
                     }
                 }
             }
         }
         $x = $ubicacionTamamo[0];
         $y = $ubicacionTamamo[1];
         $ancho = $ubicacionTamamo[2];
         $altura = $ubicacionTamamo[3];
         $color[] = ['red', 'blue', 'yellow', 'green', 'orange', 'pink', 'purple', 'silver', 'olive', 'grey', 'lime', 'sky blue', 'black', 'brown'];
         #Creamos un grafico vacio
         $graph = new PieGraph(400, 300);
         #indicamos titulo del grafico si lo indicamos como parametro
         if (!empty($titulo)) {
             $graph->title->Set($titulo);
         }
         //Creamos el plot de tipo tarta
         $p1 = new PiePlot3D($data);
         $p1->SetSliceColors($color);
         #indicamos la leyenda para cada porcion de la tarta
         $p1->SetLegends($nombres);
         //Añadirmos el plot al grafico
         $graph->Add($p1);
         //mostramos el grafico en pantalla
         unlink("{$nombreGrafico}.png");
         $graph->Stroke("{$nombreGrafico}.png");
         $this->Image("{$nombreGrafico}.png", $x, $y, $ancho, $altura);
     }
 }
Пример #6
0
function generate_image($lang, $idx)
{
    global $LANGUAGES;
    $up_to_date = get_stats($idx, $lang, 'uptodate');
    $up_to_date = $up_to_date[0];
    //
    $outdated = @get_stats($idx, $lang, 'outdated');
    $outdated = $outdated[0];
    //
    $missing = get_stats($idx, $lang, 'notrans');
    $missing = $missing[0];
    //
    $no_tag = @get_stats($idx, $lang, 'norev');
    $no_tag = $no_tag[0];
    $data = array($up_to_date, $outdated, $missing, $no_tag);
    $percent = array();
    $total = array_sum($data);
    // Total ammount in EN manual (to calculate percentage values)
    $total_files_lang = $total - $missing;
    // Total ammount of files in translation
    foreach ($data as $value) {
        $percent[] = round($value * 100 / $total);
    }
    $legend = array($percent[0] . '%% up to date (' . $up_to_date . ')', $percent[1] . '%% outdated (' . $outdated . ')', $percent[2] . '%% missing (' . $missing . ')', $percent[3] . '%% without EN-Revision (' . $no_tag . ')');
    $title = 'Details for ' . $LANGUAGES[$lang] . ' PHP Manual';
    $graph = new PieGraph(530, 300);
    $graph->SetShadow();
    $graph->title->Set($title);
    $graph->title->Align('left');
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->legend->Pos(0.02, 0.18, "right", "center");
    $graph->subtitle->Set('(Total: ' . $total_files_lang . ' files)');
    $graph->subtitle->Align('left');
    $graph->subtitle->SetColor('darkred');
    $t1 = new Text(date('m/d/Y'));
    $t1->SetPos(522, 294);
    $t1->SetFont(FF_FONT1, FS_NORMAL);
    $t1->Align("right", 'bottom');
    $t1->SetColor("black");
    $graph->AddText($t1);
    $p1 = new PiePlot3D($data);
    $p1->SetSliceColors(array("#68d888", "#ff6347", "#dcdcdc", "#f4a460"));
    if ($total_files_lang != $up_to_date) {
        $p1->ExplodeAll();
    }
    $p1->SetCenter(0.35, 0.55);
    $p1->value->Show(false);
    $p1->SetLegends($legend);
    $graph->Add($p1);
    $graph->Stroke("../www/images/revcheck/info_revcheck_php_{$lang}.png");
}
Пример #7
0
/**
 * Show 3D Pie graph
 */
function ShowPie(&$legend, &$value)
{
    $graph = new PieGraph(330, 200, "auto");
    $graph->SetFrame(false);
    //$graph->title->Set("A simple 3D Pie plot");
    //$graph->title->SetFont(FF_FONT1,FS_BOLD);
    $p1 = new PiePlot3D($value);
    $p1->ExplodeSlice(1);
    $p1->SetCenter(0.45);
    $p1->SetLegends($legend);
    $graph->legend->SetPos(0.01, 0.01, 'right', 'top');
    $graph->Add($p1);
    $graph->Stroke();
}
function PieChart($w, $h, $title, $data, $dataL, $output)
{
    $graph = new PieGraph($w, $h, "auto");
    $graph->SetFrame(false);
    $graph->SetShadow(false);
    $graph->title->Set($title);
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $p1 = new PiePlot3D($data);
    $p1->SetAngle(20);
    $p1->SetSize(0.5);
    $p1->SetCenter(0.45);
    $p1->SetLegends($dataL);
    $graph->Add($p1);
    $graph->Stroke($output);
}
 function graficarPDF()
 {
     $solo_registrados = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m01_registrada IS NOT NULL AND pasantia.m02_aceptada IS NULL AND periodo.activo = TRUE");
     $solo_aceptadas = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m02_aceptada IS NOT NULL AND pasantia.m03_numero_asignado IS NULL AND periodo.activo = TRUE");
     $solo_numero_asignado = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m03_numero_asignado IS NOT NULL AND pasantia.m04_sellada IS NULL AND periodo.activo = TRUE");
     $solo_sellada = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m04_sellada IS NOT NULL AND pasantia.m05_entrego_copia IS NULL AND periodo.activo = TRUE");
     $solo_entrego_copia = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m05_entrego_copia IS NOT NULL AND pasantia.m06_entrego_borrador IS NULL AND periodo.activo = TRUE");
     $solo_entrego_borrador = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m06_entrego_borrador IS NOT NULL AND pasantia.m07_retiro_borrador IS NULL AND periodo.activo = TRUE");
     $solo_retiro_borrador = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m07_retiro_borrador IS NOT NULL AND pasantia.m08_entrega_final IS NULL AND periodo.activo = TRUE");
     $finalizaron = contar("SELECT COUNT(*) FROM pasantia INNER JOIN periodo ON periodo.id = pasantia.periodo_id WHERE pasantia.m08_entrega_final IS NOT NULL AND periodo.activo = TRUE");
     $this->MultiCell(200, 5, utf8_decode("\nRepública Bolivariana de Venezuela\nUniversidad del Zulia\nFacultad Experimental de Ciencias\nDivisión de Programas Especiales\nSistema de Pasantías\n\n\n\nEstadísticas de Hitos"), 0, "C", 0);
     //GENERAR LA TABLA
     $this->SetXY(5, 65);
     $this->SetFont('Arial', 'B', 12);
     $this->SetWidths(array(27, 25, 25, 25, 25, 25, 25, 25));
     $this->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'));
     $this->Row(array("Registradas", "Aceptadas", "Numero Asignado", "Selladas", "Entrega Copia", "Entrega Borrador", "Retiro Borrador", "Finalizaron"));
     $this->SetX(5);
     $this->SetFont('Arial', '', 12);
     $this->SetWidths(array(27, 25, 25, 25, 25, 25, 25, 25));
     $this->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'));
     $this->Row(array("{$solo_registrados}", "{$solo_aceptadas}", "{$solo_numero_asignado}", "{$solo_sellada}", "{$solo_entrego_copia}", "{$solo_entrego_borrador}", "{$solo_retiro_borrador}", "{$finalizaron}"));
     $data = array($solo_registrados, $solo_aceptadas, $solo_numero_asignado, $solo_sellada, $solo_entrego_copia, $solo_entrego_borrador, $solo_retiro_borrador, $finalizaron);
     //aqui va la cantidad que llevará cada parte del grafico
     $graph = new PieGraph(640, 480);
     //tamaño de la letra del titulo y la leyenda
     $graph->SetShadow();
     $db = new PgDB();
     //QUERY PARA EL PERIDO ACTIVO
     $queryPer = "SELECT tipo, anio FROM periodo WHERE activo = TRUE";
     $recoPer = pg_query($queryPer);
     $rowPer = pg_fetch_array($recoPer);
     $graph->title->Set(utf8_decode("REPORTE TOTAL\n{$rowPer['tipo']} - {$rowPer['anio']}"));
     $graph->title->SetFont(FF_FONT2, FS_BOLD);
     $p1 = new PiePlot($data);
     $p1->value->Show(true);
     $p1->SetLegends(array("Registradas", "Aceptadas", "Numeros Asignados", "Selladas", "Entrega de Copias", "Entrega de Borrador", "Retiro de Borrador", "Finalizaron"));
     //la leyenda del gráfico
     $p1->SetSize(0.3);
     //el radio del gráfico
     //$p1->SetAngle(45); //setear el angulo
     $graph->Add($p1);
     $graph->Stroke("asd.png");
     $this->Image("asd.png", -15, 85, 240, 180);
     // x, y, ancho, altura.
     $this->Image("logotipo.jpg", 20, 12, -280);
     unlink("asd.png");
 }
Пример #10
0
 function plot()
 {
     $this->_setValues();
     // Create the Pie Graph.
     $graph = new PieGraph(500, 300);
     $graph->SetShadow();
     // Create
     $p1 = new PiePlot($this->_data);
     // Set A title for the plot
     $p1->SetLegends($this->_legends);
     $p1->SetSize(0.3);
     $p1->SetCenter(0.28, 0.5);
     $txt = new Text("Most Visited Titles", 0.15, 0.05);
     $txt->SetFont(FONT1_BOLD);
     $graph->Add($p1);
     $graph->AddText($txt);
     $graph->Stroke();
 }
Пример #11
0
function graph_pie_chart($graph_title, $graph_theme, $legend_array, $data_array, $xcoord, $ycoord)
{
    //unlink("Images/piecharts2/pie_chart_image.png");
    print "{$graph_title}";
    print "{$graph_theme}";
    print "{$legend_array}";
    print "{$data_array}";
    print "{$xcoord}";
    print "{$ycoord}";
    print "{$legend_array['2']}";
    $graph = new PieGraph($xcoord, $ycoord);
    $graph->title->Set($graph_title);
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $pie = new PiePlot($data_array);
    $pie->SetLegends($legend_array);
    $pie->SetTheme($graph_theme);
    //Sets the colour scheme defined in jpgraph_pie.php
    $graph->Add($pie);
    $graph->Stroke("images/piecharts2/pie_chart_image.png");
}
Пример #12
0
 public function gaficoPDF($datos = array(), $nombreGrafico = NULL, $ubicacionTamamo = array(), $titulo = NULL)
 {
     //construccion de los arrays de los ejes x e y
     if (!is_array($datos) || !is_array($ubicacionTamamo)) {
         echo "los datos del grafico y la ubicacion deben de ser arreglos";
     } elseif ($nombreGrafico == NULL) {
         echo "debe indicar el nombre del grafico a crear";
     } else {
         #obtenemos los datos del grafico
         foreach ($datos as $key => $value) {
             $data[] = $value[0];
             $nombres[] = $key;
             $color[] = $value[1];
         }
         $x = $ubicacionTamamo[0];
         $y = $ubicacionTamamo[1];
         $ancho = $ubicacionTamamo[2];
         $altura = $ubicacionTamamo[3];
         #Creamos un grafico vacio
         $graph = new PieGraph(600, 400);
         #indicamos titulo del grafico si lo indicamos como parametro
         if (!empty($titulo)) {
             $graph->title->Set($titulo);
         }
         //Creamos el plot de tipo tarta
         $p1 = new PiePlot3D($data);
         $p1->SetSliceColors($color);
         #indicamos la leyenda para cada porcion de la tarta
         $p1->SetLegends($nombres);
         //Añadirmos el plot al grafico
         $graph->Add($p1);
         //mostramos el grafico en pantalla
         $graph->Stroke("{$nombreGrafico}.png");
         $this->Image("{$nombreGrafico}.png", $x, $y, $ancho, $altura);
         unlink("{$nombreGrafico}.png");
     }
 }
Пример #13
0
 public function executePieGraph()
 {
     //Set the response header to a image JPEG datastream
     $this->getResponse()->setContent('image/jpeg');
     $util = new util();
     //echo $duales;
     $data1 = $util->getDualMedia('movies');
     $data2 = $util->getTotalMedia('movies') - $data1;
     $data = array($data2, $data1);
     $graph = new PieGraph(199, 120);
     $graph->SetMarginColor('#393939');
     $graph->SetFrame(true, '#393939');
     $graph->legend->SetPos(0.8, 0.9, 'center', 'bottom');
     $p1 = new PiePlot($data);
     $p1->SetSize(0.4);
     $p1->SetCenter(0.45);
     $p1->SetSliceColors(array('white', 'red'));
     $p1->value->SetColor('black');
     $p1->SetLegends(array("Spa", "Dual"));
     $p1->SetLabelPos(0.6);
     $graph->Add($p1);
     $graph->Stroke();
     return sfView::NONE;
 }
Пример #14
0
function graficarTorta()
{
    require 'jpgraph/src/jpgraph.php';
    require 'jpgraph/src/jpgraph_pie.php';
    require 'jpgraph/src/jpgraph_pie3d.php';
    // Some data
    $data = array($_GET['pos'], $_GET['neg']);
    // Create the Pie Graph.
    $graph = new PieGraph(350, 300);
    $theme_class = new VividTheme();
    $graph->SetTheme($theme_class);
    // Set A title for the plot
    // $graph->title->Set("Grafico Estadistico");
    // Create
    $p1 = new PiePlot3D($data);
    $p1->ShowBorder();
    $p1->SetColor('black');
    $p1->ExplodeSlice(1);
    $p1->SetLegends(array($_GET['lab1'], $_GET['lab2']));
    $p1->SetCenter(0.5, 0.4);
    $p1->SetAngle(40);
    $graph->Add($p1);
    $graph->Stroke();
}
Пример #15
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);
    }
}
Пример #16
0
$p1 = new PiePlot($data);
$p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May"));
$p1->SetSize($size);
$p1->SetCenter(0.25, 0.32);
$p1->value->SetFont(FF_FONT0);
$p1->title->Set("2001");
$p2 = new PiePlot($data);
$p2->SetSize($size);
$p2->SetCenter(0.65, 0.32);
$p2->value->SetFont(FF_FONT0);
$p2->title->Set("2002");
$p3 = new PiePlot($data);
$p3->SetSize($size);
$p3->SetCenter(0.25, 0.75);
$p3->value->SetFont(FF_FONT0);
$p3->title->Set("2003");
$p4 = new PiePlot($data);
$p4->SetSize($size);
$p4->SetCenter(0.65, 0.75);
$p4->value->SetFont(FF_FONT0);
$p4->title->Set("2004");
$graph->Add($p1);
$graph->Add($p2);
$graph->Add($p3);
$graph->Add($p4);
$graph->Stroke();
?>



Пример #17
0
function graph_pie($p_metrics, $p_title = '', $p_graph_width = 500, $p_graph_height = 350, $p_center = 0.4, $p_poshorizontal = 0.1, $p_posvertical = 0.09)
{
    $t_graph_font = graph_get_font();
    error_check(is_array($p_metrics) ? array_sum($p_metrics) : 0, $p_title);
    if (plugin_config_get('eczlibrary') == ON) {
        $graph = new ezcGraphPieChart();
        $graph->title = $p_title;
        $graph->background->color = '#FFFFFF';
        $graph->options->font = $t_graph_font;
        $graph->options->font->maxFontSize = 12;
        $graph->legend = false;
        $graph->data[0] = new ezcGraphArrayDataSet($p_metrics);
        $graph->data[0]->color = '#FFFF00';
        $graph->renderer = new ezcGraphRenderer3d();
        $graph->renderer->options->dataBorder = false;
        $graph->renderer->options->pieChartShadowSize = 10;
        $graph->renderer->options->pieChartGleam = 0.5;
        $graph->renderer->options->pieChartHeight = 16;
        $graph->renderer->options->legendSymbolGleam = 0.5;
        $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 {
        $graph = new PieGraph($p_graph_width, $p_graph_height);
        $graph->img->SetMargin(40, 40, 40, 100);
        $graph->title->Set($p_title);
        $graph->title->SetFont($t_graph_font, FS_BOLD);
        $graph->SetMarginColor('white');
        $graph->SetFrame(false);
        $graph->legend->Pos($p_poshorizontal, $p_posvertical);
        $graph->legend->SetFont($t_graph_font);
        $p1 = new PiePlot3d(array_values($p_metrics));
        // should be reversed?
        $p1->SetTheme('earth');
        # $p1->SetTheme("sand");
        $p1->SetCenter($p_center);
        $p1->SetAngle(60);
        $p1->SetLegends(array_keys($p_metrics));
        # Label format
        $p1->value->SetFormat('%2.0f');
        $p1->value->Show();
        $p1->value->SetFont($t_graph_font);
        $graph->Add($p1);
        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();
    }
}
Пример #18
0
function JpGraph()
{
    $graph = new PieGraph(230, 200, "auto");
    //$graph->SetShadow();
    // Set A title for the plot
    $graph->title->Set($tpl->_ENGINE_parse_body("{your mailbox usage}\n ({$kb} mb free)"));
    $graph->title->SetFont(FF_FONT1, FS_BOLD, 12);
    $graph->title->SetColor("black");
    $p1 = new PiePlot($data);
    $p1->SetSliceColors(array("red", "green", "yellow", "green"));
    $p1->SetTheme("water");
    $p1->value->SetFont(FF_FONT1, FS_NORMAL, 10);
    $p1->Explode(array(0, 15, 15, 25, 15));
    //$p1->SetLabelType(PIE_VALUE_PER);
    //$lbl = array("{used} $USER_STORAGE_USAGE","{free}");
    //$p1->SetLabels($lbl);
    $graph->Add($p1);
    //$graph->img->SetAntiAliasing();
    $graph->Stroke();
}
Пример #19
0
<?php

include "inc/jpgraph.php";
include "inc/jpgraph_bar.php";
include "inc/jpgraph_pie.php";
$ydata = array(11, 20, 8, 12, 5, 1, 9, 13, 5, 7);
$graph = new Graph(350, 250, "auto");
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 20, 20, 40);
$graph->title->Set("Empleados");
$graph->xaxis->title->Set("Mes");
$graph->yaxis->title->Set("Dinero");
$barplot = new BarPlot($ydata);
$barplot->SetColor("orange");
$graph->Add($barplot);
$graph->Stroke();
// Se define el array de valores y el array de la leyenda
$datos = array(40, 60, 21, 33);
$leyenda = array("Morenas", "Rubias", "Pelirrojas", "Otras");
//Se define el grafico
$grafico = new PieGraph(450, 300);
//Definimos el titulo
$grafico->title->Set("Mi primer grafico de tarta");
$grafico->title->SetFont(FF_FONT1, FS_BOLD);
//Añadimos el titulo y la leyenda
$p1 = new PiePlot($datos);
$p1->SetLegends($leyenda);
$p1->SetCenter(0.4);
//Se muestra el grafico
$grafico->Add($p1);
$grafico->Stroke();
Пример #20
0
$p1->SetLabelType(PIE_VALUE_PER);
// The label array values may have printf() formatting in them. The argument to the
// form,at string will be the value of the slice (either the percetage or absolute
// depending on what was specified in the SetLabelType() above.
$lbl = array("Jan\n%.1f%%", "Feb\n%.1f%%", "March\n%.1f%%", "Apr\n%.1f%%", "May\n%.1f%%", "Jun\n%.1f%%");
$p1->SetLabels($lbl);
// Add drop shadow to slices
$p1->SetShadow();
// Explode all slices 15 pixels
$p1->ExplodeAll(15);
// Setup the CSIM targets
global $_wrapperfilename;
$targ = array();
$alt = array();
$wtarg = array();
for ($i = 0; $i <= $n; ++$i) {
    $urlarg = 'pie_clickedon=' . ($i + 1);
    $targ[] = $_wrapperfilename . '?' . $urlarg;
    $alt[] = 'val=%d';
    $wtarg[] = '';
}
$p1->SetCSIMTargets($targ, $alt, $wtarg);
$p1->SetMidCSIM($targ[0], $alt[0], $wtarg[0]);
// Add plot to pie graph
$piegraph->Add($p1);
// Send back the image when we are called from within the <img> tag
$piegraph->StrokeCSIMImage();
?>


Пример #21
0
 /**
  * draw the Pie type graph (can have 1 pie plot)
  *
  * @param BizObj $bizObj object reference of bizobj
  * @param array $xmlArr xml array reference
  * @return void
  */
 public function pieGraphRender(&$bizObj, &$xmlArr)
 {
     include_once JPGRAPH_DIR . '/jpgraph.php';
     include_once JPGRAPH_DIR . '/jpgraph_pie.php';
     include_once JPGRAPH_DIR . '/jpgraph_pie3d.php';
     $graph = new PieGraph($xmlArr["ATTRIBUTES"]["WIDTH"], $xmlArr["ATTRIBUTES"]["HEIGHT"]);
     //$graph->SetAntiAliasing();
     // get the data set - only support one data
     $fields[0] = $xmlArr['DATASET']['DATAPIE']["ATTRIBUTES"]["FIELD"];
     $legendFld = $xmlArr['DATASET']['DATAPIE']["ATTRIBUTES"]["LEGENDFIELD"];
     $recArray =& $this->getPlotData($bizObj, $fields, $legendFld);
     $chartData = $xmlArr['DATASET']['DATAPIE'];
     $plot = $this->renderPiePlot($recArray[$fields[0]], $chartData);
     $plot->SetLegends($recArray[$legendFld]);
     $graph->Add($plot);
     // render titles
     $graph->title->Set($xmlArr['TITLE']['ATTRIBUTES']['CAPTION']);
     $this->_drawString($graph->title, $xmlArr['TITLE']['ATTRIBUTES']['FONT'], $xmlArr['TITLE']['ATTRIBUTES']['COLOR']);
     // render legend
     $this->_drawLegend($graph->legend, $xmlArr['LEGEND']['ATTRIBUTES']['POSITION'], $xmlArr['LEGEND']['ATTRIBUTES']['LAYOUT'], $xmlArr['LEGEND']['ATTRIBUTES']['FONT'], $xmlArr['LEGEND']['ATTRIBUTES']['COLOR'], $xmlArr['LEGEND']['ATTRIBUTES']['FILLCOLOR']);
     $graph->Stroke();
 }
    }
}
//
require_once 'ossim_conf.inc';
$conf = $GLOBALS["CONF"];
$jpgraph = $conf->get_conf("jpgraph_path");
require_once "{$jpgraph}/jpgraph.php";
require_once "{$jpgraph}/jpgraph_pie.php";
require_once "{$jpgraph}/jpgraph_pie3d.php";
// Setup the graph.
$graph = new PieGraph(400, 150, "auto");
$graph->SetAntiAliasing();
$graph->SetColor("#fafafa");
$graph->SetFrame(true, '#fafafa', 0);
if (isset($temp_activado)) {
    // Create the bar plots
    $piePlot3d = new PiePlot3D($data['value']);
    $piePlot3d->SetSliceColors(array(COLORPIE1, COLORPIE2, COLORPIE3, COLORPIE4, COLORPIE5, COLORPIE6, COLORPIE7, COLORPIE8));
    //$piePlot3d->SetAngle(30);
    $piePlot3d->SetHeight(12);
    $piePlot3d->SetSize(0.5);
    $piePlot3d->SetCenter(0.26, 0.4);
    // Labels
    //$piePlot3d->SetLabels($data['title'],1);
    $piePlot3d->SetLegends($data['title']);
    $graph->Add($piePlot3d);
    $graph->legend->SetPos(0.01, 0.6, 'right', 'bottom');
}
// Finally send the graph to the browser
$graph->Stroke();
unset($graph);
Пример #23
0
function dansguardian_buildGraph_week(){
include_once(dirname(__FILE__).'/listener.graphs.php');
$sql="SELECT COUNT( sitename ) AS tcount ,TYPE FROM `dansguardian_events` WHERE YEARWEEK( zDate ) = YEARWEEK( NOW( ) ) GROUP BY TYPE ORDER BY tcount DESC LIMIT 0 , 30";
if(isset($_GET["dansguardian-stats-query"])){return dansguardian_buildGraph_by_type();}

$md5=md5($sql);


	$q=new mysql();
	$results=$q->QUERY_SQL($sql,'artica_events');
	$html="<table style='width:100%'>";
	while ($ligne = mysql_fetch_array($results)) { 
		if($ligne["TYPE"]<>null){
			$data[]=$ligne["tcount"];
			$labels[]=$ligne["TYPE"];
			$jsa="javascript:ShowGraphDansGuardianDetails('{$ligne["TYPE"]}','week');";
			$html=$html . "<tr " . CellRollOver().">
				<td width=1%><img src='img/fw_bold.gif'>
				<td><strong style='font-size:11px'>{$ligne["tcount"]}</td>
				<td><strong style='font-size:11px'><a href='#' OnClick=\"$jsa\">{$ligne["TYPE"]}</a></td>
				</tr>
				
				";
			$js[]="$jsa";
			
		}
		
	}
	
	
	
   $html=$html."</table>";
   if (!is_array($data)){
   		die("<center>".ICON_DANSGUARDIAN_STATISTICS()."</center>");
   }
   
   $tpl=new templates();

   



$p1 = new PiePlot3D($data);
$p1->SetSize(.4); 
$p1->SetAngle(75); 
$p1->SetCSIMTargets($js,$labels);
$p1->SetCenter(0.3,0.5);
$p1->ExplodeAll(10); 
$p1->SetLegends($labels);
//$p1->SetSliceColors(array('red','blue','green','navy','orange')); 

$graph = new PieGraph(470,350,'auto');
$graph->Add($p1);
$graph->title->Set("Week");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->legend->Pos(0,0,'right','top');
$graph->legend->SetFillColor('white'); 
$graph->legend->SetLineWeight(0);
//$graph->legend->SetLayout(LEGEND_HOR); //hori 
$graph->legend->SetColor('black'); 
$graph->legend->SetShadow("white",0); 
$graph->SetFrame(false); 
if(function_exists("imageantialias")){$graph->img->SetAntiAliasing();}
$mapName = 'MapName';
$imgMap = $graph->GetHTMLImageMap($mapName); 
$graph->Stroke("ressources/logs/$md5.png");

$html=  "
<table style='width:100%'>

<tr>
	<td valign='top'>
$imgMap
".RoundedLightWhite("
<img src='ressources/logs/$md5.png' alt='graph' ismap usemap='#$mapName' border='0'>")."
</td>
<td valign='top'>".RoundedLightWhite($html)."</td>
</tr>
</table>

";


return $html;

	
}
Пример #24
0
$DB = NewADOConnection($_type_of_db_server);
$_res_db = @$DB->Connect($_host, $_user, $_password, $_db_name);
$ALERTS = new alerts(&$DB);
$ydata = array();
$ydata[0] = $ALERTS->TCPPktCnt();
$ydata[1] = $ALERTS->UDPPktCnt();
$ydata[2] = $ALERTS->ICMPPktCnt();
$ydata[3] = $ALERTS->PortscanPktCnt();
$xlabel = array("TCP", "UDP", "ICMP", "Portscan Traffic");
/*主页的总体图表信息*/
/*
 * Lib
 */
require_once 'jpgraph/src/jpgraph.php';
require_once 'jpgraph/src/jpgraph_canvas.php';
require_once 'jpgraph/src/jpgraph_error.php';
require_once 'jpgraph/src/jpgraph_log.php';
require_once 'jpgraph/src/jpgraph_pie.php';
require_once 'jpgraph/src/jpgraph_pie3d.php';
require_once 'jpgraph/src/jpgraph_scatter.php';
require_once 'jpgraph/src/jpgraph_radar.php';
$graph = new PieGraph(250, 250);
/* Set Margins */
$graph->img->SetMargin(50, 50, 80, 80);
$graph->img->SetAntiAliasing();
$plot[0] = new PiePlot3D($ydata);
$plot[0]->SetLegends($xlabel);
/* Set Title */
$graph->title->Set("Traffic Profile by Protocol");
$graph->Add($plot[0]);
$graph->Stroke();
Пример #25
0
function graph_pie($p_metrics, $p_title = '', $p_graph_width = 500, $p_graph_height = 350, $p_center = 0.4, $p_poshorizontal = 0.1, $p_posvertical = 0.09)
{
    $t_graph_font = graph_get_font();
    error_check(is_array($p_metrics) ? array_sum($p_metrics) : 0, $p_title);
    $graph = new PieGraph($p_graph_width, $p_graph_height);
    $graph->img->SetMargin(40, 40, 40, 100);
    $graph->title->Set($p_title);
    $graph->title->SetFont($t_graph_font, FS_BOLD);
    $graph->SetMarginColor('white');
    $graph->SetFrame(false);
    $graph->legend->Pos($p_poshorizontal, $p_posvertical);
    $graph->legend->SetFont($t_graph_font);
    $p1 = new PiePlot3d(array_values($p_metrics));
    // should be reversed?
    $p1->SetTheme('earth');
    #$p1->SetTheme("sand");
    $p1->SetCenter($p_center);
    $p1->SetAngle(60);
    $p1->SetLegends(array_keys($p_metrics));
    # Label format
    $p1->value->SetFormat('%2.0f');
    $p1->value->Show();
    $p1->value->SetFont($t_graph_font);
    $graph->Add($p1);
    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();
}
Пример #26
0
function hd_partinfos_graphic($dev)
{
    $f_name = "hd-" . md5($dev) . ".png";
    $fileName = dirname(__FILE__) . "/ressources/logs/{$f_name}";
    @unlink($fileName);
    $ydata[] = $ligne["tcount"];
    $xdata[] = $ligne["sitename"] . " " . $ligne["tcount"];
    $width = 700;
    $height = 200;
    $graph = new PieGraph($width, $height);
    $graph->title->Set("{$dev}");
    $p1 = new PiePlot3D($ydata);
    $p1->SetLegends($xdata);
    $p1->ExplodeSlice(1);
    $graph->Add($p1);
    $gdImgHandler = $graph->Stroke(_IMG_HANDLER);
    $graph->img->Stream($fileName);
    return "ressources/logs/{$f_name}";
}
Пример #27
0
 /**
  * 环形图
  */
 function createring($title, $data = array(), $size = 40, $height = 100, $width = 80, $legend = array())
 {
     // Example of pie with center circle
     vendor("Jpgraph.jpgraph");
     vendor("Jpgraph.jpgraph_pie");
     // Some data
     //$data = array(50,28,25,27,30,30);
     // A new pie graph
     $graph = new PieGraph(700, 350, 'auto');
     //$graph->SetShadow();
     // Setup title
     $graph->title->Set(iconv("utf-8", "gb2312", "{$title}"));
     $graph->title->SetFont(FF_SIMSUN, FS_BOLD, 14);
     $graph->title->SetMargin(2);
     // Add a little bit more margin from the top
     $graph->legend->Pos(0.1, 0.1);
     $graph->SetFrame(false, '#ffffff', 0);
     //去掉周围的边框
     // Create the pie plot
     $p1 = new PiePlotC($data);
     // Set size of pie
     $p1->SetTheme("sand");
     $p1->SetCenter(0.4);
     $p1->SetSize(0.35);
     // Label font and color setup
     $p1->value->SetFont(FF_ARIAL, FS_BOLD, 10);
     $p1->value->SetColor('black');
     // Setup the title on the center circle
     $p1->midtitle->Set("");
     $p1->midtitle->SetFont(FF_SIMSUN, FS_NORMAL, 10);
     // Set color for mid circle
     $p1->SetMidColor('white');
     // Use percentage values in the legends values (This is also the default)
     $p1->SetLabelType(PIE_VALUE_PER);
     $graph->legend->SetFont(FF_SIMSUN, FS_NORMAL, 8);
     //编码转化
     foreach ($legend as $k => $v) {
         $legend[$k] = iconv('utf-8', 'gb2312', $v);
     }
     $p1->SetLegends($legend);
     // Add plot to pie graph
     $graph->Add($p1);
     // .. and send the image on it's marry way to the browser
     $graph->Stroke();
 }
Пример #28
0
 public function executePieGraphSingers(sfWebRequest $request)
 {
     $util = new util();
     $loko = $util->singersData();
     //Set the response header to a image JPEG datastream
     $this->getResponse()->setContent('image/jpeg');
     //echo $duales;
     $data1 = 300;
     $data2 = 200;
     //        $data_results = $util->singersData();
     $data = array($data2, $data1);
     $graph = new PieGraph(200, 174);
     $graph->SetMarginColor('#393939');
     $graph->SetFrame(true, '#393939');
     $graph->legend->SetPos(0.8, 0.9, 'center', 'bottom');
     $p1 = new PiePlot($data);
     $p1->SetSize(0.4);
     $p1->SetCenter(0.45);
     $p1->SetSliceColors(array('white', 'red'));
     $p1->value->SetColor('black');
     $p1->SetLegends(array("Spa", "Dual"));
     $p1->SetLabelPos(0.6);
     $graph->Add($p1);
     $graph->Stroke();
     return sfView::NONE;
 }
    while ($row = mysql_fetch_object($result)) {
        $data[] = $row->count;
        $data_names[] = $row->from_domain;
        $data_size[] = round($row->size);
    }
    $graph = new PieGraph(800, 385, 0, false);
    $graph->SetShadow();
    $graph->img->SetAntiAliasing();
    $graph->title->Set("Top 10 Sender Domains by Volume");
    $p1 = new PiePlot3d($data);
    $p1->SetTheme('sand');
    $p1->SetLegends($data_names);
    $p1->SetCenter(0.73, 0.4);
    $graph->legend->SetLayout(LEGEND_VERT);
    $graph->legend->Pos(0.25, 0.2, 'center');
    $graph->Add($p1);
    $graph->Stroke($filename);
}
// HTML code to display the graph
echo "<TABLE BORDER=\"0\" CELLPADDING=\"10\" CELLSPACING=\"0\" WIDTH=\"100%\">";
echo "<TR>";
echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . IMAGES_DIR . "mailscannerlogo.gif\" ALT=\"MailScannr Logo\"></TD>";
echo "</TR>";
echo "<TR>";
//  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 {
    echo "<TD ALIGN=\"CENTER\"> File isn't readable. Please make sure that " . CACHE_DIR . " is readable and writable by MailWatch.";
}
echo "</TR>";
Пример #30
0
<?php

require_once "../src/jpgraph.php";
require_once "../src/jpgraph_pie.php";
//模拟数据
$data = array(0 => 3.5, 1 => 4.6, 2 => 9.1, 3 => 21.9, 4 => 42.3, 5 => 90.7, 6 => 183.5, 7 => 127.5, 8 => 61.4, 9 => 33.5, 10 => 11.5, 11 => 4.4);
//创建画布
$graph = new PieGraph(800, 500);
//设置图像边界范围
$graph->img->SetMargin(30, 30, 80, 30);
//设置标题
$graph->title->SetFont(FF_CHINESE);
$graph->title->Set("饼图--PiePlot Test");
//得到饼图对象
$piePlot = new PiePlot($data);
//设置图例
$piePlot->SetLegends(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
//设置图例位置
$graph->legend->Pos(0.01, 0.45, "left", "top");
//添加到画布中
$graph->Add($piePlot);
//输出
$graph->Stroke();