Skip to content

Instantly share code, notes, and snippets.

@adg29
Forked from dmachat/README.md
Created April 21, 2016 17:32
Show Gist options
  • Save adg29/609f280c2659cde6e6dadaf7175636b7 to your computer and use it in GitHub Desktop.
Save adg29/609f280c2659cde6e6dadaf7175636b7 to your computer and use it in GitHub Desktop.
Map click + updateChoropleth bug
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script src="http://rawgit.com/markmarkoh/datamaps/master/dist/datamaps.usa.min.js"></script>
<div id="map" style="height: 500px; width: 900px;"></div>
<script>
var map = new Datamap({
element: document.getElementById('map'),
scope: 'usa',
data: {
AZ: '#A9C0DE'
},
done: function(datamap) {
datamap.svg.selectAll('.datamaps-subunit').on('click', function(geography) {
var selectedGeo = {};
selectedGeo[geography.id] = '#ED1ADF';
datamap.updateChoropleth(selectedGeo);
});
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment