本文介绍了请帮助我理解select()和selectAll()之间的区别,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得我误解了一些非常基本的,这两者之间的区别是什么?

I feel I misunderstand something very basic, what is the difference between those two ?

我没有得到第二个不追加ap标签的原因对我来说。

I didn't get the reason why the second one will not append a p tag for me.

divSelection = d3.select('#div-vis').selectAll('p').data(['dummy']).enter().append('p');

divSelection = d3.select('#div-vis').select('p').data(['dummy']).enter().append('p');


推荐答案

从:

当你说 d3.select(#vis),选择的父节点仍然是文档元素。然后,当您说 selectAll(p)时,您将父节点定义为先前选择的#vis元素,因为selectAll是嵌套运算符。这只发生在selectAll而不是选择。

When you say d3.select("#vis"), the parent node of the selection is still the document element. When you then say selectAll("p"), you define the parent node as the previously-selected #vis element, because selectAll is a nesting operator. That only happens with selectAll and not select.

这篇关于请帮助我理解select()和selectAll()之间的区别,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 17:03