You are here

private function PHPExcel_Chart_Renderer_jpgraph::_renderPieChart in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Chart/Renderer/jpgraph.php \PHPExcel_Chart_Renderer_jpgraph::_renderPieChart()
1 call to PHPExcel_Chart_Renderer_jpgraph::_renderPieChart()
PHPExcel_Chart_Renderer_jpgraph::render in vendor/phpoffice/phpexcel/Classes/PHPExcel/Chart/Renderer/jpgraph.php

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Chart/Renderer/jpgraph.php, line 613

Class

PHPExcel_Chart_Renderer_jpgraph
PHPExcel_Chart_Renderer_jpgraph

Code

private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) {
  require_once PHPExcel_Settings::getChartRendererPath() . 'jpgraph_pie.php';
  if ($dimensions == '3d') {
    require_once PHPExcel_Settings::getChartRendererPath() . '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);
    }
  }
}