function generateGraphplotrev($type)
 {
     if ($type == "year") {
         $start = date("Y-");
         $start .= "01-01 00-00-00";
         $end = date("Y-");
         $end .= "12-31 23-59-59";
     } elseif ($type == "month") {
         $start = date("Y-m-");
         $start .= "01 00-00-00";
         $end = date("Y-m-");
         $end .= "31 23-59-59";
     } elseif ($type == "day") {
         $start = date("Y-m-d");
         $start .= " 00-00-00";
         $end = date("Y-m-d");
         $end .= " 23-59-59";
     } elseif ($type == "week") {
         $date = date("Y-m-d");
     }
     if ($type == "week") {
         $sql = "SELECT `id` FROM `sales` WHERE week(`created_at`) = week('{$date}') AND `deleted` = '0' ";
     } else {
         $sql = "SELECT `id` FROM `sales` WHERE (`created_at` BETWEEN '{$start}' AND '{$end}') AND `deleted` = '0'";
     }
     $sql = DB::select(DB::raw($sql));
     foreach ($sql as $row) {
         $sales_id[] = $row->id;
     }
     if (!isset($sales_id)) {
         $sales_id[] = 0;
         $sales_id[] = 0;
     }
     $ids = join(',', $sales_id);
     // user groups
     $sql = "SELECT COUNT(sales_product.id) AS 'Count', item.name AS 'Name' FROM sales_product INNER JOIN item ON item.id = sales_product.product WHERE sales_product.sale_id IN ({$ids}) GROUP BY sales_product.product ORDER BY `Count` DESC";
     $sql = DB::select(DB::raw($sql));
     foreach ($sql as $row) {
         $inq[] = $row->Count;
         $leg[] = $row->Name;
     }
     if (!isset($inq)) {
         $inq[] = 1;
         $leg[] = "null";
     }
     if (sizeof($inq) > 5) {
         $c = sizeof($inq) - 1;
         $other = 0;
         for ($x = 4; $x <= $c; $x++) {
             $other = $other + $inq[$x];
             unset($inq[$x]);
             unset($leg[$x]);
         }
         $inq[4] = $other;
         $leg[4] = "other";
     }
     // Some data
     $data = $inq;
     // Create the Pie Graph.
     $graph = new \PieGraph(350, 250);
     $graph->SetShadow();
     $legends = $leg;
     // $graph->legend->Pos(0.3, 0.85);
     $theme_class = "DefaultTheme";
     // Set A title for the plot
     $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
     $graph->SetBox(true);
     // Create
     $p1 = new \PiePlot3d($data);
     $graph->Add($p1);
     $p1->ShowBorder();
     $p1->SetColor('black');
     $p1->SetSliceColors(array('#ADFF2F', '#DC143C', '#9966FF', '#EBB000', '#6EDBFF'));
     $p1->SetLegends($legends);
     $p1->ExplodeSlice(2);
     $p1->SetAngle(30);
     $p1->SetSize(0.5);
     $p1->SetCenter(0.5, 0.4);
     // $graph->legend->SetColumns(3);
     $graph->legend->SetFrameWeight(1);
     $graph->legend->SetColumns(3);
     $gdImgHandler = $graph->Stroke(_IMG_HANDLER);
     $fileName = "assets/tmp/" . $type . "_pie_rev.png";
     $graph->img->Stream($fileName);
 }
    echo "NO hay nada";
}
//BUSCAMOS SI ENCONTRAMOS UN REGISTRO CON LOS DATOS  DEL USUARIO
$sql = "SELECT emp.nombreempresa,count(*) as cantidad\tfrom atencion as a  inner join ticket  as t on \ta.ate_tck_id=t.tck_id  inner join   webnets_rdgdb.usuario as  u  on\r\n\tt.tck_usuario=u.idusuario  inner join webnets_rdgdb.area as ar on\r\n\tu.area_idarea=ar.idarea inner join usuarios as user on \r\n\ta.ate_usuario=user.id_usuario inner join  empresa as emp on\r\n\tt.tck_empresa=emp.codigoempresa inner join estado as est on\r\n\ta.ate_estado=est.est_id  inner join tipoactividad as ta on \r\n\tt.tck_tipo=ta.codigoactividad  where a.ate_estado like '03' and\r\nate_horaestado like '%{$fecha}%'\r\ngroup by emp.nombreempresa";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res)) {
    //agregamos los datos al array
    $datos[] = $row['cantidad'];
}
// Create the Pie Graph.
$graph = new PieGraph(600, 500);
//$graph->xaxis->SetTickLabels($labels);
$theme_class = "DefaultTheme";
//$graph->SetTheme(new $theme_class());
// Set A title for the plot
//
$graph->title->Set("REPORTE POR EMPRESAS");
$graph->SetBox(true);
// Create
$p1 = new PiePlot($datos);
$graph->Add($p1);
$p1->ShowBorder();
$p1->SetColor('black');
$p1->SetSliceColors(array('#1E90FF', '#2E8B57', '#ADFF2F', '#DC143C', '#BA55D3', '#BA15D3'));
$graph->Stroke();
//SALIDA ARCHIVO  FORMATO PNG
//$grafico->Stroke("pie.png");
?>


 
Exemple #3
0
 function generateGraphplot($type)
 {
     if ($type == "year") {
         $start = date("Y-");
         $start .= "01-01 00-00-00";
         $end = date("Y-");
         $end .= "12-31 23-59-59";
     } elseif ($type == "month") {
         $start = date("Y-m-");
         $start .= "01 00-00-00";
         $end = date("Y-m-");
         $end .= "31 23-59-59";
     } elseif ($type == "day") {
         $start = date("Y-m-d");
         $start .= " 00-00-00";
         $end = date("Y-m-d");
         $end .= " 23-59-59";
     } elseif ($type == "week") {
         $date = date("Y-m-d");
     }
     // echo $sql;
     if ($type == "week") {
         $sql = "SELECT  count(*) AS counts FROM `call_log` WHERE YEARWEEK(`created_at`) = YEARWEEK('{$date}') AND `deleted` = '0' AND `call_type` = 'Inquiry' ";
         $sql2 = "SELECT count(*) AS counts FROM `sales` WHERE YEARWEEK(`created_at`) = YEARWEEK('{$date}') AND `deleted` = '0' ";
         $sql3 = "SELECT count(*) AS counts FROM `ticket` WHERE YEARWEEK(`created_at`) = YEARWEEK('{$date}') AND `deleted` = '0' ";
     } else {
         $sql = "SELECT  count(*) AS counts FROM `call_log` WHERE (`created_at` BETWEEN '{$start}' AND '{$end}') AND `deleted` = '0' AND `call_type` = 'Inquiry' ";
         $sql2 = "SELECT count(*) AS counts FROM `sales` WHERE (`created_at` BETWEEN '{$start}' AND '{$end}' ) AND `deleted` = '0' ";
         $sql3 = "SELECT count(*) AS counts FROM `ticket` WHERE (`created_at` BETWEEN '{$start}' AND '{$end}' ) AND `deleted` = '0' ";
     }
     $sql = DB::select(DB::raw($sql));
     $sql2 = DB::select(DB::raw($sql2));
     $sql3 = DB::select(DB::raw($sql3));
     foreach ($sql as $rowr) {
         $inq[] = $rowr->counts;
         $leg[] = "Inquiry";
     }
     foreach ($sql2 as $rowp) {
         $inq[] = $rowp->counts;
         $leg[] = "Sales";
     }
     foreach ($sql3 as $rowt) {
         $inq[] = $rowt->counts;
         $leg[] = "Tickets";
     }
     if ($inq['0'] == '0' && $inq['1'] == '0' && $inq['2'] == '0') {
         $inq['0'] = "1";
         unset($leg);
         // unset legends
         $leg[] = "null";
         // set legend null
     }
     if (!isset($inq)) {
         $inq[] = 1;
         $leg[] = "null";
     }
     // Some data
     $data = $inq;
     // Create the Pie Graph.
     $graph = new \PieGraph(350, 250);
     $graph->SetShadow();
     // $legends = array(
     //   'Sales',
     //   'Inquiry',
     // );
     $legends = $leg;
     $graph->legend->Pos(0.3, 0.9);
     $theme_class = "DefaultTheme";
     //$graph->SetTheme(new $theme_class());
     // Set A title for the plot
     //$graph->title->Set("Call Types");
     $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12);
     $graph->SetBox(true);
     // Create
     $p1 = new \PiePlot3d($data);
     $graph->Add($p1);
     $p1->ShowBorder();
     $p1->SetColor('black');
     $p1->SetSliceColors(array('#ADFF2F', '#DC143C', '#9966FF'));
     $p1->SetLegends($legends);
     $p1->ExplodeSlice(2);
     $p1->SetAngle(30);
     $graph->legend->SetColumns(3);
     $graph->legend->SetFrameWeight(1);
     // $graph->Stroke();
     $gdImgHandler = $graph->Stroke(_IMG_HANDLER);
     //$fileName = $type.".png";
     $fileName = "assets/tmp/" . $type . ".png";
     $graph->img->Stream($fileName);
 }
         $chartImageMapLinks[] = "";
     }
     $chartImageMapAlts[] = $fields[$content['chart_field']]['FieldCaption'] . ": " . $myKey;
     $chartImageMapTargets[] = "_top";
 }
 if ($content['chart_type'] == CHART_CAKE) {
     // Include additional code filers for this chart!
     include_once $gl_root_path . "classes/jpgraph/jpgraph_pie.php";
     include_once $gl_root_path . "classes/jpgraph/jpgraph_pie3d.php";
     // Create Basic Image, and set basic properties!
     $graph = new PieGraph($content['chart_width'], $content['chart_width'], 'auto');
     $graph->SetMargin(30, 20, 30, 30);
     // Adjust margin area
     $graph->SetScale("textlin");
     $graph->SetMarginColor('white');
     $graph->SetBox();
     // Box around plotarea
     // Set up the title for the graph
     //					$graph->title->Set('Messagecount sorted by "' . $content[ $fields[$content['chart_field']]['FieldCaption'] ] . '"');
     //					$graph->title->SetFont(FF_VERDANA,FS_NORMAL,12);
     //					$graph->title->SetColor("darkred");
     // Setup the tab title
     $graph->tabtitle->Set(GetAndReplaceLangStr($content['LN_STATS_CHARTTITLE'], $content['maxrecords'], $fields[$content['chart_field']]['FieldCaption']));
     $graph->tabtitle->SetFont(FF_VERA, FS_BOLD, 9);
     $graph->tabtitle->SetPos('left');
     // Set Graph footer
     $graph->footer->left->Set("LogAnalyzer v" . $content['BUILDNUMBER'] . "\n" . GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")));
     $graph->footer->left->SetFont(FF_VERA, FS_NORMAL, 7);
     //					$graph->footer->right->Set ( GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
     //					$graph->footer->right->SetFont( FF_VERA, FS_NORMAL, 8);
     //					$graph->footer->left->Set ("LogAnalyzer v" . $content['BUILDNUMBER'] . "\n" . GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
Exemple #5
0
 public function grafico_distribucion_tipo_resp($id_asignacionprueba)
 {
     require_once APPPATH . '/libraries/JpGraph/jpgraph_pie.php';
     $this->rendimiento_global($id_asignacionprueba);
     $data_circ = array($this->totalcorrectas, $this->totalincorrectas, $this->totalomitidas);
     $columnas_circ = array('Correctas', 'Incorrectas', 'Omitidas');
     $graph_circ = new PieGraph(400, 320);
     $graph_circ->title->Set("Distribución por Tipo de Respuesta");
     $graph_circ->SetMarginColor("#fff");
     $graph_circ->SetFrame(true, '#fff', 1);
     $graph_circ->SetBox(false);
     $p1 = new PiePlot($data_circ);
     $p1->ExplodeSlice(0);
     $p1->SetCenter(0.5);
     //$p1->SetLegends('Correctas','Incorrectas','Omitidas');
     $p1->SetLegends($columnas_circ);
     // No border
     $p1->ShowBorder(false);
     $graph_circ->legend->SetPos(0.1, 0.996, 'left', 'bottom');
     $graph_circ->legend->SetFrameWeight(1);
     $p1->SetGuideLines(true, false);
     $p1->SetGuideLinesAdjust(1.5);
     $p1->SetLabelType(PIE_VALUE_PER);
     $p1->value->Show();
     $p1->SetSliceColors(array('#1d71b8', '#ea1d25', 'orange'));
     $graph_circ->Add($p1);
     $graph_circ->Stroke(_IMG_HANDLER);
     global $img_graf_dist_resp;
     $this->img_graf_dist_resp = "assets/images/graf_dist_resp.jpg";
     $graph_circ->img->Stream($this->img_graf_dist_resp);
     /*
     $graph_circ->img->Headers();
     $graph_circ->img->Stream();
     */
 }
Exemple #6
0
 public function create_graph($width = 600, $height = 200, $data, $title, $xaxis, $yaxis, $type = "bar")
 {
     require_once 'jpgraph/jpgraph.php';
     require_once 'jpgraph/jpgraph_line.php';
     require_once 'jpgraph/jpgraph_bar.php';
     require_once 'jpgraph/jpgraph_pie.php';
     // Create a graph instance
     if ($type == "bar" || $type == "line") {
         $graph = new Graph($width, $height);
     } else {
         if ($type == "pie") {
             $graph = new PieGraph($width, $height);
         }
     }
     // Specify what scale we want to use,
     // int = integer scale for the X-axis
     // int = integer scale for the Y-axis
     $graph->SetScale('intint');
     $graph->SetMarginColor("lightblue:1.1");
     $graph->SetShadow();
     $graph->SetMargin(60, 20, 10, 40);
     // Box around plotarea
     $graph->SetBox();
     // No frame around the image
     $graph->SetFrame(false);
     // Setup a title for the graph
     $graph->title->Set($title);
     $graph->title->SetMargin(8);
     $graph->title->SetColor("darkred");
     // Setup the X and Y grid
     $graph->ygrid->SetFill(true, '#DDDDDD@0.5', '#BBBBBB@0.5');
     $graph->ygrid->SetLineStyle('dashed');
     $graph->ygrid->SetColor('gray');
     $graph->xgrid->Show();
     $graph->xgrid->SetLineStyle('dashed');
     $graph->xgrid->SetColor('gray');
     // Setup titles and X-axis labels, if it's array, first row is title
     if (is_array($xaxis)) {
         $graph->xaxis->title->Set($xaxis[0]);
         $xaxis = array_slice($xaxis, 1, count($xaxis) - 1);
         $graph->xaxis->SetTickLabels($xaxis);
     } else {
         $graph->xaxis->title->Set($xaxis);
     }
     // no array, just show name
     // Setup Y-axis title
     $graph->yaxis->title->SetMargin(10);
     $graph->yaxis->title->Set($yaxis);
     if ($type == "bar") {
         $plot = new BarPlot($data);
         $plot->SetWidth(0.6);
         $fcol = '#440000';
         $tcol = '#FF9090';
         $plot->SetFillGradient("navy:0.9", "navy:1.85", GRAD_LEFT_REFLECTION);
         //$plot->SetColor("black");
         // Set line weigth to 0 so that there are no border
         // around each bar
         $plot->SetWeight(0);
         // Add the plot to the graph
         $graph->Add($plot);
     } else {
         if ($type == "line") {
             $plot = new LinePlot($data);
             $plot->SetFillColor('skyblue@0.5');
             $plot->SetColor('navy@0.7');
             $plot->mark->SetType(MARK_SQUARE);
             $plot->mark->SetColor('blue@0.5');
             $plot->mark->SetFillColor('lightblue');
             $plot->mark->SetSize(5);
             // Add the plot to the graph
             $graph->Add($plot);
         } else {
             if ($type == "pie") {
                 $plot = new PiePlot($data);
                 $plot->SetCenter(0.5, 0.55);
                 $plot->SetSize(0.2);
                 // Enable and set policy for guide-lines
                 $plot->SetGuideLines();
                 $plot->SetGuideLinesAdjust(1.4);
                 // Setup the labels
                 $plot->SetLabelType(PIE_VALUE_PER);
                 $plot->value->Show();
                 //$plot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
                 $plot->value->SetFormat('%2.1f%%');
                 $plot->ExplodeSlice(1);
                 $plot->SetGuideLines(true);
                 $graph->SetMarginColor("white");
                 $plot->SetLegends($xaxis);
                 // Add the plot to the graph
                 $graph->Add($plot);
             } else {
                 die($type . " is not known graph type");
             }
         }
     }
     // Display the graph
     $fn = strtolower($title);
     $fn = str_replace(" ", "", $fn);
     $filename_relative = "site/web_app/images/dynamic/{$fn}.jpg";
     $filename_full = __DIR__ . "/" . $filename_relative;
     $graph->Stroke($filename_full);
     $imglink = "<img src='{$filename_relative}' title='{$title}' />\n";
     return $imglink;
 }
Exemple #7
0
     }
     require_once 'core/jpgraph/jpgraph_pie.php';
     // Get data
     $wins = $db->GetRow("SELECT mapstat_alien_wins,\n                                mapstat_human_wins,\n                                mapstat_ties + mapstat_draws AS ties\n                         FROM map_stats WHERE mapstat_id = ?", array($_GET['map_id']));
     if ($wins['mapstat_alien_wins'] + $wins['mapstat_human_wins'] + $wins['ties'] > 0) {
         $data = array($wins['mapstat_alien_wins'], $wins['mapstat_human_wins'], $wins['ties']);
     } else {
         $data = array(0, 0, 1);
     }
     // Build graph
     $g = new PieGraph(200, 120);
     $g->SetMargin(30, 30, 10, 25);
     $g->SetMarginColor('#22262a');
     $g->SetColor('#22262a');
     $g->SetFrame(true, array(0, 0, 0), 0);
     $g->SetBox(false);
     // Build plot
     $p1 = new PiePlot($data);
     $p1->SetCenter(40, 60);
     $p1->SetSliceColors(array('#CC0000', '#0055FF', '#888888'));
     $p1->value->show(false);
     $legends = array('Aliens (%d%%)', 'Humans (%d%%)', 'Tied (%d%%)');
     $p1->SetLegends($legends);
     $g->legend->SetShadow(false);
     $g->legend->SetAbsPos(10, 60, 'right', 'center');
     // Stroke
     $g->Add($p1);
     $g->Stroke();
     break;
 case 'map_balance':
     if (!isset($_GET['map_id'])) {
Exemple #8
0
 public function grafico_3_bd()
 {
     require_once APPPATH . '/libraries/JpGraph/jpgraph_pie.php';
     $data_circ = $this->id_asignacionprueba;
     $columnas_circ = array('Correctas', 'Omitidas', 'Incorrectas');
     $graph_circ = new PieGraph(500, 400);
     $graph_circ->title->Set("Grafico 3 - circular o de pastel");
     $graph_circ->SetMarginColor("#fff");
     $graph_circ->SetFrame(true, '#fff', 1);
     $graph_circ->SetBox(false);
     $p1 = new PiePlot($data_circ);
     $p1->ExplodeSlice(0);
     $p1->SetCenter(0.5);
     $p1->SetLegends($this->id_asignacionprueba);
     $graph_circ->legend->SetPos(0.2, 0.99, 'right', 'bottom');
     $graph_circ->legend->SetFrameWeight(1);
     $p1->SetGuideLines(true, false);
     $p1->SetGuideLinesAdjust(1.5);
     $p1->SetLabelType(PIE_VALUE_PER);
     $p1->value->Show();
     $graph_circ->Add($p1);
     $graph_circ->Stroke(_IMG_HANDLER);
     global $fileName_bd_3;
     $this->fileName_bd_3 = "assets/images/grafica_muestra_bd_3.jpg";
     $graph_circ->img->Stream($this->fileName_bd_3);
     /*
     $graph_circ->img->Headers();
     $graph_circ->img->Stream();
     */
 }