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