$data['value'][] = $value['var2']; if ($value['var2'] != 0) { // si todos los valores están a 0, el piegraph da el siguiente error 'Illegal pie plot. Sum of all data is zero for pie plot' $temp_activado = true; } } // require_once 'ossim_conf.inc'; $conf = $GLOBALS["CONF"]; $jpgraph = $conf->get_conf("jpgraph_path"); require_once "{$jpgraph}/jpgraph.php"; require_once "{$jpgraph}/jpgraph_pie.php"; require_once "{$jpgraph}/jpgraph_pie3d.php"; // Setup the graph. $graph = new PieGraph(400, 150, "auto"); $graph->SetAntiAliasing(); $graph->SetColor("#fafafa"); $graph->SetFrame(true, '#fafafa', 0); if (isset($temp_activado)) { // Create the bar plots $piePlot3d = new PiePlot3D($data['value']); $piePlot3d->SetSliceColors(array(COLORPIE1, COLORPIE2, COLORPIE3, COLORPIE4, COLORPIE5, COLORPIE6, COLORPIE7, COLORPIE8)); //$piePlot3d->SetAngle(30); $piePlot3d->SetHeight(12); $piePlot3d->SetSize(0.5); $piePlot3d->SetCenter(0.26, 0.4); // Labels //$piePlot3d->SetLabels($data['title'],1); $piePlot3d->SetLegends($data['title']); $graph->Add($piePlot3d); $graph->legend->SetPos(0.01, 0.6, 'right', 'bottom');
private function piePlot($question, $datax, $datay, $width, $height) { include_once BASE . "jpgraph.php"; include_once BASE . "jpgraph_pie.php"; include_once BASE . "jpgraph_pie3d.php"; // Create the Pie Graph. $graph = new PieGraph($width, $height, "auto"); $graph->SetShadow(); // Set A title for the plot $tFontSize = 11; $graph->title->Set($question); $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize); $graph->title->SetColor("darkblue"); $graph->SetAntiAliasing(true); $graph->legend->SetPos(0.02, 0.95, 'right', 'bottom'); $graph->legend->SetMarkAbsSize(5); $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 9); $tWidth = $graph->title->GetWidth($graph->img); //if ($graph->title->GetWidth($graph->img)>$width) $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize-2); if ($tWidth > $width) { $index = strrpos(substr($question, 0, ($len = strlen($question)) / 2 + 5), ' '); //echo $index; if ($index === false) { $index = $len / 2 - 3; } $question[$index] = "\n"; $graph->title->SetFont(FF_VERDANA, FS_BOLD, $tFontSize -= 2); $graph->title->Set($question); } // Create pie plot $pie = new PiePlot3d($datay); $pie->SetTheme("sand"); $pie->SetCenter(0.5, 0.4); $pie->SetSize(($t = $height * 0.005 / $this->amountOfVariants) > 0.5 ? 0.5 : $t); $pie->SetAngle(30); $pie->ExplodeAll(5); $pie->value->SetFont(FF_ARIAL, FS_NORMAL, 10); $pie->SetLegends($datax); $graph->Add($pie); return $graph->Stroke("images/raporty/{$this->id_pytanie}P.png"); }