xref: /webtrees/resources/views/statistics/other/charts/combo.phtml (revision d70512ab02636ee884ef6d7907223ed02c754ff5)
1<?php
2
3declare(strict_types=1);
4
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($language) ?>);
29        statistics.addCallback(<?= $name ?>);
30    } else {
31        document.addEventListener("DOMContentLoaded", function () {
32            statistics.init(<?= json_encode($language) ?>);
33            statistics.addCallback(<?= $name ?>);
34        });
35    }
36
37    </script>
38<?php endif; ?>
39