Skip to content

Instantly share code, notes, and snippets.

@ElDeveloper
Created July 21, 2015 06:21
Show Gist options
  • Save ElDeveloper/9564bb8e742565be1cba to your computer and use it in GitHub Desktop.
Save ElDeveloper/9564bb8e742565be1cba to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
var x
(function(){
element = document.body;
$.getScript("http://d3js.org/d3.v3.min.js", function () {
$.getScript("http://d3js.org/topojson.v1.min.js", function () {
$.getScript("http://datamaps.github.io/scripts/0.4.0/datamaps.all.js", function () {
$(element).append('<h1>Thylacinus</h1')
$(element).append('<div id="container" style="position: relative; width: 500px; height: 300px;"></div>')
var rawData = { 'CHN': {count: 2, fillKey: '#f8fdc1'},
'ISR': {count: 4, fillKey: '#e4f4ab'},
'ITA': {count: 13, fillKey: '#acdd8e'},
'BEL': {count: 21, fillKey: '#8ed082'},
'FIN': {count: 23, fillKey: '#89ce80'},
'ZAF': {count: 32, fillKey: '#74c477'},
'MWI': {count: 63, fillKey: '#49af61'},
'USA': {count: 80, fillKey: '#3da559'},
'AUS': {count: 125, fillKey: '#2d914b'},
'BRA': {count: 920, fillKey: '#004529'}, };
var map = new Datamap({
element: document.getElementById('container'),
fills: {
defaultFill: 'gray',
red: 'red',
'#f8fdc1': '#f8fdc1',
'#e4f4ab': '#e4f4ab',
'#acdd8e': '#acdd8e',
'#a4d98a': '#a4d98a',
'#8ed082': '#8ed082',
'#89ce80': '#89ce80',
'#74c477': '#74c477',
'#5db96b': '#5db96b',
'#49af61': '#49af61',
'#3da559': '#3da559',
'#2d914b': '#2d914b',
'#004529': '#004529',
},
geographyConfig: {
// highlightOnHover: false,
highlightBorderColor: '#bada55',
popupTemplate: function(geography, data) {
if (data !== null){
return '<div class="hoverinfo">There were '+ data.count + ' Thylacinus found here' + '</div>';
}
},
highlightBorderWidth: 1
},
data: rawData
});
});
});
});
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment