D3 datum vs. data有什么区别? [英] What is the difference D3 datum vs. data?

查看:1522
本文介绍了D3 datum vs. data有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释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:

D3 - 如何处理JSON数据结构?

如果要将数据绑定到单个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 datum vs. data有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆