PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Helpers/global/chart.php +10 -4 11.0.0 → 11.1.0 View file →
@@ -268,9 +268,9 @@
268 268 $loaded = true;
269 269 }
270 270 }
271 271
272 -function acym_displayRoundChart($percentage, string $type = '', string $class = '', string $topLabel = ''): void
272 +function acym_displayRoundChart($percentage, string $type = '', string $class = '', string $topLabel = '', string $centerText = ''): void
273 273 {
274 274 if (empty($percentage) && $percentage !== 0) {
275 275 return;
276 276 }
@@ -276,8 +276,14 @@
276 276 }
277 277
278 278 acym_initializeChart();
279 279
280 + // A total-based value can exceed 100% (e.g. anonymized opens/clicks): clamp the ring so it never overflows
281 + $gauge = max(0, min(100, (float)$percentage));
282 + if ($centerText === '') {
283 + $centerText = $percentage.'%';
284 + }
285 +
280 286 $randNumber = acym_rand(1000, 9000);
281 287 $id = 'acy_round_chart_rand_id'.$randNumber;
282 288 $idCanvas = 'acy_canvas_rand_id'.$randNumber;
283 289
@@ -375,9 +381,9 @@
375 381 type: 'doughnut',
376 382 data: {
377 383 datasets: [
378 384 {
379 - data: <?php echo json_encode([$percentage, 100 - $percentage]); ?>,
385 + data: <?php echo json_encode([$gauge, 100 - $gauge]); ?>,
380 386 backgroundColor: <?php echo json_encode([$color, "#f1f1f1"]); ?>,
381 387 borderWidth: 0
382 388 }
383 389 ]
@@ -388,9 +394,9 @@
388 394 display: false
389 395 },
390 396 elements: {
391 397 center: {
392 - text: <?php echo json_encode($percentage.'%'); ?>,
398 + text: <?php echo json_encode($centerText); ?>,
393 399 color: '#363636',
394 400 fontStyle: 'Poppins',
395 401 sidePadding: 70
396 402 }
@@ -492,9 +498,9 @@
492 498 type: 'pie',
493 499 data: {
494 500 datasets: [
495 501 {
496 - data: <?php echo json_encode($data); ?>,
502 + data: <?php echo json_encode(array_values($data)); ?>,
497 503 backgroundColor: <?php echo json_encode($colors); ?>,
498 504 }
499 505 ],
500 506 labels: <?php echo json_encode($allLabelsArray); ?>