私はjavascriptとd3の新機能ですが、私はいくつかの共有コードを使って作業しており、変更しようとしています。ここでD3データに基づくリンクの色を変更しました
は、私が現在持っているものです。
https://gist.github.com/erich-kuehn/2770a7c7c1cd633f6b47ebb21b640f68
のオフに基づいてその:
http://bl.ocks.org/erikhazzard/6201948
を私は新しいフィールドに基づいて、リンクの色を変更しようとしていますステータスと呼ばれるcsvを追加しました。それはOKを介して実行するようだと私はコードをステップインすると、いくつかのリンクを赤といくつかの緑を作るようだが、完了したとき、彼らはすべて緑色に終わる。思考?申し訳ありません、私はこれで本当に新しいです。
//update
for(var i=0, len=links.length; i<len; i++){
if (links[i].status[0][0] === 'red') {
pathArcs.attr({
//d is the points attribute for this path, we'll draw
// an arc between the points using the arc function
d: path
})
.style({
stroke: 'red',
'stroke-width': '2px'
})
// Uncomment this line to remove the transition
.call(lineTransition);
//exit
pathArcs.exit().remove();
}else{
pathArcs.attr({
//d is the points attribute for this path, we'll draw
// an arc between the points using the arc function
d: path
})
.style({
stroke: 'green',
'stroke-width': '2px'
})
// Uncomment this line to remove the transition
.call(lineTransition);
//exit
pathArcs.exit().remove();
}
}
});