Instead of trying to use the transition in the form of a region graph, you can apply the scale (x, y) for the whole svg element that you want to animate. The advantage of this approach is that it is not limited to a specific implementation implementation (for example: not path / d 3.area).
There are a few comments:
To avoid the transition behavior (), while working on the field settings, make sure you have a separate "g" element for the transition transformations () to act on
SVG has the origin (0,0) in the upper left corner, so in addition to scaling the SVG area, you need to set the base of the graph
This is shown below:
'g':
var svg = d3.select("#co2").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left, "," + margin.top + ")")
transition (), including setting up the database:
svg .attr("transform", "translate(0," + height + ") scale(1, 0)") .transition().duration(2000) .attr("transform", "translate(0,0) scale(1, 1)");
As always, this is best illustrated by a complete example: http://bl.ocks.org/4239516
source share