What is the difference D3 datum vs. data?

前端 未结 4 1130
广开言路
广开言路 2020-12-04 05:21

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?

4条回答
  •  日久生厌
    2020-12-04 05:57

    I found the correct answer here from Mike himself:

    D3 - how to deal with JSON data structures?

    If you want to bind your data to a single SVG element, use

    (...).data([data])
    

    or

    (...).datum(data)
    

    If you want to bind your data to multiple SVG elements

    (...).data(data).enter().append("svg")
    

    .....

提交回复
热议问题