Inheritance: extends Graph
Exemple #1
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
 }
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();
}
 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');
 }
Exemple #4
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();
 }
Exemple #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);
     }
 }
 /**
  * Runs the phpOpenTracker API call.
  *
  * @param  array $parameters
  * @return mixed
  * @access public
  */
 function run($parameters)
 {
     $parameters['api_call'] = 'top';
     $parameters['result_format'] = 'separate_result_arrays';
     list($names, $values, $percent, $total) = phpOpenTracker::get($parameters);
     $title = 'Top ' . $parameters['limit'] . ' ';
     switch ($parameters['what']) {
         case 'document':
             $title .= 'Pages';
             break;
         case 'entry_document':
             $title .= 'Entry Pages';
             break;
         case 'exit_document':
             $title .= 'Exit Pages';
             break;
         case 'exit_target':
             $title .= 'Exit Targets';
             break;
         case 'host':
             $title .= 'Hosts';
             break;
         case 'operating_system':
             $title .= 'Operating Systems';
             break;
         case 'referer':
             $title .= 'Referers';
             break;
         case 'user_agent':
             $title .= 'User Agents';
             break;
     }
     $title .= " (Total: {$total})";
     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();
 }
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");
}
Exemple #8
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");
 }
Exemple #11
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();
 }
Exemple #12
0
 public function Draw()
 {
     // modify pad_bottom to make PieGraph do the hard work
     $pb = $this->pad_bottom;
     $this->pad_bottom += $this->depth;
     $this->Calc();
     $this->pad_bottom = $pb;
     return PieGraph::Draw();
 }
 /**
  * Sets up the polar graph details
  */
 protected function Calc()
 {
     // no sorting, no percentage
     $this->sort = false;
     $this->show_label_percent = false;
     parent::Calc();
     $smax = sqrt($this->GetMaxValue());
     $this->radius_factor_x = $this->radius_x / $smax;
     $this->radius_factor_y = $this->radius_y / $smax;
     $this->slice_angle = 2.0 * M_PI / ($this->GetMaxKey() + 1);
 }
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");
}
 protected function Draw()
 {
     // modify pad_bottom to make PieGraph do the hard work
     $pb = $this->pad_bottom;
     $space = $this->height - $this->pad_top - $this->pad_bottom;
     if ($space < $this->depth) {
         $this->depth = $space / 2;
     }
     $this->pad_bottom += $this->depth;
     $this->Calc();
     $this->pad_bottom = $pb;
     return PieGraph::Draw();
 }
 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");
     }
 }
Exemple #17
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();
}
Exemple #18
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;
 }
Exemple #19
0
 function __construct($Titre = "", $NbColonnesLegende = GRAPH_NB_COLONNES_LEGENDE, $width = GRAPH_LARGEUR, $height = GRAPH_HAUTEUR, $cachedName = "", $timeout = 0, $inline = 1)
 {
     parent::__construct($width, $height, $cachedName, $timeout, $inline);
     $this->SetColor("white");
     $this->title->Set($Titre);
     $this->title->SetFont(FF_TIMES, FS_BOLD, 12);
     $this->title->SetColor("#404040");
     // Mise en forme de la légende du graphe
     $this->legend->SetAbsPos(0, 220, "left", "top");
     // à 0px du bord gauche et à 220px du haut
     $this->legend->SetFillColor("white");
     // couleur de fond : blanc
     $this->legend->SetColumns($NbColonnesLegende);
     // nombre de colonnes par ligne
 }
Exemple #20
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();
 }
// Check permissions to see if apache can actually create the file
if (is_writable(CACHE_DIR)) {
    // JPGraph
    include_once "./lib/jpgraph/src/jpgraph.php";
    include_once "./lib/jpgraph/src/jpgraph_pie.php";
    include_once "./lib/jpgraph/src/jpgraph_pie3d.php";
    $result = dbquery($sql);
    if (!mysql_num_rows($result) > 0) {
        die("Error: no rows retrieved from database\n");
    }
    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>";
Exemple #22
0
<?php

// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_pie.php';
$data = array(19, 12, 4, 3, 3, 12, 3, 3, 5, 6, 7, 8, 8, 1, 7, 2, 2, 4, 6, 8, 21, 23, 2, 2, 12);
// Create the Pie Graph.
$graph = new PieGraph(300, 350);
// Set A title for the plot
$graph->title->Set("Label guide lines");
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 12);
$graph->title->SetColor("darkblue");
$graph->legend->Pos(0.1, 0.2);
// Create pie plot
$p1 = new PiePlot($data);
$p1->SetCenter(0.5, 0.55);
$p1->SetSize(0.3);
// Enable and set policy for guide-lines
$p1->SetGuideLines();
$p1->SetGuideLinesAdjust(1.4);
// Setup the labels
$p1->SetLabelType(PIE_VALUE_PER);
$p1->value->Show();
$p1->value->SetFont(FF_ARIAL, FS_NORMAL, 9);
$p1->value->SetFormat('%2.1f%%');
// Add and stroke
$graph->Add($p1);
$graph->Stroke();
?>

Exemple #23
0
<?php

include_once "../jpgraph.php";
include_once "../jpgraph_pie.php";
// Some data
$data = array(40, 21, 17, 14, 23);
// Create the Pie Graph.
$graph = new PieGraph(300, 200, 'auto');
$graph->SetShadow();
// Set A title for the plot
$graph->title->Set("Client side image map");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Create
$p1 = new PiePlot($data);
$p1->SetCenter(0.4, 0.5);
$p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"));
$targ = array("pie_csimex1.php#1", "pie_csimex1.php#2", "pie_csimex1.php#3", "pie_csimex1.php#4", "pie_csimex1.php#5", "pie_csimex1.php#6");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$p1->SetCSIMTargets($targ, $alts);
$graph->Add($p1);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM('pie_csimex1.php');
?>


Exemple #24
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();
 }
Exemple #25
0
<?php

// content="text/plain; charset=utf-8"
// $Id: piec_csimex1.php,v 1.1.2.1 2003/10/09 21:05:39 aditus Exp $
// Example of pie with center circle
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_pie.php';
// Some data
$data = array(50, 28, 25, 27, 31, 20);
// A new pie graph
$graph = new PieGraph(400, 400);
// If you don't want any  border just uncomment this line
// $graph->SetFrame(false);
// Uncomment this line to add a drop shadow to the border
// $graph->SetShadow();
// Setup title
$graph->title->Set("CSIM Center Pie plot ex 1");
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 18);
$graph->title->SetMargin(8);
// Add a little bit more margin from the top
// Create the pie plot
$p1 = new PiePlotC($data);
// Set the radius of pie (as fraction of image size)
$p1->SetSize(0.32);
// Move the center of the pie slightly to the top of the image
$p1->SetCenter(0.5, 0.45);
// Label font and color setup
$p1->value->SetFont(FF_ARIAL, FS_BOLD, 12);
$p1->value->SetColor('white');
// Setup the title on the center circle
$p1->midtitle->Set("Test mid\nRow 1\nRow 2");
    $data['title'][] = $value['var1'];
    $data['value'][] = $value['var2'];
    if ($value['var2'] != 0) {
        // si todos los valores están a 0, el piegraph da el siguiente error 'Illegal pie plot. Sum of all data is zero for pie plot'
        $temp_activado = true;
    }
}
//
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);
<?php

include "../jpgraph.php";
include "../jpgraph_pie.php";
// Some data
$data = array(113, 5, 160, 3, 15, 10, 1);
// Create the Pie Graph.
$graph = new PieGraph(300, 200, "auto");
$graph->SetShadow();
// Set A title for the plot
$graph->title->Set("Example 1 Pie plot");
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 14);
$graph->title->SetColor("brown");
// Create pie plot
$p1 = new PiePlot($data);
//$p1->SetSliceColors(array("red","blue","yellow","green"));
$p1->SetTheme("earth");
$p1->SetFont(FF_ARIAL, FS_NORMAL, 10);
// Set how many pixels each slice should explode
$p1->Explode(array(0, 15, 15, 25, 15));
$graph->Add($p1);
$graph->Stroke();
?>


Exemple #28
0
<?php

require '../include/core/common.php';
include '../include/jpgraph/jpgraph.php';
include '../include/jpgraph/jpgraph_pie.php';
unset($data);
for ($i = 1; $i <= SURVEY_MAX_ALTERNATIVES; $i++) {
    if (isset($_GET['alt_' . $i])) {
        $data[$i] = $_GET['alt_' . $i];
    }
}
if (count($data) == 0 && is_numeric($_GET['poll_id'])) {
    $poll = poll_fetch(array('id' => $_GET['poll_id']));
    for ($i = 1; $i <= SURVEY_MAX_ALTERNATIVES; $i++) {
        if (strlen($poll[0]['alt_' . $i]) > 0) {
            $data[$i] = $poll[0]['alt_' . $i . '_votes'];
        }
    }
}
$graph = new PieGraph(190, 160);
$graph->SetAntiAliasing();
$graph->SetShadow();
$p1 = new PiePlot($data);
$p1->ShowBorder();
$graph->SetFrame(false, 'darkblue', 2);
$p1->SetSliceColors($survey_chart_colors);
$graph->Add($p1);
$graph->Stroke();
     $y[] = '0';
 }
 $rsCSC = sql("SELECT COUNT(`cache_logs`.`type`) `count`, `log_types`.`&2` AS `type` FROM `cache_logs` INNER JOIN `log_types` ON (`cache_logs`.`type`=`log_types`.`id`) WHERE type=3 AND cache_logs.deleted=0 AND cache_logs.cache_id=&1 GROUP BY `cache_logs`.`type` ORDER BY `log_types`.`pl` ASC", $cache_id, $lang_db);
 if ($rsCSC !== false) {
     $xtitle = "";
     $ry = mysql_fetch_array($rsCSC);
     $y[] = $ry['count'];
     $x[] = $ry['type'];
 } else {
     $x[] = tr("comment");
 }
 mysql_free_result($rsCSF);
 mysql_free_result($rsCSNF);
 mysql_free_result($rsCSC);
 /// A new pie graph
 $graph = new PieGraph(400, 200, "auto");
 $graph->SetScale('textint');
 $logtype = tr("by_logtype");
 // Title setup
 $graph->title->Set($logtype);
 $graph->title->SetFont(FF_ARIAL, FS_NORMAL);
 //$graph ->legend->Pos( 0.25,0.8,"right" ,"bottom");
 // Setup the pie plot
 $p1 = new PiePlot($y);
 $p1->SetTheme("earth");
 $p1->value->SetFormat("%d");
 $p1->SetLabelType(PIE_VALUE_ABS);
 $p1->SetSliceColors(array('chartreuse3', 'chocolate2', 'wheat1'));
 // Adjust size and position of plot
 $p1->SetSize(0.35);
 $p1->SetCenter(0.25, 0.52);
 /**
  * Collects and renders user per group report data
  */
 public function user_per_group()
 {
     $myConfig = $this->getConfig();
     $oDb = oxDb::getDb();
     global $aTitles;
     $aDataX = array();
     $aDataY = array();
     $sSQL = "SELECT oxgroups.oxtitle,\n                        count(oxuser.oxid)\n                 FROM oxobject2group,\n                      oxuser,\n                      oxgroups\n                 WHERE oxobject2group.oxobjectid = oxuser.oxid  AND\n                       oxobject2group.oxgroupsid = oxgroups.oxid\n                 GROUP BY oxobject2group.oxgroupsid\n                 ORDER BY oxobject2group.oxgroupsid";
     $rs = $oDb->execute($sSQL);
     if ($rs != false && $rs->recordCount() > 0) {
         while (!$rs->EOF) {
             if ($rs->fields[1]) {
                 $aDataX[] = $rs->fields[1];
                 $aDataY[] = $rs->fields[0];
             }
             $rs->moveNext();
         }
     }
     header("Content-type: image/png");
     // New graph with a drop shadow
     if (count($aDataX) > 10) {
         $graph = new PieGraph(800, 830);
     } else {
         $graph = new PieGraph(600, 600);
     }
     $graph->setBackgroundImage($myConfig->getImageDir(true) . "/reportbgrnd.jpg", BGIMG_FILLFRAME);
     $graph->setShadow();
     // Set title and subtitle
     //$graph->title->set($this->aTitles[$myConfig->getConfigParam( 'iAdminLanguage' ) ]);
     $graph->title->set($this->aTitles[oxRegistry::getLang()->getObjectTplLanguage()]);
     // Use built in font
     $graph->title->setFont(FF_FONT1, FS_BOLD);
     // Create the bar plot
     $bplot = new PiePlot3D($aDataX);
     $bplot->setSize(0.4);
     $bplot->setCenter(0.5, 0.32);
     // explodes all chunks of Pie from center point
     $bplot->explodeAll(10);
     $iUserCount = 0;
     foreach ($aDataX as $iVal) {
         $iUserCount += $iVal;
     }
     for ($iCtr = 0; $iCtr < count($aDataX); $iCtr++) {
         $iSLeng = strlen($aDataY[$iCtr]);
         if ($iSLeng > 20) {
             if ($iSLeng > 23) {
                 $aDataY[$iCtr] = trim(substr($aDataY[$iCtr], 0, 20)) . "...";
             }
         }
         $aDataY[$iCtr] .= " - " . $aDataX[$iCtr] . " Kund.";
     }
     $bplot->setLegends($aDataY);
     if (count($aDataX) > 10) {
         $graph->legend->pos(0.49, 0.66, 'center');
         $graph->legend->setFont(FF_FONT0, FS_NORMAL);
         $graph->legend->setColumns(4);
     } else {
         $graph->legend->pos(0.49, 0.7, 'center');
         $graph->legend->setFont(FF_FONT1, FS_NORMAL);
         $graph->legend->setColumns(2);
     }
     $graph->add($bplot);
     // Finally output the  image
     $graph->stroke();
 }