1<?php 2declare(strict_types=1); 3 4$id = 'google-chart-' . bin2hex(random_bytes(8)); 5?> 6 7<?= view('statistics/other/chart-setup') ?> 8 9<div id="<?= $id ?>"></div> 10 11<script> 12 13var callbackPieChart = function () { 14 google.charts.setOnLoadCallback(function () { 15 drawPieChart( 16 '<?= $id ?>', 17 <?= json_encode($data) ?>, 18 <?= json_encode($colors) ?>, 19 '<?= $title ?>', 20 '<?= $labeledValueText ?? 'value' ?>' 21 ); 22 }); 23 24 $(window).resize(function () { 25 drawPieChart( 26 '<?= $id ?>', 27 <?= json_encode($data) ?>, 28 <?= json_encode($colors) ?>, 29 '<?= $title ?>', 30 '<?= $labeledValueText ?? 'value' ?>' 31 ); 32 }); 33}; 34 35if ( 36 document.readyState === "complete" || 37 (document.readyState !== "loading" && !document.documentElement.doScroll) 38) { 39 callbackPieChart(); 40} else { 41 document.addEventListener("DOMContentLoaded", callbackPieChart); 42} 43 44</script> 45