2 つのデータ セットを示すグラフがあります。ユーザーはボタンを押して、別のデータ セットに切り替えることができます。問題は、軸が同じではないことですが、目盛りを更新したいときは、代わりに別の軸の上に重ねるだけです。
http://jsfiddle.net/scottieb/VjHd6/
キービットは最後にあります:
vis.selectAll("axis").remove();
vis.append("svg:g")
.attr("class", "x axis")
.attr("transform", "translate(0, " + (h - margin ) + ")")
.call(d3.svg.axis()
.scale(x)
.tickSize(0)
.tickSubdivide(true)
.tickFormat(formatCurrency)
);
selectAll("g").remove() を試しましたが、次の軸を配置できません。何か案は?