I would like to create a dynamic graph with several (linear) axes. After the axes have been drawn, I would like (as new data arrives) to change the data domain and redraw / update the axes. Can I select an existing axis with D3 and do this, or should I explicitly store each axis in my code? I hope my question does not confuse.
$.each(chart.YAxes, function (index) {
var yScale, yAxis;
yScale = d3.scale.linear().range([chartHeight, 0]);
yScale.domain([this.YMin, this.YMax]);
yAxis = d3.svg.axis()
.scale(yScale)
.ticks(10, this.Title)
.orient("left");
d3Chart.append("g")
.attr("class", "yAxis " + "y" + this.ID)
.call(yAxis);
......
var myYAxis = d3.select(".y" + yAxis.ID);
var myScale = myYAxis. **
myScale.domain([newYMin, newYMax]);
d3Chart.select(".y" + yAxis.ID)
.transition().duration(300).ease("sin-in-out")
.call(myYAxis);
THX ...
source
share