You are here

private function PHPExcel_Writer_Excel2007_Chart::_writePlotArea in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Chart.php \PHPExcel_Writer_Excel2007_Chart::_writePlotArea()

Write Chart Plot Area

Parameters

PHPExcel_Chart_PlotArea $plotArea:

PHPExcel_Chart_Title $xAxisLabel:

PHPExcel_Chart_Title $yAxisLabel:

PHPExcel_Chart_Axis $xAxis:

PHPExcel_Chart_Axis $yAxis:

PHPExcel_Shared_XMLWriter $objWriter XML Writer:

Throws

PHPExcel_Writer_Exception

1 call to PHPExcel_Writer_Excel2007_Chart::_writePlotArea()
PHPExcel_Writer_Excel2007_Chart::writeChart in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Chart.php
Write charts to XML format

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Chart.php, line 235

Class

PHPExcel_Writer_Excel2007_Chart
PHPExcel_Writer_Excel2007_Chart

Code

private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea, PHPExcel_Chart_Title $xAxisLabel = NULL, PHPExcel_Chart_Title $yAxisLabel = NULL, $objWriter, PHPExcel_Worksheet $pSheet, PHPExcel_Chart_Axis $xAxis, PHPExcel_Chart_Axis $yAxis, PHPExcel_Chart_GridLines $majorGridlines, PHPExcel_Chart_GridLines $minorGridlines) {
  if (is_null($plotArea)) {
    return;
  }
  $id1 = $id2 = 0;
  $this->_seriesIndex = 0;
  $objWriter
    ->startElement('c:plotArea');
  $layout = $plotArea
    ->getLayout();
  $this
    ->_writeLayout($layout, $objWriter);
  $chartTypes = self::_getChartType($plotArea);
  $catIsMultiLevelSeries = $valIsMultiLevelSeries = FALSE;
  $plotGroupingType = '';
  foreach ($chartTypes as $chartType) {
    $objWriter
      ->startElement('c:' . $chartType);
    $groupCount = $plotArea
      ->getPlotGroupCount();
    for ($i = 0; $i < $groupCount; ++$i) {
      $plotGroup = $plotArea
        ->getPlotGroupByIndex($i);
      $groupType = $plotGroup
        ->getPlotType();
      if ($groupType == $chartType) {
        $plotStyle = $plotGroup
          ->getPlotStyle();
        if ($groupType === PHPExcel_Chart_DataSeries::TYPE_RADARCHART) {
          $objWriter
            ->startElement('c:radarStyle');
          $objWriter
            ->writeAttribute('val', $plotStyle);
          $objWriter
            ->endElement();
        }
        elseif ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART) {
          $objWriter
            ->startElement('c:scatterStyle');
          $objWriter
            ->writeAttribute('val', $plotStyle);
          $objWriter
            ->endElement();
        }
        $this
          ->_writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType, $pSheet);
      }
    }
    $this
      ->_writeDataLbls($objWriter, $layout);
    if ($chartType === PHPExcel_Chart_DataSeries::TYPE_LINECHART) {

      //	Line only, Line3D can't be smoothed
      $objWriter
        ->startElement('c:smooth');
      $objWriter
        ->writeAttribute('val', (int) $plotGroup
        ->getSmoothLine());
      $objWriter
        ->endElement();
    }
    elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART || $chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D) {
      $objWriter
        ->startElement('c:gapWidth');
      $objWriter
        ->writeAttribute('val', 150);
      $objWriter
        ->endElement();
      if ($plotGroupingType == 'percentStacked' || $plotGroupingType == 'stacked') {
        $objWriter
          ->startElement('c:overlap');
        $objWriter
          ->writeAttribute('val', 100);
        $objWriter
          ->endElement();
      }
    }
    elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
      $objWriter
        ->startElement('c:bubbleScale');
      $objWriter
        ->writeAttribute('val', 25);
      $objWriter
        ->endElement();
      $objWriter
        ->startElement('c:showNegBubbles');
      $objWriter
        ->writeAttribute('val', 0);
      $objWriter
        ->endElement();
    }
    elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) {
      $objWriter
        ->startElement('c:hiLowLines');
      $objWriter
        ->endElement();
      $objWriter
        ->startElement('c:upDownBars');
      $objWriter
        ->startElement('c:gapWidth');
      $objWriter
        ->writeAttribute('val', 300);
      $objWriter
        ->endElement();
      $objWriter
        ->startElement('c:upBars');
      $objWriter
        ->endElement();
      $objWriter
        ->startElement('c:downBars');
      $objWriter
        ->endElement();
      $objWriter
        ->endElement();
    }

    //	Generate 2 unique numbers to use for axId values
    //					$id1 = $id2 = rand(10000000,99999999);
    //					do {
    //						$id2 = rand(10000000,99999999);
    //					} while ($id1 == $id2);
    $id1 = '75091328';
    $id2 = '75089408';
    if ($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART && $chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D && $chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) {
      $objWriter
        ->startElement('c:axId');
      $objWriter
        ->writeAttribute('val', $id1);
      $objWriter
        ->endElement();
      $objWriter
        ->startElement('c:axId');
      $objWriter
        ->writeAttribute('val', $id2);
      $objWriter
        ->endElement();
    }
    else {
      $objWriter
        ->startElement('c:firstSliceAng');
      $objWriter
        ->writeAttribute('val', 0);
      $objWriter
        ->endElement();
      if ($chartType === PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) {
        $objWriter
          ->startElement('c:holeSize');
        $objWriter
          ->writeAttribute('val', 50);
        $objWriter
          ->endElement();
      }
    }
    $objWriter
      ->endElement();
  }
  if ($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART && $chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D && $chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) {
    if ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
      $this
        ->_writeValAx($objWriter, $plotArea, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines);
    }
    else {
      $this
        ->_writeCatAx($objWriter, $plotArea, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $yAxis);
    }
    $this
      ->_writeValAx($objWriter, $plotArea, $yAxisLabel, $chartType, $id1, $id2, $valIsMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines);
  }
  $objWriter
    ->endElement();
}