Advertisement
filip710

z2

Apr 15th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.35 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3.  
  4.   <head>
  5.     <script src="https://d3js.org/d3.v3.min.js"></script>
  6.   </head>
  7.   <body>
  8.   <script>
  9.     function drawCircles() {
  10.         var data = d3.range(10).map(function() {
  11.             return {
  12.                 x: Math.random()*500,
  13.                 y: Math.random()*500
  14.             };
  15.         });
  16.  
  17.         var circles = svg.selectAll("circle")
  18.             .data(data).enter()
  19.             .append("circle")
  20.             .attr("cx", function(d) { return d.x; })
  21.             .attr("cy", function(d) { return d.y; })
  22.             .attr("r", 15)
  23.             .style("fill", "white")
  24.             .style("stroke", "blue");
  25.  
  26.         transitionTime = 0;
  27.  
  28.         circles.each(function(d) {
  29.             let durationTime = Math.random() * 1000 + 400
  30.             d3.select(this).transition().duration(durationTime).style("fill", "#26a69a")
  31.             d3.select(this).transition().delay(durationTime).duration(durationTime).attr("r", width/2).style("opacity", 0)
  32.         })
  33.     }
  34.     var width = 500;
  35.     var height = 500;
  36.     var svg = d3.select("body")
  37.         .append("svg")
  38.         .attr("width", width)
  39.         .attr("height", height)
  40.  
  41.     setInterval(function() {
  42.         setTimeout(drawCircles, 3100)
  43.         setTimeout(svg.selectAll("circle").remove(), 3000)
  44.     }, 3000)
  45.    
  46.    
  47. </script>
  48.   </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement