-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtemplate.js
36 lines (30 loc) · 1023 Bytes
/
template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var margin = {top: 40, right: 40, bottom: 40, left: 40},
width = 960,
height = 500
start = Date.now(),
speed = 0.25;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.attr("class", "canvases")
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var data = [{x:width/2, y:height/2}];
var widthW = width/10;
svg.selectAll(".rects")
.data(data)
.enter().append("rect")
.attr("class", "rect")
.attr("x", -widthW/2)
.attr("y", -widthW/2)
.attr("width", widthW)
.attr("height", widthW)
.attr("transform", function(d) {
return "translate("+ d.x + "," + d.y + ")"})
.style("fill", "steelblue");
d3.timer(function() {
var deg = (Date.now() - start) * speed ;
var transVal = function(d) { return "translate("+ d.x + "," + d.y + ")" + "rotate(" + deg + ")"; }
svg.selectAll(".rect").attr("transform", transVal);
//svg.attr("transform", transVal); // fixed ring*/
});