1<?php 2 3declare(strict_types=1); 4 5use Fisharebest\Webtrees\I18N; 6 7/** 8 * @var string $chart_color2 9 * @var string $chart_color3 10 * @var string $chart_title 11 * @var array<array> $data 12 * @var string $language 13 * @var string $region 14 */ 15 16$id = 'google-chart-' . bin2hex(random_bytes(8)); 17$name = 'callback_' . bin2hex(random_bytes(12)); 18?> 19 20<?php if (count($data) === 1) : ?> 21 <?= I18N::translate('This information is not available.') ?> 22<?php else : ?> 23 <div class="mb-3"> 24 <div class="card-deck"> 25 <div class="col-12 mb-3"> 26 <div class="card m-0"> 27 <div class="card-header"> 28 <?= $chart_title ?> 29 </div> 30 <div class="card-body"> 31 <div id="<?= $id ?>" title="<?= $chart_title ?>"></div> 32 </div> 33 </div> 34 </div> 35 </div> 36 </div> 37 <script> 38 39 let <?= $name ?> = function () { 40 statistics.drawGeoChart( 41 <?= json_encode($id) ?>, 42 <?= json_encode($data) ?>, 43 { 44 title: <?= json_encode($chart_title) ?>, 45 region: <?= json_encode($region) ?>, 46 colorAxis: { 47 colors: [ 48 <?= json_encode('#' . $chart_color3) ?>, 49 <?= json_encode('#' . $chart_color2) ?> 50 ] 51 } 52 } 53 ); 54 }; 55 56 if (document.readyState === "complete" 57 || (document.readyState !== "loading" && !document.documentElement.doScroll) 58 ) { 59 statistics.init(<?= json_encode($language) ?>); 60 statistics.addCallback(<?= $name ?>); 61 } else { 62 document.addEventListener("DOMContentLoaded", function () { 63 statistics.init(<?= json_encode($language) ?>); 64 statistics.addCallback(<?= $name ?>); 65 }); 66 } 67 68 </script> 69<?php endif; ?> 70