<?php include("conn.php");
$page='Pole Managment';?>
<!DOCTYPE html>
<html lang="en">
<?php include("common/head.php")?>
<?php 


$query = "SELECT item_name, sum(total) FROM orders group by item_name";
$res = $conn->query($query);

?>
<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {

        var data = google.visualization.arrayToDataTable([
          ['Country', 'Visits'],
          
          <?php 
while($row=$res->fetch_assoc())
{
    echo "['".$row['item_name']."',".$row['sum(total)']."],";
}

          ?>

        ]);

        var options = {
          title: 'Visits From Countries',
          is3D:true,
        };

        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="piechart" style="width: 900px; height: 500px;"></div>
  </body>
</html>
