You are here

private function PHPExcel_Chart_Renderer_jpgraph::_renderPlotStock in Loft Data Grids 6.2

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

File

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

Class

PHPExcel_Chart_Renderer_jpgraph
PHPExcel_Chart_Renderer_jpgraph

Code

private function _renderPlotStock($groupID) {
  $seriesCount = $this->_chart
    ->getPlotArea()
    ->getPlotGroupByIndex($groupID)
    ->getPlotSeriesCount();
  $plotOrder = $this->_chart
    ->getPlotArea()
    ->getPlotGroupByIndex($groupID)
    ->getPlotOrder();
  $dataValues = array();

  //	Loop through each data series in turn and build the plot arrays
  foreach ($plotOrder as $i => $v) {
    $dataValuesX = $this->_chart
      ->getPlotArea()
      ->getPlotGroupByIndex($groupID)
      ->getPlotValuesByIndex($v)
      ->getDataValues();
    foreach ($dataValuesX as $j => $dataValueX) {
      $dataValues[$plotOrder[$i]][$j] = $dataValueX;
    }
  }
  if (empty($dataValues)) {
    return;
  }
  $dataValuesPlot = array();

  // Flatten the plot arrays to a single dimensional array to work with jpgraph
  for ($j = 0; $j < count($dataValues[0]); $j++) {
    for ($i = 0; $i < $seriesCount; $i++) {
      $dataValuesPlot[] = $dataValues[$i][$j];
    }
  }

  // Set the x-axis labels
  $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);
    $this->_graph->xaxis
      ->SetTickLabels($datasetLabels);
  }
  $seriesPlot = new StockPlot($dataValuesPlot);
  $seriesPlot
    ->SetWidth(20);
  $this->_graph
    ->Add($seriesPlot);
}