You are here

public static function PHPExcel_Reader_Excel2007_Chart::readChart in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007/Chart.php \PHPExcel_Reader_Excel2007_Chart::readChart()
1 call to PHPExcel_Reader_Excel2007_Chart::readChart()
PHPExcel_Reader_Excel2007::load in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php
* Loads PHPExcel from file * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007/Chart.php, line 63

Class

PHPExcel_Reader_Excel2007_Chart
PHPExcel_Reader_Excel2007_Chart

Code

public static function readChart($chartElements, $chartName) {
  $namespacesChartMeta = $chartElements
    ->getNamespaces(true);
  $chartElementsC = $chartElements
    ->children($namespacesChartMeta['c']);
  $XaxisLabel = $YaxisLabel = $legend = $title = NULL;
  $dispBlanksAs = $plotVisOnly = NULL;
  foreach ($chartElementsC as $chartElementKey => $chartElement) {
    switch ($chartElementKey) {
      case "chart":
        foreach ($chartElement as $chartDetailsKey => $chartDetails) {
          $chartDetailsC = $chartDetails
            ->children($namespacesChartMeta['c']);
          switch ($chartDetailsKey) {
            case "plotArea":
              $plotAreaLayout = $XaxisLable = $YaxisLable = null;
              $plotSeries = $plotAttributes = array();
              foreach ($chartDetails as $chartDetailKey => $chartDetail) {
                switch ($chartDetailKey) {
                  case "layout":
                    $plotAreaLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta, 'plotArea');
                    break;
                  case "catAx":
                    if (isset($chartDetail->title)) {
                      $XaxisLabel = self::_chartTitle($chartDetail->title
                        ->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
                    }
                    break;
                  case "dateAx":
                    if (isset($chartDetail->title)) {
                      $XaxisLabel = self::_chartTitle($chartDetail->title
                        ->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
                    }
                    break;
                  case "valAx":
                    if (isset($chartDetail->title)) {
                      $YaxisLabel = self::_chartTitle($chartDetail->title
                        ->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat');
                    }
                    break;
                  case "barChart":
                  case "bar3DChart":
                    $barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string');
                    $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
                    $plotSer
                      ->setPlotDirection($barDirection);
                    $plotSeries[] = $plotSer;
                    $plotAttributes = self::_readChartAttributes($chartDetail);
                    break;
                  case "lineChart":
                  case "line3DChart":
                    $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
                    $plotAttributes = self::_readChartAttributes($chartDetail);
                    break;
                  case "areaChart":
                  case "area3DChart":
                    $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
                    $plotAttributes = self::_readChartAttributes($chartDetail);
                    break;
                  case "doughnutChart":
                  case "pieChart":
                  case "pie3DChart":
                    $explosion = isset($chartDetail->ser->explosion);
                    $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
                    $plotSer
                      ->setPlotStyle($explosion);
                    $plotSeries[] = $plotSer;
                    $plotAttributes = self::_readChartAttributes($chartDetail);
                    break;
                  case "scatterChart":
                    $scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string');
                    $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
                    $plotSer
                      ->setPlotStyle($scatterStyle);
                    $plotSeries[] = $plotSer;
                    $plotAttributes = self::_readChartAttributes($chartDetail);
                    break;
                  case "bubbleChart":
                    $bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer');
                    $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
                    $plotSer
                      ->setPlotStyle($bubbleScale);
                    $plotSeries[] = $plotSer;
                    $plotAttributes = self::_readChartAttributes($chartDetail);
                    break;
                  case "radarChart":
                    $radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string');
                    $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
                    $plotSer
                      ->setPlotStyle($radarStyle);
                    $plotSeries[] = $plotSer;
                    $plotAttributes = self::_readChartAttributes($chartDetail);
                    break;
                  case "surfaceChart":
                  case "surface3DChart":
                    $wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean');
                    $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
                    $plotSer
                      ->setPlotStyle($wireFrame);
                    $plotSeries[] = $plotSer;
                    $plotAttributes = self::_readChartAttributes($chartDetail);
                    break;
                  case "stockChart":
                    $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
                    $plotAttributes = self::_readChartAttributes($plotAreaLayout);
                    break;
                }
              }
              if ($plotAreaLayout == NULL) {
                $plotAreaLayout = new PHPExcel_Chart_Layout();
              }
              $plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries);
              self::_setChartAttributes($plotAreaLayout, $plotAttributes);
              break;
            case "plotVisOnly":
              $plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string');
              break;
            case "dispBlanksAs":
              $dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string');
              break;
            case "title":
              $title = self::_chartTitle($chartDetails, $namespacesChartMeta, 'title');
              break;
            case "legend":
              $legendPos = 'r';
              $legendLayout = null;
              $legendOverlay = false;
              foreach ($chartDetails as $chartDetailKey => $chartDetail) {
                switch ($chartDetailKey) {
                  case "legendPos":
                    $legendPos = self::_getAttribute($chartDetail, 'val', 'string');
                    break;
                  case "overlay":
                    $legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean');
                    break;
                  case "layout":
                    $legendLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta, 'legend');
                    break;
                }
              }
              $legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay);
              break;
          }
        }
    }
  }
  $chart = new PHPExcel_Chart($chartName, $title, $legend, $plotArea, $plotVisOnly, $dispBlanksAs, $XaxisLabel, $YaxisLabel);
  return $chart;
}