<?php
global $votes;
include "includes/security.php";

?>

<!DOCTYPE HTML>
<html lang="it">

<head>
    <title>Login</title>
    <?php require "includes/head.php" ?>
</head>

<body>

<div class="container">
    <h1>Statistiche dei voti</h1>
    <canvas id="statistiche"></canvas>
</div>

<?php require "includes/footer.php" ?>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

<script>
    const ctx = document.getElementById('statistiche');

    new Chart(ctx, {
        type: 'bar',
        data: {
            labels: ['Avengers', 'Wall-E', 'Napoleon'],
            datasets: [{
                label: '# of Votes',
                data: [<?= $votes["avengers"] ?>, <?= $votes["walle"] ?>, <?= $votes["napoleon"] ?>,],
                borderWidth: 1
            }]
        },
        options: {
            scales: {
                y: {
                    beginAtZero: true
                }
            }
        }
    });
</script>

</body>
</html>
