Why does this D3 code add the

element outside the body, instead of inside it?

后端 未结 3 1580
北恋
北恋 2020-12-30 09:43

I\'m learning D3 and have come across an issue using the select operator.

Specifically, why does the following code add the

element outside th

3条回答
  •  自闭症患者
    2020-12-30 10:11

    there is no p element to select, so I would suggest appending the p element before entering your data:

    var pData1 = d3.select("body").append("p")
    
    pData1.data([1])...
    

    do whatever else you need to do after .data, although there is no need to append another p

提交回复
热议问题