Multiple Google geo charts on One Page

multiple geo

Fixing Multiple google geo charts on One page, this tutorial is [solved] your problem.

official https://developers.google.com/chart/interactive/docs/gallery/geomap#overview

A geomap is a map of a country, continent, or region map, with colors and values assigned to specific regions. Values are displayed as a color scale, and you can specify optional hovertext for regions. The map is rendered in the browser using an embedded Flash player. Note that the map is not scrollable or draggable, but can be configured to allow zooming.
tutorial geo chart php mysqli xml

Tutorial  available on Youtube

Data Format

Two address formats are supported, each of which supports a different number of columns, and different data types for each column. All addresses in the table must use one or the other; you cannot mix types.

  • Format 1: Latitude/Longitude locations. This format works only when the dataMode option is ‘markers’. If this format is used, you do not need to include the Google Map Javascript. The location is entered in two columns, plus two optional columns:
    1. [Number, Required] A latitude. Positive numbers are north, negative numbers are south.
    2. [Number, Required] A longitude. Positive numbers are east, negative numbers are west.
    3. [Number, Optional] A numeric value displayed when the user hovers over this region. If column 4 is used, this column is required.
    4. [String, Optional] Additional string text displayed when the user hovers over this region.
  • Format 2: Address, country name, region name locations, or US metropolitan area codes. This format works with the dataMode option set to either ‘markers’ or ‘regions’. The location is entered in one column, plus two optional columns:
    1. [String, Required] A map location. The following formats are accepted:
      • A specific address (for example, “1600 Pennsylvania Ave”).
      • A country name as a string (for example, “England”), or an uppercase ISO-3166 code or its English text equivalent (for example, “GB” or “United Kingdom”).
      • An uppercase ISO-3166-2 region code name or its English text equivalent (for example, “US-NJ” or “New Jersey”). Note: Regions can only be specified when the dataMode option is set to ‘regions’.
      • A metropolitan area code. These are three-digit metro codes used to designate various regions; US codes only supported. Note that these are not the same as telephone area codes.
    2. [Number, Optional] A numeric value displayed when the user hovers over this region. If column 3 is used, this column is required.
    3. [String, Optional] Additional string text displayed when the user hovers over this region.

Tutorial  available on Youtube

 

Advertisements

Fixing Google Geo chart PHP + MYSQLi or XML parser complete tutorials

Fixing Google Geo chart PHP + MYSQLi or XML parser complete tutorials

 

Please Subscribe my Chanel on Youtube:

YouTube-Subscribe

google geo chart

Mysqltable is bellow:

google chart mysql

 

<?php $con = mysqli_connect('localhost','root','','test') or Die(); ?>
<html>
  <head>
   <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([

          ['Country', 'Visits'],
           <?php $query = "SELECT count(ip) AS count, country FROM visitors GROUP BY country"; $exec = mysqli_query($con,$query); while($row = mysqli_fetch_array($exec)){ echo "['".$row['country']."',".$row['count']."],"; } ?>
        ]);

        var options = {
        	
        };

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

        chart.draw(data, options);
      }
    </script>
  
    

   
  </head>
  <body>
 



<h3>Geo Chart</h3>






<div id="geochartsatu" style="width: 900px; height: 500px;"></div>



  
   
         

  </body>
</html>

Google chart 2016 PHP + MYSQLi Connection

Google chart 2016 PHP + MYSQLi Connection theme case is Populer startup in Indonesia (data is Fiktif)

googlechart_php+myqliconnection

 

googlechart


<?php //open connection to mysql db $connection = mysqli_connect("localhost","root","","test") or die("Error " . mysqli_error($connection)); //fetch table rows from mysql db $sql = "select * from populer_startup"; $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection)); //create an array $rows = array(); //flag is not needed $flag = true; $table = array(); $table['cols'] = array( // Labels for your chart, these represent the column titles // Note that one column is in "string" format and another one is in "number" format as pie chart only required "numbers" for calculating percentage and string will be used for column title array('label' => 'Startup', 'type' => 'string'),
    array('label' => 'Users', 'type' => 'number')
 
);
	

	$rows = array();
    while($r =mysqli_fetch_assoc($result))
    {
    $temp = array();
    // the following line will be used to slice the Pie chart
    $temp[] = array('v' => (string) $r['name']); 
 
    // Values of each slice
    $temp[] = array('v' => (int) $r['custommer']);
    $rows[] = array('c' => $temp);
    }
	
  $table['rows'] = $rows;
   $jsonTable = json_encode($table);

?>



<html>
  <head>
    <!--Load the Ajax API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript">
 
    // Load the Visualization API and the piechart package.
    google.load('visualization', '1', {'packages':['corechart']});
 
    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawChart);
 
    function drawChart() {
 
      // Create our data table out of JSON data loaded from server.
      var data = new google.visualization.DataTable(<?=$jsonTable?>);
      var options = {
           title: 'Populer startup in Indonesia. ',
          is3D: 'true',
          width: 800,
          height: 600
        };
      // Instantiate and draw our chart, passing in some options.
      // Do not forget to check your div ID
      var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
      chart.draw(data, options);
    }
    </script>
  </head>
 
  <body>
    <!--this is the div that will hold the pie chart-->

<div id="chart_div"></div>

  </body>
</html>

Google chart + php + mysql lanjutan 2

Tutorial google chart untuk php dan mysql
donatgchart_sql


<?php /* Script : PHP-JSON-MySQLi-GoogleChart Author : Enam Hossain version : 1.0 */ /* -------------------------------------------------------------------- Usage: -------------------------------------------------------------------- Requirements: PHP, Apache and MySQL Installation: --- Create a database by using phpMyAdmin and name it "chart" --- Create a table by using phpMyAdmin and name it "googlechart" and make sure table has only two columns as I have used two columns. However, you can use more than 2 columns if you like but you have to change the code a little bit for that --- Specify column names as follows: "weekly_task" and "percentage" --- Insert some data into the table --- For the percentage column only use a number --------------------------------- example data: Table (googlechart) --------------------------------- weekly_task percentage ----------- ---------- Sleep 30 Watching Movie 10 job 40 Exercise 20 */ /* Establish the database connection */ // $mysqli = new mysqli_connect('127.0.0.1:3306', 'root', 'root', 'test'); /* if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } */ $mysqli =mysqli_connect('localhost', 'root', '', 'rumahsakit'); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: ".mysqli_connect_error(); } /* select all the weekly tasks from the table googlechart */ $result = $mysqli->query(' SELECT tgldaftar, COUNT( * ) AS count, SUM( 100 ) / total AS percentage
FROM t_pasien CROSS JOIN (
SELECT COUNT( * ) AS total
FROM t_pasien ) x GROUP BY MONTH( tgldaftar )
 ');

  /*
      ---------------------------
      example data: Table (googlechart)
      --------------------------
      Weekly_Task     percentage
      Sleep           30
      Watching Movie  10
      job             40
      Exercise        20
  */

  $rows = array();
  $table = array();
  $table['cols'] = array(

    // Labels for your chart, these represent the column titles.
    /*
        note that one column is in "string" format and another one is in "number" format
        as pie chart only required "numbers" for calculating percentage
        and string will be used for Slice title
    */
    array('label' => 'tgldaftar', 'type' => 'string'),
    array('label' => 'percentage', 'type' => 'number')

);
    /* Extract the information from $result */
    foreach($result as $r) {

      $temp = array();

      // The following line will be used to slice the Pie chart

      $temp[] = array('v' => (string) $r['tgldaftar']); 

      // Values of the each slice

      $temp[] = array('v' => (int) $r['percentage']);
      $rows[] = array('c' => $temp);
    }

$table['rows'] = $rows;

// convert data into JSON format
$jsonTable = json_encode($table);
//echo $jsonTable;

?>

    <!--Load the Ajax API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript">

    // Load the Visualization API and the piechart package.
    google.load('visualization', '1', {'packages':['corechart']});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawChart);

    function drawChart() {

      // Create our data table out of JSON data loaded from server.
      var data = new google.visualization.DataTable(<?=$jsonTable?>);
      var options = {
           title: 'jumlah Pasien berdasarkan Periode Bulan',
        //  is3D: 'true',
          width: 550,
          height: 400,
          pieHole: 0.4,
        };
      // Instantiate and draw our chart, passing in some options.
      // Do not forget to check your div ID
      var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
      chart.draw(data, options);
    }
    </script>

    <!--this is the div that will hold the pie chart-->

<div id="donutchart"></div>

line chart from google chart

line
berbagi sorce code line chart php + mysql [google chart]


<?php
/*
Script  : PHP-JSON-MySQLi-GoogleChart
Author  : Enam Hossain
version : 1.0

*/

/*
--------------------------------------------------------------------
Usage:
--------------------------------------------------------------------

Requirements: PHP, Apache and MySQL

Installation:

  --- Create a database by using phpMyAdmin and name it "chart"
  --- Create a table by using phpMyAdmin and name it "googlechart" and make sure table has only two columns as I have used two columns. However, you can use more than 2 columns if you like but you have to change the code a little bit for that
  --- Specify column names as follows: "weekly_task" and "percentage"
  --- Insert some data into the table
  --- For the percentage column only use a number

      ---------------------------------
      example data: Table (googlechart)
      ---------------------------------

      weekly_task     percentage
      -----------     ----------

      Sleep           30
      Watching Movie  10
      job             40
      Exercise        20     


*/

  /* Establish the database connection */
 // $mysqli = new mysqli_connect('127.0.0.1:3306', 'root', 'root', 'test');

/*  if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
  } */

  $mysqli =mysqli_connect('localhost', 'root', '', 'rumahsakit');
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: ".mysqli_connect_error();
}

   /* select all the weekly tasks from the table googlechart */
  $result = $mysqli->query('SELECT * FROM widget_prices
       ');

  /*
      ---------------------------
      example data: Table (googlechart)
      --------------------------
      Weekly_Task     percentage
      Sleep           30
      Watching Movie  10
      job             40
      Exercise        20       
  */



  $rows = array();
  $table = array();
  $table['cols'] = array(

    // Labels for your chart, these represent the column titles.
    /* 
        note that one column is in "string" format and another one is in "number" format 
        as pie chart only required "numbers" for calculating percentage 
        and string will be used for Slice title
    */
    array('label' => 'week', 'type' => 'string'),
    array('label' => 'price', 'type' => 'number')

);
    /* Extract the information from $result */
    foreach($result as $r) {

      $temp = array();

      // The following line will be used to slice the Pie chart
  
     $temp[] = array('v' => (string) $r['week']); 

      // Values of the each slice

      $temp[] = array('v' => (int) $r['price']); 
      $rows[] = array('c' => $temp);
    }

$table['rows'] = $rows;

// convert data into JSON format
$jsonTable = json_encode($table);
//echo $jsonTable;


?>



    <!--Load the Ajax API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript">

    // Load the Visualization API and the piechart package.
    google.load('visualization', '1', {'packages':['corechart']});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawChart);

    function drawChart() {

      // Create our data table out of JSON data loaded from server.
      var data = new google.visualization.DataTable(<?=$jsonTable?>);
      var options = {
           title: 'Analisa Penggunaan Kamar',
           hAxis: {title: 'Minggu ke-', titleTextStyle: {color: 'blue'}},
          is3D: 'true',
          width: 550,
          height: 400
        };
      // Instantiate and draw our chart, passing in some options.
      // Do not forget to check your div ID
      var chart = new google.visualization.LineChart(document.getElementById('chart_line'));
      chart.draw(data, options);
    }
    </script>
 


    <!--this is the div that will hold the pie chart-->
    <div id="chart_line"></div>

google chart + php + mysql

modified on August 2014 GOOGLE CHART + PHP + MYSQL create Infograph with Gchart..

Please my subscribe my chanel

YouTube-Subscribe

Youtube Tutorial Link

Pray for Gaza

table gaza palestina

<?php $con=mysql_connect("localhost","root","") or die("Failed to connect with database!!!!"); mysql_select_db("gaza", $con); $sth = mysql_query("SELECT * FROM death_rate"); $rows = array(); //flag is not needed $flag = true; $table = array(); $table['cols'] = array( // Labels for your chart, these represent the column titles // Note that one column is in "string" format and another one is in "number" format as pie chart only required "numbers" for calculating percentage and string will be used for column title array('label' => 'people', 'type' => 'string'),
    array('label' => 'total', 'type' => 'number')

);

$rows = array();
while($r = mysql_fetch_assoc($sth)) {
    $temp = array();
    // the following line will be used to slice the Pie chart
    $temp[] = array('v' => (string) $r['people']); 

    // Values of each slice
    $temp[] = array('v' => (int) $r['total']);
    $rows[] = array('c' => $temp);
}

$table['rows'] = $rows;
$jsonTable = json_encode($table);
//echo $jsonTable;
?>

<html>
  <head>
    <!--Load the Ajax API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript">

    // Load the Visualization API and the piechart package.
    google.load('visualization', '1', {'packages':['corechart']});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawChart);

    function drawChart() {

      // Create our data table out of JSON data loaded from server.
      var data = new google.visualization.DataTable(<?=$jsonTable?>);
      var options = {
           title: ' Israel genocide in Gaza. ',
          is3D: 'true',
          width: 800,
          height: 600
        };
      // Instantiate and draw our chart, passing in some options.
      // Do not forget to check your div ID
      var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
      chart.draw(data, options);
    }
    </script>
  </head>

  <body>
    <!--this is the div that will hold the pie chart-->

<div id="chart_div"></div>

  </body>
</html>

column gaza

   var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));

create infographic recent news for human solidarity still boycott israel products.

google geo chart

let’s see Google Geo chart Tutorial https://ndesostyle.wordpress.com/2016/03/30/fixing-google-geo-chart-php-mysqli-or-xml-parser-complete-tutorials/