简体   繁体   中英

D3 svg-path transition wiggles around (inclusive jsfiddle)

I want to make a transition between a rect and a circle with d3.js.

my attempt is here: http://jsfiddle.net/8kxBW/1/

But for me that transition doesn't look smooth. Has anyone an idea how to improve the transition?

Is there a easy way to do that?

var circleDAttribute = "m4,15.75c0,-6.90608 5.59392,-12.5 12.5,-12.5c6.90608,0     12.5,5.59392 12.5,12.5c0,6.90608 -5.59392,12.5 -12.5,12.5c-6.90608,0 -12.5,-5.59392 -12.5,-12.5z";
var rectDAttribute = "m1.75,1.75l0,40l80.25,0l-0.25,-40l-80,0z";

d3.select("#pathTransition")
     .append("svg").append("g")
        .attr("transform","translate(60,60)")
     .append("path")
            .attr("d",rectDAttribute)
            .transition()
            .duration(3000)
            .attr("fill","blue")
            .transition()
            .duration(8000)
            .attr("d",circleDAttribute);  

通过超级公式资源管理器,您可以在这些形状和更多形状之间进行转换。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM