Skip to content
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

Update JpGraphRendererBase.php - check existing of PlotLabel #4074

Merged
merged 8 commits into from
Jun 30, 2024
Prev Previous commit
Next Next commit
Update JpGraphRendererBase.php
  • Loading branch information
yfinkel committed Jun 26, 2024
commit 17fc6234e6423a2453cfb008888e40dec1f7ebf1
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ private function renderPlotLine(int $groupID, bool $filled = false, bool $combin
}
if ($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($index)) {
$dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($index)->getDataValue();
$seriesPlot->SetLegend($dataLabel);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think seriesPlot->SetLegend($dataLabel) needs to be inside the if statement, otherwise dataLabel will not be defined.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please add a unit test to demonstrate that there was a problem before your fix and you've fixed it.

$seriesPlot->SetLegend($dataLabel);

$seriesPlots[] = $seriesPlot;
}
Expand Down
Loading