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