You are here

private function PHPExcel_Writer_Excel2007_Chart::_writePlotSeriesValues 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::_writePlotSeriesValues()

Write Plot Series Values

Parameters

PHPExcel_Chart_DataSeriesValues $plotSeriesValues:

PHPExcel_Shared_XMLWriter $objWriter XML Writer:

string $groupType Type of plot for dataseries:

string $dataType Datatype of series values:

PHPExcel_Worksheet $pSheet:

Throws

PHPExcel_Writer_Exception

1 call to PHPExcel_Writer_Excel2007_Chart::_writePlotSeriesValues()
PHPExcel_Writer_Excel2007_Chart::_writePlotGroup in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Chart.php
Write Plot Group (series of related plots)

File

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

Class

PHPExcel_Writer_Excel2007_Chart
PHPExcel_Writer_Excel2007_Chart

Code

private function _writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, $dataType = 'str', PHPExcel_Worksheet $pSheet) {
  if (is_null($plotSeriesValues)) {
    return;
  }
  if ($plotSeriesValues
    ->isMultiLevelSeries()) {
    $levelCount = $plotSeriesValues
      ->multiLevelCount();
    $objWriter
      ->startElement('c:multiLvlStrRef');
    $objWriter
      ->startElement('c:f');
    $objWriter
      ->writeRawData($plotSeriesValues
      ->getDataSource());
    $objWriter
      ->endElement();
    $objWriter
      ->startElement('c:multiLvlStrCache');
    $objWriter
      ->startElement('c:ptCount');
    $objWriter
      ->writeAttribute('val', $plotSeriesValues
      ->getPointCount());
    $objWriter
      ->endElement();
    for ($level = 0; $level < $levelCount; ++$level) {
      $objWriter
        ->startElement('c:lvl');
      foreach ($plotSeriesValues
        ->getDataValues() as $plotSeriesKey => $plotSeriesValue) {
        if (isset($plotSeriesValue[$level])) {
          $objWriter
            ->startElement('c:pt');
          $objWriter
            ->writeAttribute('idx', $plotSeriesKey);
          $objWriter
            ->startElement('c:v');
          $objWriter
            ->writeRawData($plotSeriesValue[$level]);
          $objWriter
            ->endElement();
          $objWriter
            ->endElement();
        }
      }
      $objWriter
        ->endElement();
    }
    $objWriter
      ->endElement();
    $objWriter
      ->endElement();
  }
  else {
    $objWriter
      ->startElement('c:' . $dataType . 'Ref');
    $objWriter
      ->startElement('c:f');
    $objWriter
      ->writeRawData($plotSeriesValues
      ->getDataSource());
    $objWriter
      ->endElement();
    $objWriter
      ->startElement('c:' . $dataType . 'Cache');
    if ($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART && $groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D && $groupType != PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) {
      if ($plotSeriesValues
        ->getFormatCode() !== NULL && $plotSeriesValues
        ->getFormatCode() !== '') {
        $objWriter
          ->startElement('c:formatCode');
        $objWriter
          ->writeRawData($plotSeriesValues
          ->getFormatCode());
        $objWriter
          ->endElement();
      }
    }
    $objWriter
      ->startElement('c:ptCount');
    $objWriter
      ->writeAttribute('val', $plotSeriesValues
      ->getPointCount());
    $objWriter
      ->endElement();
    $dataValues = $plotSeriesValues
      ->getDataValues();
    if (!empty($dataValues)) {
      if (is_array($dataValues)) {
        foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) {
          $objWriter
            ->startElement('c:pt');
          $objWriter
            ->writeAttribute('idx', $plotSeriesKey);
          $objWriter
            ->startElement('c:v');
          $objWriter
            ->writeRawData($plotSeriesValue);
          $objWriter
            ->endElement();
          $objWriter
            ->endElement();
        }
      }
    }
    $objWriter
      ->endElement();
    $objWriter
      ->endElement();
  }
}