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); }
private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) { require_once 'jpgraph_pie.php'; if ($dimensions == '3d') { require_once 'jpgraph_pie3d.php'; } $this->_renderPiePlotArea($doughnut); $iLimit = $multiplePlots ? $groupCount : 1; for ($groupID = 0; $groupID < $iLimit; ++$groupID) { $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); $exploded = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); if ($groupID == 0) { $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); if ($labelCount > 0) { $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount); } } $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); $seriesPlots = array(); // For pie charts, we only display the first series: doughnut charts generally display all series $jLimit = $multiplePlots ? $seriesCount : 1; // Loop through each data series in turn for ($j = 0; $j < $jLimit; ++$j) { $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues(); // Fill in any missing values in the $dataValues array $testCurrentIndex = 0; foreach ($dataValues as $k => $dataValue) { while ($k != $testCurrentIndex) { $dataValues[$testCurrentIndex] = null; ++$testCurrentIndex; } ++$testCurrentIndex; } if ($dimensions == '3d') { $seriesPlot = new PiePlot3D($dataValues); } else { if ($doughnut) { $seriesPlot = new PiePlotC($dataValues); } else { $seriesPlot = new PiePlot($dataValues); } } if ($multiplePlots) { $seriesPlot->SetSize(($jLimit - $j) / ($jLimit * 4)); } if ($doughnut) { $seriesPlot->SetMidColor('white'); } $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]); if (count($datasetLabels) > 0) { $seriesPlot->SetLabels(array_fill(0, count($datasetLabels), '')); } if ($dimensions != '3d') { $seriesPlot->SetGuideLines(false); } if ($j == 0) { if ($exploded) { $seriesPlot->ExplodeAll(); } $seriesPlot->SetLegends($datasetLabels); } $this->_graph->Add($seriesPlot); } } }