Skip to content

Instantly share code, notes, and snippets.

@karansapolia
Created July 11, 2017 10:32
Show Gist options
  • Save karansapolia/dd778705fa3747c6f309c3b0885a4a7f to your computer and use it in GitHub Desktop.
Save karansapolia/dd778705fa3747c6f309c3b0885a4a7f to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {
'packages':['geochart'],
});
google.charts.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['State', 'Population'],
['Gujarat', 360000], ['Uttar Pradesh',999], ['Haryana', 34345], ['Andhra Pradesh', 240000],
['Uttarakhand', 234663], ['Himachal Pradesh', 442342], ['Delhi', 32342],
['Madhya Pradesh', 284321], ['Chhattisgarh', 15999],
['Orissa', 425656], ['Kerala', 35234], ['Punjab', 123434],
['West Bengal', 34344], ['Arunachal Pradesh', 6329],
['Tamil Nadu', 99999], ['Bihar', 512111],
['Tripura', 14], ['Jammu and Kashmir', 545434], ['Karnataka', 69999], ['Jharkhand', 34],
['Assam', 1], ['Rajasthan', 200], ['Maharashtra', 44444]
]);
var options = {
region: 'IN', // India
colorAxis: {colors: ['#ffefd5', 'yellow', '#e31b23']},
backgroundColor: '#81d4fa',
datalessRegionColor: '#f8bbd0',
defaultColor: '#f5f5f5',
domain: 'IN',
resolution: 'provinces'
};
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
function myClickHandler(){
var selection = chart.getSelection();
console.log(selection);
google.visualization.events.addListener(chart,'select', myClickHandler);
chart.draw(data, options);
}
};
</script>
</head>
<body>
<div id="geochart-colors" style="width: 700px; height: 433px;"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment