In code comments for stock chart improvements

This commit is contained in:
Mark Baker 2013-09-15 18:11:48 +01:00
parent 47f3888664
commit 555a4ab828
3 changed files with 9 additions and 11 deletions

View File

@ -52,6 +52,7 @@ class PHPExcel_Chart_DataSeries
const TYPE_RADARCHART = 'radarChart'; const TYPE_RADARCHART = 'radarChart';
const TYPE_BUBBLECHART = 'bubbleChart'; const TYPE_BUBBLECHART = 'bubbleChart';
const TYPE_STOCKCHART = 'stockChart'; const TYPE_STOCKCHART = 'stockChart';
const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym
const GROUPING_CLUSTERED = 'clustered'; const GROUPING_CLUSTERED = 'clustered';
const GROUPING_STACKED = 'stacked'; const GROUPING_STACKED = 'stacked';

View File

@ -518,34 +518,27 @@ class PHPExcel_Chart_Renderer_jpgraph
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
$plotOrder = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder(); $plotOrder = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder();
$seriesPlots = array();
//var_dump($seriesCount);
$dataValues = array(); $dataValues = array();
// Loop through each data series in turn and build the plot arrays
// Loop through each data series in turn
foreach($plotOrder as $i => $v) { foreach($plotOrder as $i => $v) {
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->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;
} }
} }
if(empty($dataValues)) { if(empty($dataValues)) {
return; return;
} }
$dataValuesPlot = array(); $dataValuesPlot = array();
// Flatten the plot arrays to a single dimensional array to work with jpgraph
for($j = 0; $j < count($dataValues[0]); $j++) { for($j = 0; $j < count($dataValues[0]); $j++) {
for($i = 0; $i < $seriesCount; $i++) { for($i = 0; $i < $seriesCount; $i++) {
$dataValuesPlot[] = $dataValues[$i][$j]; $dataValuesPlot[] = $dataValues[$i][$j];
} }
} }
$seriesPlot = new StockPlot($dataValuesPlot); // Set the x-axis labels
$seriesPlot->SetWidth(20);
$labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
if ($labelCount > 0) { if ($labelCount > 0) {
$datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
@ -553,6 +546,9 @@ class PHPExcel_Chart_Renderer_jpgraph
$this->_graph->xaxis->SetTickLabels($datasetLabels); $this->_graph->xaxis->SetTickLabels($datasetLabels);
} }
$seriesPlot = new StockPlot($dataValuesPlot);
$seriesPlot->SetWidth(20);
$this->_graph->Add($seriesPlot); $this->_graph->Add($seriesPlot);
} // function _renderPlotStock() } // function _renderPlotStock()

View File

@ -31,7 +31,8 @@ Fixed in develop branch for release v1.8.0:
- Feature: (amerov) - Implementation of the Excel HLOOKUP() function - Feature: (amerov) - Implementation of the Excel HLOOKUP() function
- Feature: (MBaker) - Added "Quote Prefix" to style settings (Excel2007 Reader and Writer only) - Feature: (MBaker) - Added "Quote Prefix" to style settings (Excel2007 Reader and Writer only)
- Feature: (MBaker) - Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer - Feature: (MBaker) - Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer
- General: (cdhutch) Work item 20055 - remove array_shift in ReferenceHelper::insertNewBefore improves column or row delete speed - General: (cdhutch) Work item 20055 - Remove array_shift in ReferenceHelper::insertNewBefore improves column or row delete speed
- General: (MBaker) - Improve stock chart handling and rendering, with help from Swashata Ghosh
Fixed in develop branch for release v1.7.9: Fixed in develop branch for release v1.7.9: