@@ -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
+ }
290
+
291
+ return $ plotLabel ->getDataValue ();
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,8 +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
- $ dataLabel = $ this -> chart -> getPlotArea ()-> getPlotGroupByIndex ( $ groupID )-> getPlotLabelByIndex ( $ index )-> getDataValue ();
338
- $ seriesPlot ->SetLegend ($ dataLabel );
347
+
348
+ $ seriesPlot ->SetLegend ($ this -> getDataLabel ( $ groupID , $ index ) );
339
349
340
350
$ seriesPlots [] = $ seriesPlot ;
341
351
}
@@ -408,12 +418,8 @@ private function renderPlotBar(int $groupID, ?string $dimensions = '2d'): void
408
418
if ($ dimensions == '3d ' ) {
409
419
$ seriesPlot ->SetShadow ();
410
420
}
411
- if (!$ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotLabelByIndex ($ j )) {
412
- $ dataLabel = '' ;
413
- } else {
414
- $ dataLabel = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotLabelByIndex ($ j )->getDataValue ();
415
- }
416
- $ seriesPlot ->SetLegend ($ dataLabel );
421
+
422
+ $ seriesPlot ->SetLegend ($ this ->getDataLabel ($ groupID , $ j ));
417
423
418
424
$ seriesPlots [] = $ seriesPlot ;
419
425
}
@@ -492,8 +498,7 @@ private function renderPlotScatter(int $groupID, bool $bubble): void
492
498
$ marker = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotValuesByIndex ($ i )->getPointMarker ();
493
499
$ this ->formatPointMarker ($ seriesPlot , $ marker );
494
500
}
495
- $ dataLabel = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotLabelByIndex ($ i )->getDataValue ();
496
- $ seriesPlot ->SetLegend ($ dataLabel );
501
+ $ seriesPlot ->SetLegend ($ this ->getDataLabel ($ groupID , $ i ));
497
502
498
503
$ this ->graph ->Add ($ seriesPlot );
499
504
}
@@ -524,13 +529,12 @@ private function renderPlotRadar(int $groupID): void
524
529
525
530
$ seriesPlot = new RadarPlot (array_reverse ($ dataValuesX ));
526
531
527
- $ dataLabel = $ this ->chart ->getPlotArea ()->getPlotGroupByIndex ($ groupID )->getPlotLabelByIndex ($ i )->getDataValue ();
528
532
$ seriesPlot ->SetColor (self ::$ colourSet [self ::$ plotColour ++]);
529
533
if ($ radarStyle == 'filled ' ) {
530
534
$ seriesPlot ->SetFillColor (self ::$ colourSet [self ::$ plotColour ]);
531
535
}
532
536
$ this ->formatPointMarker ($ seriesPlot , $ marker );
533
- $ seriesPlot ->SetLegend ($ dataLabel );
537
+ $ seriesPlot ->SetLegend ($ this -> getDataLabel ( $ groupID , $ i ) );
534
538
535
539
$ this ->graph ->Add ($ seriesPlot );
536
540
}
0 commit comments