require "../../conexion.php"; $datos_genero = array(); $datos_puntaje = array(); $generos = "SELECT SUM(visitas),genero FROM juegos RIGHT JOIN genero_juego ON(juegos.id_genero=genero_juego.id_genero) GROUP BY genero\n"; $resultado_genero = mysql_query($generos) or die("Error" . $generos); while ($array_generos = mysql_fetch_array($resultado_genero)) { array_push($datos_genero, $array_generos['genero']); array_push($datos_puntaje, $array_generos['0']); } //print_r($datos_genero); //print_r($datos_puntaje); //$data = array(40,60,21,33); $graph = new PieGraph(450, 200, "auto"); $graph->img->SetAntiAliasing(); $graph->SetMarginColor('gray'); //$graph->SetShadow(); // Setup margin and titles $graph->title->Set("Cantidad de visitas según género"); $p1 = new PiePlot3D($datos_puntaje); $p1->SetSize(0.35); $p1->SetCenter(0.5); // Setup slice labels and move them into the plot $p1->value->SetFont(FF_FONT1, FS_BOLD); $p1->value->SetColor("black"); $p1->SetLabelPos(0.2); //$nombres=array("pepe","luis","miguel","alberto"); $p1->SetLegends($datos_genero); // Explode all slices $p1->ExplodeAll(); $graph->Add($p1); $graph->Stroke();
} // die(print_r($targ)); $p1->SetCSIMTargets($targ, $alts); // Horizontal: 'left','right','center' // Vertical: 'bottom','top','center' $graph->legend->SetAbsPos(10, 20, 'right', 'top'); // $graph->legend->Pos(0.5,0.5); // $graph->legend->SetColumns(2); $graph->legend->SetFont(FF_VERDANA, FS_NORMAL, 8); // Adjust size and position of plot $p1->SetSize(0.4); $p1->SetCenter(0.39, 0.6); // Setup slice labels and move them into the plot $p1->value->SetFont(FF_FONT1, FS_BOLD); $p1->value->SetColor("darkred"); $p1->SetLabelPos(0.7); // Set perM > 1 below to enable per million labels $perM = 0; if ($perM < 1) { $p1->SetLabelType(PIE_VALUE_ABS); $p1->value->SetFormat("%d"); } else { $p1->SetLabelType(PIE_VALUE_PER); $p1->value->SetFormat(".%dM"); } // Set percentage to enable per percent labels $percentage = 1; if ($percentage > 0) { $p1->SetLabelType(PIE_VALUE_ABS); $p1->value->SetFormat("%d%%"); $p1->SetValueType(PIE_VALUE_PERCENTAGE);
function crearPie($pdf, $verde, $rojo, $ciclos, $alineacion) { $data = array($verde, $rojo); $labels = array("Valores\ndentro de\nnorma\n(%.1f%%)", "Valores\nfuera de\nnorma\n(%.1f%%)"); $graph = new PieGraph(310, 200); $graph->SetShadow(); $graph->title->Set(utf8_decode("Análisis de resultados " . $ciclos)); $graph->title->SetFont(FF_FONT1, FS_BOLD); $p1 = new PiePlot3D($data); $p1->SetSize(0.5); $p1->SetCenter(0.5); $p1->ExplodeAll(15); $p1->SetStartAngle(60); $p1->SetLabels($labels); $p1->SetLabelPos(0); $p1->value->SetColor('black'); $graph->Add($p1); $p1->SetSliceColors(array('green', 'red')); //$graph->Stroke(); $nombreImagen = '' . uniqid() . '.png'; // Display the graph $graph->Stroke($nombreImagen); if ($alineacion === 'C') { $pdf->Image($nombreImagen, 145, 145, 55, 45); } elseif ($alineacion === 'L') { $pdf->Image($nombreImagen, 90, 145, 55, 45); } elseif ($alineacion === 'R') { $pdf->Image($nombreImagen, 195, 145, 55, 45); } elseif ($alineacion === 'C1') { $pdf->Image($nombreImagen, 75, 205, 55, 45); } elseif ($alineacion === 'L1') { $pdf->Image($nombreImagen, 20, 205, 55, 45); } elseif ($alineacion === 'R1') { $pdf->Image($nombreImagen, 125, 205, 55, 45); } elseif ($alineacion === 'C2') { $pdf->Image($nombreImagen, 75, 160, 55, 45); } unlink($nombreImagen); }
$p1 = new PiePlot3D($YchartData); $p1->SetLegends($XchartData); $p1->SetEdge('#333333', 1); $p1->SetTheme('earth'); /* "earth" * "pastel" * "sand" * "water" */ $p1->SetCSIMTargets($chartImageMapLinks, $chartImageMapAlts, $chartImageMapTargets); // Set label format if ($content['showpercent'] == 1) { $p1->SetLabelType(0); $p1->value->SetFormat("%d%%"); } else { $p1->SetLabelType(1); $p1->value->SetFormat("%d"); } // Set label properties $p1->SetLabelPos(1.0); $p1->SetSliceColors(array('#FFF584', '#CBFF84', '#FF6B9E', '#FF9584', '#EAFF84', '#7BFF51', '#51FFA6', '#51FF52', '#6BCFFF', '#5170FF', '#519CFF', '#EAE3AD', '#FFF184', '#8584FF', '#E698FF', '#C384FF', '#FF84EC', '#FF98A3', '#E5C285', '#FFDA98')); $p1->value->SetFont(FF_VERA, FS_NORMAL, 8); $p1->value->SetColor("black"); // Adjust other Pie Properties $p1->SetLabelMargin(5); $p1->SetCenter(0.4, 0.65); $p1->SetSize(0.3); $p1->SetAngle(60); $graph->Add($p1); } else { if ($content['chart_type'] == CHART_BARS_VERTICAL) { // Include additional code filers for this chart! include_once $gl_root_path . "classes/jpgraph/jpgraph_bar.php"; include_once $gl_root_path . "classes/jpgraph/jpgraph_line.php"; // Create Basic Image, and set basic properties!
<?php $rutaJpGraph = "../jpgraph/src"; error_reporting(1); include "{$rutaJpGraph}/jpgraph_pie.php"; include "{$rutaJpGraph}/jpgraph_pie3d.php"; $data = array(1); $graph = new PieGraph(490, 300, "auto"); $graph->img->SetAntiAliasing(); $graph->SetMarginColor('white'); $graph->legend->Pos(0.75, 0.2); // Setup margin and titles $graph->title->SetFont(FF_FONT2, FS_NORMAL1, 5); $graph->title->Set("INFORME PQR "); $p1 = new PiePlot3D($data1y); //$_GET['datoss'][0]); $p1->SetSize(0.35); $p1->SetLabelMargin(5); $p1->SetAngle(65); $p1->SetCenter(0.52, 0.6); $p1->ExplodeSlice(3); // Setup slice labels and move them into the plot //$p1->SetLabelType(PIE_VALUE_ABS); $p1->value->SetFont(FF_FONT1, FS_BOLD, 5); $p1->value->SetColor("black"); $p1->SetLabelPos(0.6); $p1->SetLabels($nombPqrLbl, 0.2); $p1->SetLegends($nombPqr); //$_GET['nombres'][0]); $graph->Add($p1); $graph->Stroke($rutaImagen);
$resultadoDos = mysqli_query($conexion, "select count(*) cantidad2 from disparo where factor=0"); while ($row = mysqli_fetch_array($resultadoDos)) { $dato2 = $row["cantidad2"]; } mysqli_close($conexion); $data = array($dato1, $dato2); $a = array('reales', 'falsas'); $ancho = 600; $alto = 250; //crear la instancia del objeto graph $graph = new PieGraph($ancho, $alto, 'auto'); $graph->img->SetAntiAliasing(); // $graph->SetMarginColor('gray'); $graph->title->Set("Alarmas disparadas reales/falsas"); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); $p1 = new PiePlot3D($data); $p1->SetLegends($a); $p1->SetSize(0.45); $p1->SetCenter(0.5); $p1->SetLabelType(PIE_VALUE_ADJPERCENTAGE); $graph->legend->SetAbsPos(220, 220, 50, 10); $graph->title->SetMargin(20, 50, 50, 100); $p1->value->SetFont(FF_FONT1, FS_BOLD); $p1->value->SetColor("black"); $p1->SetLabelPos(0.5); $graph->Add($p1); $graph->Stroke(); ?>