Chart writing bugfixes

This commit is contained in:
Mark Baker 2012-07-20 23:53:16 +01:00
parent dd69a5a134
commit 8bcf795e16
5 changed files with 36 additions and 18 deletions

View File

@ -849,7 +849,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
} }
if ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { if ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) {
$this->_writeBubbles($plotSeriesValues, $objWriter); $this->_writeBubbles($plotSeriesValues, $objWriter, $pSheet);
} }
$objWriter->endElement(); $objWriter->endElement();
@ -975,15 +975,17 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$dataValues = $plotSeriesValues->getDataValues(); $dataValues = $plotSeriesValues->getDataValues();
if (!empty($dataValues)) { if (!empty($dataValues)) {
if (!is_array($dataValues)) { // if (!is_array($dataValues)) {
$dataValues = PHPExcel_Calculation_Functions::flattenArray( // echo 'NOT AN ARRAY: ';
PHPExcel_Calculation::getInstance() // var_dump($dataValues);
->calculateFormula('='.$dataValues, // $dataValues = PHPExcel_Calculation_Functions::flattenArray(
NULL, // PHPExcel_Calculation::getInstance()
$pSheet->getCell('A1') // ->calculateFormula('='.$dataValues,
) // NULL,
); // $pSheet->getCell('A1')
} // )
// );
// }
if (is_array($dataValues)) { if (is_array($dataValues)) {
foreach($dataValues as $plotSeriesKey => $plotSeriesValue) { foreach($dataValues as $plotSeriesKey => $plotSeriesValue) {
$objWriter->startElement('c:pt'); $objWriter->startElement('c:pt');
@ -1010,7 +1012,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
* @throws Exception * @throws Exception
*/ */
private function _writeBubbles($plotSeriesValues, $objWriter) private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet)
{ {
if (is_null($plotSeriesValues)) { if (is_null($plotSeriesValues)) {
return; return;
@ -1027,7 +1029,21 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() ); $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() );
$objWriter->endElement(); $objWriter->endElement();
foreach($plotSeriesValues->getDataValues() as $plotSeriesKey => $plotSeriesValue) { $dataValues = $plotSeriesValues->getDataValues();
if (!empty($dataValues)) {
// if (!is_array($dataValues)) {
// echo 'NOT AN ARRAY: ';
// 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) {
$objWriter->startElement('c:pt'); $objWriter->startElement('c:pt');
$objWriter->writeAttribute('idx', $plotSeriesKey ); $objWriter->writeAttribute('idx', $plotSeriesKey );
$objWriter->startElement('c:v'); $objWriter->startElement('c:v');
@ -1035,6 +1051,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
}
}
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();