xref: /webtrees/resources/views/statistics/other/charts/combo.phtml (revision 8343293f2ed38c29580f5d0f954f80b1addf4121)
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    var callbackComboChart = function () {
20        google.charts.setOnLoadCallback(function () {
21            drawComboChart(
22                '<?= $id ?>',
23                <?= json_encode($data) ?>,
24                <?= json_encode($chart_options) ?>
25            );
26        });
27
28        $(window).resize(function () {
29            drawComboChart(
30                '<?= $id ?>',
31                <?= json_encode($data) ?>,
32                <?= json_encode($chart_options) ?>
33            );
34        });
35    };
36
37    if (
38        document.readyState === "complete" ||
39        (document.readyState !== "loading" && !document.documentElement.doScroll)
40    ) {
41        callbackComboChart();
42    } else {
43        document.addEventListener("DOMContentLoaded", callbackComboChart);
44    }
45
46    </script>
47<?php endif; ?>
48