我有这个函数来制作 d3-geomap,当我的应用程序首次加载时调用该函数。 但是如何使用新数据更新 map 而不重新绘制整个新 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);
}
最佳答案
假设您的数据位于名为 newData 的列中,那么您需要进行以下调用
map.column(newData).update()
这应该可以自行处理所有事情。
关于javascript - 如何使用新数据更新(但不重绘)d3-geomap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38624829/