public function createPlot() { $size = '0.25'; $plot = new \PiePlot($this->data); $plot->SetLegends($this->legends); $plot->SetSize($size); $plot->SetCenter(0.25, 0.32); $plot->ShowBorder(); $plot->SetColor('black'); $this->grafico->add($plot); }
<?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();
require_once "jpgraph/jpgraph_pie.php"; // Some data $data = array(27, 23, 47, 17); // A new graph $graph = new PieGraph(350, 200); $graph->SetShadow(); // Setup title $graph->title->Set("Example of pie plot with absolute labels"); $graph->title->SetFont(FF_FONT1, FS_BOLD); // The pie plot $p1 = new PiePlot($data); // Move center of pie to the left to make better room // for the legend $p1->SetCenter(0.35, 0.5); // No border $p1->ShowBorder(false); // Label font and color setup $p1->value->SetFont(FF_FONT1, FS_BOLD); $p1->value->SetColor("darkred"); // Use absolute values (type==1) $p1->SetLabelType(PIE_VALUE_ABS); // Label format $p1->value->SetFormat("\$%d"); $p1->value->Show(); // Size of pie in fraction of the width of the graph $p1->SetSize(0.3); // Legends $p1->SetLegends(array("May (\$%d)", "June (\$%d)", "July (\$%d)", "Aug (\$%d)")); $graph->legend->Pos(0.05, 0.15); $graph->Add($p1); $graph->Stroke();
if (strlen($lastTLD)) { getColors($colors, $count, $index); } // reset the counter $count = 0; $lastTLD = $tld; } $count++; } if (strlen($lastTLD)) { getColors($colors, $count, $index); } $graph = new PieGraph($width, $height); $graph->SetFrame(false); $graph->SetAntiAliasing(); $pie = new PiePlot($values); // set the actual labels for the wedges $pie->SetLabels($labels, 1.1); if (count($colors)) { $pie->SetSliceColors($colors); } // set other options $pie->SetGuideLines(true, true, true); $graph->title->SetFont(FF_FONT2, FS_BOLD); $graph->title->Set($chartType); $pie->ShowBorder(true, true); $pie->SetSize(0.25); $graph->Add($pie); $graph->img->SetExpired(false); $graph->Stroke(); }
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(); */ }