是否可以在转换期间将事件绑定到选择?
例如,假设这是您的更新:
g3.selectAll(".circles")
.data(dataFiltered, function(d){ return d['token']})
.transition().delay(circleDelay).duration(1200)
.attr('r', pointRadius + "px")
.attr('stroke', '#fff')
.attr('stroke-width', 1.5)
.attr("fill",function(d,i){ return (typeof(d[3]) === 'string') ? colorize(d[3]) : null })
.style('cursor',"pointer")
.attr('class',"circles");
它会向链抛出错误.on('mouseover',function mouseoverlogic(){});
在此期间enter().update().exit()
模式,事件可以绑定到现有的选择之前exit()
?
由于过渡是一种特殊类型的选择,因此您不能使用可用于过渡选择的所有方法。相反,使用过渡.each() https://github.com/mbostock/d3/wiki/Transitions#each将处理程序绑定到转换中的元素。
.transition()
.each(function () {
d3.select(this).on('mouseover', function mouseoverlogic() {});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)