More chart bugfixing

This commit is contained in:
Mark Baker 2012-07-20 23:13:16 +01:00
parent 946ea73ddb
commit dd69a5a134

View File

@ -83,7 +83,12 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('val', 0);
$objWriter->endElement();
$this->_writePlotArea($pChart->getPlotArea(), $pChart->getXAxisLabel(), $pChart->getYAxisLabel(), $objWriter);
$this->_writePlotArea($pChart->getPlotArea(),
$pChart->getXAxisLabel(),
$pChart->getYAxisLabel(),
$objWriter,
$pChart->getWorksheet()
);
$this->_writeLegend($pChart->getLegend(), $objWriter);
@ -217,7 +222,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea,
PHPExcel_Chart_Title $xAxisLabel = NULL,
PHPExcel_Chart_Title $yAxisLabel = NULL,
$objWriter)
$objWriter,
PHPExcel_Worksheet $pSheet)
{
if (is_null($plotArea)) {
return;
@ -252,7 +258,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->endElement();
}
$this->_writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType);
$this->_writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType, $pSheet);
}
}
@ -664,9 +670,17 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param boolean &$catIsMultiLevelSeries Is category a multi-series category
* @param boolean &$valIsMultiLevelSeries Is value set a multi-series set
* @param string &$plotGroupingType Type of grouping for multi-series values
* @param PHPExcel_Worksheet $pSheet
* @throws Exception
*/
private function _writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType)
private function _writePlotGroup( $plotGroup,
$groupType,
$objWriter,
&$catIsMultiLevelSeries,
&$valIsMultiLevelSeries,
&$plotGroupingType,
PHPExcel_Worksheet $pSheet
)
{
if (is_null($plotGroup)) {
return;
@ -815,7 +829,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('c:cat');
}
$this->_writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str');
$this->_writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str', $pSheet);
$objWriter->endElement();
}
@ -830,7 +844,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('c:val');
}
$this->_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num');
$this->_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num', $pSheet);
$objWriter->endElement();
}
@ -885,9 +899,15 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @param string $groupType Type of plot for dataseries
* @param string $dataType Datatype of series values
* @param PHPExcel_Worksheet $pSheet
* @throws Exception
*/
private function _writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, $dataType='str')
private function _writePlotSeriesValues( $plotSeriesValues,
$objWriter,
$groupType,
$dataType='str',
PHPExcel_Worksheet $pSheet
)
{
if (is_null($plotSeriesValues)) {
return;
@ -956,7 +976,13 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$dataValues = $plotSeriesValues->getDataValues();
if (!empty($dataValues)) {
if (!is_array($dataValues)) {
var_dump($dataValues);
$dataValues = PHPExcel_Calculation_Functions::flattenArray(
PHPExcel_Calculation::getInstance()
->calculateFormula('='.$dataValues,
NULL,
$pSheet->getCell('A1')
)
);
}
if (is_array($dataValues)) {
foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {