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