Skip to content

fix: Handle null value for $plotGroupingType in writePlotGroup #3976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/PhpSpreadsheet/Writer/Xlsx/Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private function writePlotArea(XMLWriter $objWriter, ?PlotArea $plotArea, ?Title

$chartTypes = self::getChartType($plotArea);
$catIsMultiLevelSeries = $valIsMultiLevelSeries = false;
$plotGroupingType = '';
$plotGroupingType = null;
$chartType = null;
foreach ($chartTypes as $chartType) {
$objWriter->startElement('c:' . $chartType);
Expand Down Expand Up @@ -367,7 +367,7 @@ private function writePlotArea(XMLWriter $objWriter, ?PlotArea $plotArea, ?Title
$objWriter->writeAttribute('val', '150');
$objWriter->endElement();

if ($plotGroupingType == 'percentStacked' || $plotGroupingType == 'stacked') {
if ($plotGroupingType === 'percentStacked' || $plotGroupingType === 'stacked') {
$objWriter->startElement('c:overlap');
$objWriter->writeAttribute('val', '100');
$objWriter->endElement();
Expand Down Expand Up @@ -1110,9 +1110,9 @@ private function writePlotSeriesValuesElement(XMLWriter $objWriter, int $val, ?C
* @param string $groupType Type of plot for dataseries
* @param bool $catIsMultiLevelSeries Is category a multi-series category
* @param bool $valIsMultiLevelSeries Is value set a multi-series set
* @param string $plotGroupingType Type of grouping for multi-series values
* @param null|string $plotGroupingType Type of grouping for multi-series values
*/
private function writePlotGroup(?DataSeries $plotGroup, string $groupType, XMLWriter $objWriter, bool &$catIsMultiLevelSeries, bool &$valIsMultiLevelSeries, string &$plotGroupingType): void
private function writePlotGroup(?DataSeries $plotGroup, string $groupType, XMLWriter $objWriter, bool &$catIsMultiLevelSeries, bool &$valIsMultiLevelSeries, ?string &$plotGroupingType): void
{
if ($plotGroup === null) {
return;
Expand Down
Loading