Last active
July 11, 2017 21:25
-
-
Save karansapolia/6e314520c877bee73748e7e002627987 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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')); | |
chart.draw(data, options); | |
google.visualization.events.addListener(chart, 'select', function() { | |
var selectedItem=chart.getSelection()[0]; | |
if(selectedItem) { | |
var state=data.getValue(selectedItem.row,0); | |
if(state.toLowerCase() == 'gujarat') | |
window.location.href='https://encrypted.google.com/search?hl=en&q=gujarat'; | |
else if(state.toLowerCase() == 'bihar') | |
window.location.href='https://www.google.co.in/?gfe_rd=cr&ei=kUBlWZyzJMfy8Aeg9KuADA&gws_rd=ssl#q=bihar'; | |
} | |
}); | |
}; | |
</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