From 47f38886647c6cb9322c2aead8339f807265c69c Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sun, 15 Sep 2013 12:44:39 +0100 Subject: [PATCH] Fixed rendering of stock charts with jpgraph --- Classes/PHPExcel/Chart/Renderer/jpgraph.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Classes/PHPExcel/Chart/Renderer/jpgraph.php b/Classes/PHPExcel/Chart/Renderer/jpgraph.php index f2e6e24..9a822e8 100644 --- a/Classes/PHPExcel/Chart/Renderer/jpgraph.php +++ b/Classes/PHPExcel/Chart/Renderer/jpgraph.php @@ -524,8 +524,8 @@ class PHPExcel_Chart_Renderer_jpgraph $dataValues = array(); // Loop through each data series in turn - for($i = 0; $i < $seriesCount; ++$i) { - $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); + foreach($plotOrder as $i => $v) { + $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues(); foreach($dataValuesX as $j => $dataValueX) { $dataValues[$plotOrder[$i]][$j] = $dataValueX; } @@ -543,11 +543,16 @@ class PHPExcel_Chart_Renderer_jpgraph } } - $xAxisLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); - - $seriesPlot = new StockPlot($dataValuesPlot, $xAxisLabel); + $seriesPlot = new StockPlot($dataValuesPlot); $seriesPlot->SetWidth(20); + $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); + } + $this->_graph->Add($seriesPlot); } // function _renderPlotStock()