Fixed rendering of stock charts with jpgraph

This commit is contained in:
Mark Baker 2013-09-15 12:44:39 +01:00
parent cb5fc9532f
commit 47f3888664
1 changed files with 10 additions and 5 deletions

View File

@ -524,8 +524,8 @@ class PHPExcel_Chart_Renderer_jpgraph
$dataValues = array(); $dataValues = array();
// Loop through each data series in turn // Loop through each data series in turn
for($i = 0; $i < $seriesCount; ++$i) { foreach($plotOrder as $i => $v) {
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues();
foreach($dataValuesX as $j => $dataValueX) { foreach($dataValuesX as $j => $dataValueX) {
$dataValues[$plotOrder[$i]][$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);
$seriesPlot = new StockPlot($dataValuesPlot, $xAxisLabel);
$seriesPlot->SetWidth(20); $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); $this->_graph->Add($seriesPlot);
} // function _renderPlotStock() } // function _renderPlotStock()