yaph / d3-geomap

A library for creating geographical maps based on D3.js
https://d3-geomap.github.io/
MIT License
132 stars 45 forks source link

onClick event in d3-geomap #45

Closed srh-ocean1991 closed 6 years ago

srh-ocean1991 commented 6 years ago

0 down vote favorite I'm trying to change onclick event in d3-geomap from zoom to another function. How can I do this ?

Thanks

my code is here :

var map = d3.geomap.choropleth()
            .geofile('json/IRN2.json')
            .unitId('fips')
            .projection(function(){return d3.geo.albers().center([51,35]);})
            .column('point')
            .scale(2000)
            .rotate([-40, 0])
            .translate([1.25*width ,-200 ])
            .colors(['green','yellow' , 'pink' ,'red'])
            .domain([0, 20 , 50,100])
            //.clicked(function(){console.log("hiiiiiiiiiiiiiiii");})
            .legend(true);

          d3.select('#map')
            .datum(mydata)
            .call(map.draw, map);
yaph commented 6 years ago

You can try something like this after creating the map object:

map.svg.selectAll('.unit').on('click', function() {console.log('test')})

I just tested this in the browser console for this map. It logs 'test' to the console and removes the zoom behavior.