0

I have this function to make a d3-geomap that is called when my app first loads. But how do I update the map with new data without redrawing a whole new map?

function buildMap(dataToShow){

        var map = d3.geomap.choropleth()
                .geofile('https://d3-geomap.github.io//d3-geomap/topojson/world/countries.json')
                .colors(colorbrewer.YlGnBu[9]) 
                .column('figure') 
                .format(function(d) {return (Math.round(d * 10) / 10).toFixed(2)+"%";}) 
                .legend(true)
                .unitId('ccode')
                .domain(chartDomain)
                .zoomFactor(5);


         d3.select('#map')
            .datum(dataToShow)
            .call(map.draw, map);
    }
NewToJS
  • 2,011
  • 4
  • 35
  • 62

1 Answers1

1

Say your data is in a column called newData, you then need to make the following call

map.column(newData).update()

This should take care of everything all by itself.