require_once "{$jpgraph}/jpgraph_pie3d.php"; // Setup graph $graph = new PieGraph(400, 400, "auto"); $graph->SetAntiAliasing(); $graph->SetMarginColor('#fafafa'); //$graph->SetShadow(); // Setup graph title if ($type == "event") { //$graph->title->Set(gettext("EVENTS RECEIVED")); } elseif ($type == "alarm") { //$graph->title->Set(gettext("ALARMS RECEIVED")); } $graph->title->SetFont(FF_FONT1, FS_BOLD); // Create pie plot $p1 = new PiePlot3d($data); $p1->SetHeight(12); $p1->SetSize(0.3); if (count($labels) > 1) { $p1->SetCenter(0.5, 0.25); } else { $p1->SetCenter(0.57, 0.25); } $p1->SetLegends($legend); $p1->SetLabels($labels); $p1->SetLabelPos(1); $graph->legend->SetPos(0.5, 0.95, 'center', 'bottom'); $graph->legend->SetShadow('#fafafa', 0); $graph->legend->SetFrameWeight(0); $graph->legend->SetFillColor('#fafafa'); $graph->SetFrame(false); $p1->SetSliceColors($colors);
// Some data $data = array(20, 27, 45, 75, 90); // Create the Pie Graph. $graph = new PieGraph(350, 200); $graph->SetShadow(); // Set A title for the plot $graph->title->Set("Example 2 3D Pie plot"); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 18); $graph->title->SetColor("darkblue"); $graph->legend->Pos(0.1, 0.2); // Create 3D pie plot $p1 = new PiePlot3d($data); $p1->SetTheme("sand"); $p1->SetCenter(0.4); $p1->SetSize(0.4); $p1->SetHeight(5); // Adjust projection angle $p1->SetAngle(45); // You can explode several slices by specifying the explode // distance for some slices in an array $p1->Explode(array(0, 40, 0, 30)); // As a shortcut you can easily explode one numbered slice with // $p1->ExplodeSlice(3); $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 10); $p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct")); $graph->Add($p1); $graph->Stroke(); ?>
public function generarReportePastel() { $this->load->model('nivel_model'); $alumPorNivel = $this->nivel_model->alumnosPorNivel(); require_once APPPATH . "libraries/jpgraph/jpgraph.php"; require_once APPPATH . "libraries/jpgraph/jpgraph_pie.php"; require_once APPPATH . "libraries/jpgraph/jpgraph_pie3d.php"; // Pasando el nombre de los niveles a un arreglo llamado dato $i = 0; foreach ($alumPorNivel->result() as $a) { $dato[$i] = $a->nombre; $cuenta[] = $a->total; $exp[$i] = 5; $i++; } // Creando el Grafico de Pastel $graph = new PieGraph(550, 400); $graph->SetShadow(); // Estableciendo el titulo $graph->title->Set("Porcentaje de Alumnos por Nivel"); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 18); $graph->title->SetColor("darkblue"); $graph->legend->Pos(0.3, 0.06); // Crear 3D pie plot $p1 = new PiePlot3d($cuenta); $p1->SetTheme("sand"); $p1->SetCenter(0.5); $p1->SetSize(0.5); $p1->SetHeight(20); #Ancho del pastel // Angulo de inclinaciĆ³n $p1->SetAngle(45); // Distancia entre las partes del pastel $p1->Explode($exp); $p1->value->SetFont(FF_ARIAL, FS_NORMAL, 10); $p1->SetLegends($dato); $graph->Add($p1); $gdImgHandler = $graph->Stroke(_IMG_HANDLER); // Guardando imagen como archivo por default es .png $fileName = "assets/img/reportes/reporte.jpg"; $graph->img->Stream($fileName); redirect(base_url('Alumnos/verReportePastel')); }