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); }
function generatePie3D($data, $legend_index = 0, $chartData_index = 1, $image = false, $length = 500, $width = 300, $hasShadow = true, $fontFamily = FF_FONT1, $fontStyle = FS_BOLD, $fontSize = '', $fontColor = 'black') { include_once XHELP_JPGRAPH_PATH . '/jpgraph_pie.php'; include_once XHELP_JPGRAPH_PATH . '/jpgraph_pie3d.php'; $graph = new PieGraph($length, $width); if ($hasShadow) { // Add a shadow to the image $graph->setShadow(); } $graph->title->Set($this->meta['name']); $p1 = new PiePlot3D($data[$chartData_index]); $p1->SetSize(0.3); $p1->SetCenter(0.45); $p1->SetStartAngle(20); $p1->SetAngle(45); $p1->SetLegends($data[$legend_index]); $p1->value->SetFont($fontFamily, $fontStyle, $fontSize); $p1->value->SetColor($fontColor); $p1->SetLabelType(PIE_VALUE_PER); $a = array_search(max($data[$chartData_index]), $data[$chartData_index]); //Find the position of maximum value. $p1->ExplodeSlice($a); // Set graph background image if ($image != false) { $graph->SetBackgroundImage($image, BGIMG_FILLFRAME); } $graph->Add($p1); $graph->Stroke(); }
$graph->SetMarginColor('#FAFAFA'); $graph->legend->SetShadow('#fafafa', 0); //$graph->legend->SetFillColor('#fafafa'); $graph->legend->SetFrameWeight(0); } else { if (intval($w) == 2) { $graph->SetMarginColor('#FFFFFF'); $graph->legend->SetShadow('#FFFFFF', 0); $graph->legend->SetFillColor('#FFFFFF'); $graph->legend->SetFrameWeight(0); } } $p1 = new PiePlot3D($data); $graph->SetFrame(false, '#ffffff'); $p1->SetSize(0.5); $p1->SetStartAngle(290); $p1->SetAngle(50); $p1->SetCenter(0.35); $p1->SetLegends($legend); //$colors=array("#C835ED", "red", "orange", "green", "#eeeeee"); //$colors=array("#C835ED", "red", "orange", "#FFD700", "#F0E68C"); $p1->SetSliceColors($colors); $p1->ExplodeAll(8); //$dplot[0]->SetFillColor("blue"); //$dplot[1]->SetFillColor("green"); //$dplot[2]->SetFillColor("navy"); //$dplot[3]->SetFillColor("orange"); //$dplot[4]->SetFillColor("magenta"); //$dplot[5]->SetFillColor("yellow"); //$dplot[6]->SetFillColor("red"); $graph->Add($p1);
require_once '../../vendor/autoload.php'; \JpGraph\JpGraph::load(); \JpGraph\JpGraph::module('pie'); \JpGraph\JpGraph::module('pie3d'); // 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 4 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(80); // Adjust projection angle $p1->SetAngle(45); // Adjsut angle for first slice $p1->SetStartAngle(45); // As a shortcut you can easily explode one numbered slice with $p1->ExplodeSlice(3); // Setup slice values $p1->value->SetFont(FF_ARIAL, FS_BOLD, 11); $p1->value->SetColor("navy"); $p1->SetLegends(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct")); $graph->Add($p1); $graph->Stroke();