Integrate the GEO chart for states in india

34 views
Skip to first unread message

LOGES WARAN

unread,
Aug 26, 2020, 3:17:28 AM8/26/20
to Google Visualization API
Dear all,

       Since I am new to Google charts, I would like to know how to Integrate the GEO chart for states in india in PHP.

          The following PHP not working properly.Can anyone correct me where i went wrongly?

Thanks in advance
R Logeswaran 

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "hitech";
$text="";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
 
?>
<!DOCTYPE HTML>
<html>
<head>
 <meta charset="utf-8">
 <title>
 Create Google Charts
 </title>
 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
 <script type="text/javascript">
 google.load("visualization", "1", {packages:["geochart"]});
 google.setOnLoadCallback(drawRegionsMap);

 function drawRegionsMap() {

 var data = google.visualization.arrayToDataTable([

 ['LOCATION', 'Sales value'],
 <?php 
 //$query = "SELECT count(ip) AS count, country FROM visitors GROUP BY country";
 $query = "SELECT SUM(AMOUNT) AS count, LOCATION FROM SALES_DATA GROUP BY LOCATION ORDER BY LOCATION";

 $exec = mysqli_query($conn,$query);
 while($row = mysqli_fetch_array($exec)){

 echo "['".$row['LOCATION']."',".$row['count']."],";
 }
 ?>
 ]);

 var options = {
 region: 'IN', // India 
            displayMode: 'markers', //If you want to highlight some cities
            resolution: 'provinces', //If you want to display provinces in India
            colorAxis: {colors: ['blue']} //If you want specific color for your markers (cities)
 };

 var chart = new google.visualization.GeoChart(document.getElementById('geochart'));

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

         


Reply all
Reply to author
Forward
0 new messages