D3 数据与数据有什么区别? [英] What is the difference D3 datum vs. data?
本文介绍了D3 数据与数据有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能解释一下 D3.js 中 datum() 和 data() 的区别?我看到两者都在使用,但我不确定为什么你应该选择一个而不是另一个?
Can someone please explain the difference between datum() and data() in D3.js? I see both being used and I am not sure why you should choose one over the other?
推荐答案
我在这里找到了 Mike 本人的正确答案:
I found the correct answer here from Mike himself:
如果要将数据绑定到单个 SVG 元素,请使用
If you want to bind your data to a single SVG element, use
(...).data([data])
或
(...).datum(data)
如果要将数据绑定到多个 SVG 元素
If you want to bind your data to multiple SVG elements
(...).data(data).enter().append("svg")
.....
这篇关于D3 数据与数据有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文