@@ -281,6 +281,16 @@ private function renderRadarPlotArea(): void
281
281
$ this ->renderTitle ();
282
282
}
283
283
284
+ private function getDataLabel (int $ groupId , int $ index ): mixed
285
+ {
286
+ $ plotLabel = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupId )->getPlotLabelByIndex ($ index );
287
+ if (!$ plotLabel ) {
288
+ return '' ;
289
+ } else {
290
+ return $ plotLabel ->getDataValue ();
291
+ }
292
+ }
293
+
284
294
private function renderPlotLine (int $ groupID , bool $ filled = false , bool $ combination = false ): void
285
295
{
286
296
$ grouping = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotGrouping ();
@@ -334,10 +344,8 @@ private function renderPlotLine(int $groupID, bool $filled = false, bool $combin
334
344
// Set the appropriate plot marker
335
345
$ this ->formatPointMarker ($ seriesPlot , $ marker );
336
346
}
337
- if ($ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotLabelByIndex ($ index )) {
338
- $ dataLabel = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotLabelByIndex ($ index )->getDataValue ();
339
- $ seriesPlot ->SetLegend ($ dataLabel );
340
- }
347
+
348
+ $ seriesPlot ->SetLegend ($ this ->getDataLabel ($ groupID , $ index ));
341
349
342
350
$ seriesPlots [] = $ seriesPlot ;
343
351
}
@@ -410,12 +418,8 @@ private function renderPlotBar(int $groupID, ?string $dimensions = '2d'): void
410
418
if ($ dimensions == '3d ' ) {
411
419
$ seriesPlot ->SetShadow ();
412
420
}
413
- if (!$ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotLabelByIndex ($ j )) {
414
- $ dataLabel = '' ;
415
- } else {
416
- $ dataLabel = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotLabelByIndex ($ j )->getDataValue ();
417
- }
418
- $ seriesPlot ->SetLegend ($ dataLabel );
421
+
422
+ $ seriesPlot ->SetLegend ($ this ->getDataLabel ($ groupID , $ j ));
419
423
420
424
$ seriesPlots [] = $ seriesPlot ;
421
425
}
@@ -494,8 +498,7 @@ private function renderPlotScatter(int $groupID, bool $bubble): void
494
498
$ marker = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotValuesByIndex ($ i )->getPointMarker ();
495
499
$ this ->formatPointMarker ($ seriesPlot , $ marker );
496
500
}
497
- $ dataLabel = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotLabelByIndex ($ i )->getDataValue ();
498
- $ seriesPlot ->SetLegend ($ dataLabel );
501
+ $ seriesPlot ->SetLegend ($ this ->getDataLabel ($ groupID , $ i ));
499
502
500
503
$ this ->graph ->Add ($ seriesPlot );
501
504
}
@@ -526,13 +529,12 @@ private function renderPlotRadar(int $groupID): void
526
529
527
530
$ seriesPlot = new RadarPlot (array_reverse ($ dataValuesX ));
528
531
529
- $ dataLabel = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotLabelByIndex ($ i )->getDataValue ();
530
532
$ seriesPlot ->SetColor (self ::$ colourSet [self ::$ plotColour ++]);
531
533
if ($ radarStyle == 'filled ' ) {
532
534
$ seriesPlot ->SetFillColor (self ::$ colourSet [self ::$ plotColour ]);
533
535
}
534
536
$ this ->formatPointMarker ($ seriesPlot , $ marker );
535
- $ seriesPlot ->SetLegend ($ dataLabel );
537
+ $ seriesPlot ->SetLegend ($ this -> getDataLabel ( $ groupID , $ i ) );
536
538
537
539
$ this ->graph ->Add ($ seriesPlot );
538
540
}
0 commit comments