xref: /webtrees/resources/views/statistics/other/charts/column.phtml (revision bb88f16b1377db732afb12b8b709b3f5f899347a)
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.drawColumnChart(
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