この質問がばかげているように思われる場合は申し訳ありませんが、それは私を数日間困惑させたので、誰からの簡単な入力でも本当にありがたいです!:)異なるデータセット間を遷移する線グラフをd3.jsで作成しようとしています。ただし、遷移関数を押すと、グラフの元の線とグラフの軸が選択され、すべてが遷移します。selectAll( "path")の代わりにselectAll( "svg:path")を実行しようとしましたが、DOMException 12が返され、選択が存在しなかったことを示しています。
//beginning of code to append axis to graph
graph.append("svg:g").attr("class", "x axis")
//draws the original line on the graph
graph.append("svg:path").attr("d", line(dataset1));
//line function
var line = d3.svg.line()
.x(function(d) {return x(d.age);})
.y(function(d) {return y(d.freq);})
.interpolate("basis");
//transition function
function transition(newData) {
graph.selectAll("path")
.data(newData)
.transition()
.duration(2000)
.attr("d", line(newData));
}
ご回答ありがとうございます!:)