Check existing of PlotLabel before using its method getDataValue()

I'v got that:

Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\FatalError: "Error: Uncaught Error: Call to a member function getDataValue() on bool in .../vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php:337

I've found that it's necessary to check existing of PlotLabel before using its method getDataValue().
This commit is contained in:
Юрий Финкель
2024-06-26 10:59:17 +04:00
committed by GitHub
parent acd0e386e8
commit 36f316856b
@@ -334,8 +334,9 @@ abstract class JpGraphRendererBase implements IRenderer
// Set the appropriate plot marker
$this->formatPointMarker($seriesPlot, $marker);
}
if ($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($index))
if ($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($index)) {
$dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($index)->getDataValue();
}
$seriesPlot->SetLegend($dataLabel);
$seriesPlots[] = $seriesPlot;