当元素(element)与数据(data)绑定时,有三种可能
update
:元素与数据数量相等,使用selection.data
方法返回
enter
:没有匹配元素的数据,使用selection.enter
方法返回
exit
:没有匹配数据的元素,使用selection.exit
方法返回
假设有以下数据,现在只有AE索引能匹配上.
var div = d3.selectAll("div").data(vowels, name);
div.exit();
div.enter();
参考:
https://bost.ocks.org/mike/selection/#enter-update-exit