1<?php 2 3declare(strict_types=1); 4 5use Fisharebest\Webtrees\I18N; 6 7/** 8 * @var array<mixed> $chart_options 9 * @var array<array> $data 10 * @var string $language 11 */ 12 13$id = 'google-chart-' . bin2hex(random_bytes(8)); 14$name = 'callback_' . bin2hex(random_bytes(12)); 15?> 16 17<?php if (count($data) === 1) : ?> 18 <?= I18N::translate('This information is not available.') ?> 19<?php else : ?> 20 <div id="<?= $id ?>" title="<?= $chart_title ?? '' ?>"></div> 21 <script> 22 23 let <?= $name ?> = function () { 24 statistics.drawComboChart( 25 <?= json_encode($id) ?>, 26 <?= json_encode($data) ?>, 27 <?= json_encode($chart_options) ?> 28 ); 29 }; 30 31 if (document.readyState === "complete" 32 || (document.readyState !== "loading" && !document.documentElement.doScroll) 33 ) { 34 statistics.init(<?= json_encode($language) ?>); 35 statistics.addCallback(<?= $name ?>); 36 } else { 37 document.addEventListener("DOMContentLoaded", function () { 38 statistics.init(<?= json_encode($language) ?>); 39 statistics.addCallback(<?= $name ?>); 40 }); 41 } 42 43 </script> 44<?php endif; ?> 45