D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
matt-erhart
Full window
Github gist
Chained Transitions
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } </style> </head> <body> <script> // Feel free to change or delete any of the code you see in this editor! var svg = d3.select("body").append("svg") .attr("width", 500) .attr("height", 500) .append('g') var data = d3.range(200).map(d => [Math.random()*d,Math.random()*d ]) var xScale = d3.scaleLinear().domain(d3.extent(data.map(row=>row[0]))).range([0,960]) var yScale = d3.scaleLinear().domain(d3.extent(data.map(row=>row[1]))).range([500,0]) svg.selectAll("circle").data(data).enter().append("circle") .attr('cx',d => xScale(d[0])) .attr('cy',d => yScale(d[1])) .attr('r', 11) .attr('fill', 'black') d3.selectAll("circle").transition() .delay(function(d, i) { return i * 25; }) .on("start", function repeat() { d3.active(this) .attr('cx',(d,i)=>xScale(d[0]/2)) .attr('r',22) .style("fill", "blue") .duration(1681) .transition() .attr('cx',(d,i)=>xScale(d[0]+d[0]/2)) .style("fill", "yellow") .attr('r',5) .duration(1000) }); </script> </body>
https://d3js.org/d3.v4.min.js