Thanks @neptunemo for your suggestion. However, your code is too specific for your problem. I would like to give a general example to better illustrate your idea:
Please view the full code from the d3noob example: https://bl.ocks.org/d3noob/119a138ef9bd1d8f0a8d57ea72355252
Original area generator code:
var area = d3.area() .x(function(d) { return x(d.date); }) .y0(height) .y1(function(d) { return y(d.close); });
Modified area generator code:
var area = function(datum, boolean) { return d3.area() .y0(height) .y1(function (d) { return y(d.close); }) .x(function (d) { return boolean ? x(d.date) : 0; }) (datum); }
datum - receive databoolean - manage:.x() (if you want animation along the x axis).y1() (if you want animation along the y axis)
By setting boolean to false , we can set .x() or .y1() to 0 .
This will help us establish the initial state of the region before starting the transition process.
Modified Area Transition Code:
svg.append("path") .data([data]) .attr("class", "area") .attr("d", d => area(d, false)) .attr("fill", "lightsteelblue") .transition() .duration(2000) .attr("d", d => area(d,true));
Effects?


Note The problem I am facing is that I cannot synchronize the animation of the row and region :(
source share