} } // 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'); } // Finally send the graph to the browser $graph->Stroke(); unset($graph);
/** * chartService::renderPiePlot() - draw the Pie type plot * * @param array $data plot data array reference * @param array $xmlArr xml array reference * @return object refernce Pie plot object reference */ public function renderPiePlot(&$data, &$xmlArr) { $id = $xmlArr['ATTRIBUTES']['ID']; $field = $xmlArr['ATTRIBUTES']['FIELD']; $chartType = $xmlArr['ATTRIBUTES']['CHARTTYPE']; $size = $xmlArr['ATTRIBUTES']['SIZE']; $center = $xmlArr['ATTRIBUTES']['CENTER']; $height = $xmlArr['ATTRIBUTES']['HEIGHT']; $angle = $xmlArr['ATTRIBUTES']['ANGLE']; $labelPos = $xmlArr['ATTRIBUTES']['LABELPOS']; $legendField = $xmlArr['ATTRIBUTES']['LAGENDFIELD']; if ($chartType == "Pie") { $plot = new PiePlot($data); $plot->SetLabelPos($labelPos); } else { if ($chartType == "Pie3D") { $plot = new PiePlot3D($data); $plot->SetHeight($height); $plot->SetAngle($angle); } } list($c1, $c2) = explode(',', $center); $plot->SetCenter($c1, $c2); $plot->SetSize($size); $this->_drawString($plot->value, $xmlArr['VALUE']['ATTRIBUTES']['FONT'], $xmlArr['VALUE']['ATTRIBUTES']['COLOR']); return $plot; }
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 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();