0
我用一些數據通過時間來繪製圓,更新過程是好的,但出口不行,這裏是我的代碼部分:爲什麼exit()不能在這裏工作?
function update(data) {
var tmp1 = group.selectAll('.circle').data(data)
tmp1.enter().append('circle')
.attr('cx', function(d) {coords = projection([d.long,d.lat]); return coords[0]})
.attr('cy', function(d) {coords = projection([d.long,d.lat]); return coords[1]})
.attr('r', function(d) { return countScale(d.count)})
.attr("stroke", function(d, i) { return color(d.name, i);})
.attr("stroke-width", 2.3)
.style('fill', function(d) {
if (d.count == 0){ return 'white';}
if (d.count !== 0){ return color(d.name);}
});
tmp1.exit().remove();
}
後,我用setInterval來更新我的數據,但出口不工作,之前的圈子仍然退出。
setInterval(function() { update(nextDay(data)) }, 10);
我解決我的問題,非常感謝,很高興你回答我的問題,你一般更新模式教程幫助了我很多! – DoReMi
很高興我能幫到你。如果我回答了您的問題,請接受帶有複選標記的答案。 – mbostock