Coder Social home page Coder Social logo

Comments (3)

markmarkoh avatar markmarkoh commented on May 29, 2024 1

This should work for the geographies:

   done: function(map) {
            map.svg.selectAll('.datamaps-subunit').on('click', function(geography) {
              console.log( map.options.data[geography.id] );
            });
      }

from datamaps.

ramnathv avatar ramnathv commented on May 29, 2024

Ah. I would never have figured that out! For consistency with the popupTemplate function, do you think it would be better to allow data to also be explicitly passed to the done method. I can work with what you have now, but thought it would be good to keep things consistent.

from datamaps.

markmarkoh avatar markmarkoh commented on May 29, 2024

The first version of datamaps had that, but I ended up removing it.
For it to work, I had to hard code the events datamaps would allow to be emitted, like "click .bubble", "mouseenter .datamap-subunit" and so on. I ended up including the 20 or so events I thought would be used, but the decided to change my approach and allow you to listen to any event with d3's selection.on event handler.

Doing that lose the data parameter, though, and now a lookup is required.

I dislike the inconsistency and think it should be made consistent, and I want to explore some lightweight options, like:
Inside any event handler, d3.select(this).datum() should return the geography as well as the corresponding data value.

I think that's attainable pretty easily, since right now it already provides the geography.

from datamaps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.