| <!DOCTYPE html> | |
| <html> | |
| <script src="http://d3js.org/d3.v3.js" charset="utf-8"></script> | |
| <body> | |
| <script> | |
| var w = 800, h = 800, n = 40 | |
| var svg = d3.select('body').append('svg') | |
| .attr({width: w, height: h}) | |
| var data = d3.range(n) | |
| .map(function(d) { return (d + 1) / n / 2 }) | |
| .sort(function(a, b){ return b - a }) | |
| var g = svg.selectAll('g').data(data) | |
| .enter().append('g') | |
| .attr('transform', function(d) { | |
| return 'translate(' + [ w / 2, h / 2 ] + ') rotate(' + d * 900 + ')' | |
| }) | |
| g.append('rect') | |
| .style('fill', 'none') | |
| .style('stroke', 1) | |
| .attr('x', function(d) { return - w * d * 0.5 }) | |
| .attr('y', function(d) { return -h * d * 0.5 }) | |
| .attr('width', function(d) { return w * d }) | |
| .attr('height', function(d) { return h * d }) | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment