我是d3.js新手,我想做一个连续的转换,但不工作
我试图反复循环我的转换,但我不明白代码出了什么问题 我试过使用。在“结束”时重复,但不起作用。 这是我的密码 var edges=d3。选择all'.edge'我是d3.js新手,我想做一个连续的转换,但不工作,d3.js,D3.js,我试图反复循环我的转换,但我不明白代码出了什么问题 我试过使用。在“结束”时重复,但不起作用。 这是我的密码 var edges=d3。选择all'.edge' var indexAndEdge = []; edges.each(function(d, i) { var thisEdgeCount = this.id.substring(4) indexAndEdge.push({ //push index you are at, the edge count
var indexAndEdge = [];
edges.each(function(d, i) {
var thisEdgeCount = this.id.substring(4)
indexAndEdge.push({ //push index you are at, the edge count worked out above and the id
index: i,
count: thisEdgeCount,
id: this.id
})
})
indexAndEdge.sort(function(a, b) {
return a.count - b.count;
});
var count = 0; //set count to 0
function timer() {
setTimeout(function(d) {
if (count < indexAndEdge.length) { //if we havent gone through all edges
d3.select('#' + indexAndEdge[count].id)
.transition()
.duration(4000)
.style('opacity', 0)
.transition()
.duration(5000)
.style('opacity', 1)
.transition()
.duration(6000)
.style('opacity', 2) //select current id from array
count++; //increment count
timer(); //call timer again
}
else {
console.log('repeat') //end
}
}, 1000)
;
}
timer(); //call timer to show paths one by one
</script>
我希望边缘永远持续下去你能为你的问题创建一个代码笔吗?我不熟悉代码笔??你知道怎么做吗?[codepen_embed height=265 theme\u id=0 slug\u hash=QWLrRmX default\u tab=html,result user=Thinker95]查看画笔rel=nofollow noreferrer>codepen.io/Thinker95'>@Thinker95打开。[/codepen_embed]rel=nofollow noreferrer>codepen.io'>画笔。[/codepen_embed]无法访问画笔。您只需在codepen上创建一个帐户。Jsut在那里创建你的笔。保存它,然后共享该页面的URL。好的。非常感谢。马上回来