Skip to content

Instantly share code, notes, and snippets.

@dmachat
Last active April 21, 2016 17:32
Show Gist options
  • Select an option

  • Save dmachat/b75a5a01cfb31cf92cf5 to your computer and use it in GitHub Desktop.

Select an option

Save dmachat/b75a5a01cfb31cf92cf5 to your computer and use it in GitHub Desktop.

Revisions

  1. dmachat revised this gist Sep 26, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -10,12 +10,12 @@
    element: document.getElementById('map'),
    scope: 'usa',
    data: {
    AZ: blue
    AZ: '#A9C0DE'
    },
    done: function(datamap) {
    datamap.svg.selectAll('.datamaps-subunit').on('click', function(geography) {
    var selectedGeo = {};
    selectedGeo[geography.id] = green;
    selectedGeo[geography.id] = '#ED1ADF';
    datamap.updateChoropleth(selectedGeo);
    });
    }
  2. dmachat created this gist Sep 26, 2015.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Demo of a bug that happens when you trigger `updateChoropleth` from a geography click. Fill is updated properly, but per the mouseout functions found at https://github.com/markmarkoh/datamaps/blob/master/src/js/datamaps.js#L523 & https://github.com/markmarkoh/datamaps/blob/master/src/js/datamaps.js#L252, when you mouseout from the just-selected geography, the fill reverts.
    26 changes: 26 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    <!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://rawgithub.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: blue
    },
    done: function(datamap) {
    datamap.svg.selectAll('.datamaps-subunit').on('click', function(geography) {
    var selectedGeo = {};
    selectedGeo[geography.id] = green;
    datamap.updateChoropleth(selectedGeo);
    });
    }
    });
    </script>

    </body>
    </html>