D3单select和函数调用
D3 single select and function invocation
使用 d3.select()
成功 select 后如何调用函数?
目前我有这个代码:
var selectedCircle = d3.select("circle");
if(selectedCircle) {
// do stuff
}
我希望它是这样的:
d3.select("circle")
.function()(
// do stuff
);
我该怎么做?
P.S
我知道select都具有相似的功能:
d3.selectAll("circle")
.each(function() {
// do stuff
});
选择时调用
https://github.com/mbostock/d3/wiki/Selections#call
d3.select("circle").call(function(selection){
// do stuff on selection
});
使用 d3.select()
成功 select 后如何调用函数?
目前我有这个代码:
var selectedCircle = d3.select("circle");
if(selectedCircle) {
// do stuff
}
我希望它是这样的:
d3.select("circle")
.function()(
// do stuff
);
我该怎么做?
P.S
我知道select都具有相似的功能:
d3.selectAll("circle")
.each(function() {
// do stuff
});
选择时调用
https://github.com/mbostock/d3/wiki/Selections#call
d3.select("circle").call(function(selection){
// do stuff on selection
});