Skip to content

Instantly share code, notes, and snippets.

@markmarkoh
Created July 29, 2014 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markmarkoh/9088a2ba212e1dad4bd4 to your computer and use it in GitHub Desktop.
Save markmarkoh/9088a2ba212e1dad4bd4 to your computer and use it in GitHub Desktop.

Seeing that the bubbles json call returns something like:

[
       {name: 'Hot', latitude: 21.32, longitude: 5.32, radius: 10, fillKey: 'gt50'},
       {name: 'Chilly', latitude: -25.32, longitude: 120.32, radius: 18, fillKey: 'lt50'},
       {name: 'Hot again', latitude: 21.32, longitude: -84.32, radius: 8, fillKey: 'gt50'},
]
var election = new Datamap({
scope: 'usa',
element: document.getElementById('container1'),
geographyConfig: {
popupTemplate: function(geo, data) {
return data && data.info && "<div class='hoverinfo'><strong>" + data.info + "</strong></div>";
},
highlightOnHover: false,
borderColor: '#444',
borderWidth: 0.5
},
done: function(map) {
d3.json('/url/for/bubbles/json', function( error, data ) {
if ( error ) {
console.warn(error);
}
map.bubbles(data);
});
},
data: {},
fills: {
'Visited': '#306596',
'neato': '#0fa0fa',
'Trouble': '#bada55',
defaultFill: '#dddddd'
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment