<!DOCTYPE html>
<html>
<head>
    <title>Dashboard</title>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
    <canvas id="buyersChart"></canvas>
    <script>
        const ctx = document.getElementById('buyersChart').getContext('2d');
        const labels = <?= json_encode(array_column($buyers_data, 'transaction_date')); ?>;
        const new_buyers = <?= json_encode(array_column($buyers_data, 'new_buyers')); ?>;
        const old_buyers = <?= json_encode(array_column($buyers_data, 'old_buyers')); ?>;

        const buyersChart = new Chart(ctx, {
            type: 'bar',
            data: {
                labels: labels,
                datasets: [
                    {
                        label: 'New Buyers',
                        data: new_buyers,
                        backgroundColor: 'rgba(75, 192, 192, 0.5)',
                    },
                    {
                        label: 'Old Buyers',
                        data: old_buyers,
                        backgroundColor: 'rgba(153, 102, 255, 0.5)',
                    }
                ]
            },
            options: {
                responsive: true,
                scales: {
                    y: {
                        beginAtZero: true
                    }
                }
            }
        });
    </script>
</body>
</html>
