Skip to content

Commit

Permalink
Data type is num unless one of the values is non-numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyEssence authored Mar 27, 2024
1 parent 6738a06 commit b69dd05
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,13 @@ protected function writeMultipleValuesOrReference(XMLWriter $objWriter, bool $is
// c:strRef / c:numRef
$referenceType = ($isReference ? 'Ref' : 'Lit');

// Get data type from first non-null value
$dataType = array_reduce($values, function ($carry, $item) {
if (!isset($item)) {
return $carry;
// Data type is num unless one of the values is non-numeric
$dataType = 'num';
foreach ($values as $value){
if (!is_numeric($value)){
$dataType = 'str';
}

return is_numeric($item) ? 'num' : 'str';
}, 'num');
}

$objWriter->startElement('c:' . $dataType . $referenceType);

Expand Down

0 comments on commit b69dd05

Please sign in to comment.