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