私はそれを間違って理解していますか?またはそれはそのようになっているのですか?
元のサークル
d3.select("svg").selectAll('circle')
.data([{'name':'john', 'age': '50'}]).enter().append('circle')
.attr("cx", function(d){return d.age;}).attr("cy", '200').attr("r", '10').attr("fill", 'red');
クリックボタンで下の関数と呼ばれる
function prependValue(){
d3.select("svg").selectAll('circle')
.data([{'name':'peter', 'age': '100'}, {'name':'john', 'age': '50'} ])
.enter().append('circle').attr("cx", function(d){return d.age;}).attr("cy", '200').attr("r", '10').attr("fill", 'green');
}
ピーターの場合はcx=100に緑色の円を追加する必要があると思いますが、ジョンの円の色は緑色に変わります。
私が行った場合
.data([{'name':'john', 'age': '50'}, {'name':'peter', 'age': '100'} ])
すべてが期待どおりに機能します。