File "chart002.php"

Full Path: /home/analogde/www/MDPH/Json/chart002.php
File size: 1.34 KB
MIME-type: text/html
Charset: utf-8

<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Graphique avec Chart.js</title>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
    <h1>Graphique des valeurs</h1>
    <canvas id="myChart" width="400" height="200"></canvas>
    <script>
        // Tableau de valeurs
        const tab = [0, 6, 37, 46, 57, 81, 98];

        // Générer des labels pour chaque point de données
        const labels = tab.map((_, index) => `Point ${index + 1}`);

        // Configuration du graphique
        const ctx = document.getElementById('myChart').getContext('2d');
        const myChart = new Chart(ctx, {
            type: 'line',
            data: {
                labels: labels,
                datasets: [{
                    label: 'Valeurs',
                    data: tab,
                    borderColor: 'rgba(75, 192, 192, 1)',
                    borderWidth: 1,
                    fill: false
                }]
            },
            options: {
                scales: {
                    x: {
                        beginAtZero: true
                    },
                    y: {
                        beginAtZero: true
                    }
                }
            }
        });
    </script>
</body>
</html>