<!DOCTYPE html>
<html>
<head>
  <title>DNS Статистика</title>
  <script src="assets/chart.js"></script>
</head>
<body>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
  <h2>Топ запрашиваемых доменов</h2>
  <canvas id="dnsChart"></canvas>
  <script>
    fetch('api.php')
      .then(res => res.json())
      .then(data => {
        const labels = data.map(d => d.domain);
        const hits = data.map(d => d.hits);
        new Chart(document.getElementById('dnsChart'), {
          type: 'bar',
          data: {
            labels: labels,
            datasets: [{
              label: 'Запросы',
              data: hits,
              backgroundColor: 'rgba(54, 162, 235, 0.6)'
            }]
          }
        });
      });
  </script>
</body>
</html>
