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