block by zanarmstrong 3b5f766647e15e23e5b8

Stripped adaptation of Jfire.io animation, for teaching purposes

Full Screen

forked from zanarmstrong‘s block: Adaption of Jfire.io animation, for teaching purposes

index.html

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
  <style>

  </style>
</head>

<body>
  <script>

  // created by //jfire.io/animations/2015-03-09/, adapted for demo
var width = 500,
    height = 500,
    n = 20;
    
var margin = {top: 20, right: 10, bottom: 20, left: 10};
var svg = d3.select("body").append("svg")
  .attr("width", width)
  .attr("height", height)

var g = svg.selectAll(".groups")
    .data(d3.range(n))
    .enter().append("g").attr("class", "group");

g.append("path")
    .attr("fill", "none")
    .attr("stroke", "#d1d1d1")
    .attr("stroke-width", 3)
    .attr("d", "M-150,0L150,0");

g.selectAll("ellipse")
    .data([-150, 150])
    .enter().append("ellipse")
    .attr("cx", function(d) { return d; })
    .attr("cy", 0)
    .attr("rx", 10)
    .attr("ry", 7)
    .attr("fill", "#bbb");

// step #1: write a translation and scalar function to replace the xxxx's below 
g.attr("transform", function(d) {return "translate(xxxxxx)scale(xxxxx)";})

// step #2: add time as an element in your translation function to animate
/*
d3.timer(function(time) {
g.attr("transform", function(d) {return "translate(xxxxxx)scale(xxxxx)";})
    });
    */

  </script>
</body>