D3.js已经更新到第五版,
https://www.d3js.org/d3.v5.js
本次分享的是selection.join()
在第三版中,数据绑定过程中,主要的方法是selection.enter()、selection.update()、selection.exit()
当是enter时,需要调用append();
当是update时,需要调用update();
当是exit时,需要调用remove()。
不过上述方法,在修改的时候,需要全部的节点都要更新。为了减少visulation的时间,
d3js.v5版,增加了selection.join()方法,通过arguments(enter, update, exit)进行局
部操作,减少渲染时间,提高效率。如
selection.join(
enter => enter.append();
update=>update;
);
存在则更新(也可以不更新,即把update函数或参数删去即可),不存在的
添加。