に設定されたノードの位置は、この史上最も単純D3力のレイアウトについて次のようになります。D3 V4:NaNの
const svg = main.append("svg")
.attr("width",500)
.attr("height",500)
.classed("SVG_frame",true)
.append("g")
const nodes = [{id:1},{id:2}];
const simulation = d3.forceSimulation(nodes)
.force("centering",d3.forceCenter([200,200]))
.force("collision",d3.forceCollide(20))
const node = svg
.selectAll("circle")
.data(nodes)
.enter().append("circle")
.attr("r",20)
simulation.on("tick",function() {
console.log(nodes[0].x)
node
.attr("cx",d => d.x)
.attr("cy",d => d.y)
})
そして、まだ、私は最初のフレームに<circle> attribute cx: Expected length, "NaN".
得ます。 (cy
は、シミュレーションが動くことをあきらめるフレーム上の小さなビットを置き換えます)
これは何回か聞かれていますが、フォースシミュレーションがおそらく内部動作を変更したバージョン4には対応していないようです。実際には、ドキュメントでは、位置がNaNのときはthe position is automatically arranged in a "phyllotaxis arrangement" or whateverであるため、これは起こりそうにないかもしれませんが、それはそうです。
誰か手掛かりがありますか?
AAAAAAAAAAAAAAAAAAAAA!出来た! これらの括弧が配列か単にdoc表記であるかどうかはわかりません。今回は前者に行った。 :/私は、別段の記載がない限り、配列が決してないと仮定します。 – Rafael