1、enter常用在批量创建元素,当查询的元素不足时,通过enter+append去动态创建跟data数据一致的元素
ref.selectAll('circle') .data(path) .enter() .append('circle') .attr('r', 1) // 通过样式控制大小 .attr('class', `dynamic-canvas-circle ${id}`) .attr('cx', (d: any, i: number) => d[0]) .attr('cy', (d: any, i: number) => d[1])
2、exit
exit跟enter相反,当元素过多,超过data长度,通过exit+remove,删除多余元素
ref.selectAll('circle') .data(path) .enter() .append('circle') .attr('r', 1) // 通过样式控制大小 .attr('class', `dynamic-canvas-circle ${id}`) .attr('cx', (d: any, i: number) => d[0]) .attr('cy', (d: any, i: number) => d[1]) .exit().remove()
3、update 理想状态,不存在该api
12-01
1282
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-17
1803
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交