xref: /webtrees/resources/views/statistics/other/charts/combo.phtml (revision e759aebbec359cf7148227a725fea81907659ae8)
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    <?= view('statistics/other/chart-setup') ?>
13
14    <div id="<?= $id ?>" title="<?= $chart_title ?>"></div>
15
16    <script>
17
18    var callbackComboChart = function () {
19        var options = {
20            title: '<?= $chart_title ?? '' ?>',
21            subtitle: '<?= $chart_sub_title ?? '' ?>',
22            vAxis: {
23                title: '<?= $vAxis_title ?? '' ?>'
24            },
25            hAxis: {
26                title: '<?= $hAxis_title ?? '' ?>'
27            },
28            colors: <?= json_encode($colors) ?>
29        };
30
31        google.charts.setOnLoadCallback(function () {
32            drawComboChart(
33                '<?= $id ?>',
34                <?= json_encode($data) ?>,
35                options
36            );
37        });
38
39        $(window).resize(function () {
40            drawComboChart(
41                '<?= $id ?>',
42                <?= json_encode($data) ?>,
43                options
44            );
45        });
46    };
47
48    if (
49        document.readyState === "complete" ||
50        (document.readyState !== "loading" && !document.documentElement.doScroll)
51    ) {
52        callbackComboChart();
53    } else {
54        document.addEventListener("DOMContentLoaded", callbackComboChart);
55    }
56
57    </script>
58<?php endif; ?>
59