-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircles.js
36 lines (29 loc) · 938 Bytes
/
circles.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
36
/*global console:false*/
var circles_obj = (function() {
var data = (function() {
var c = [], i=0;
for (; i < 30; i++) {
c.push(Math.floor(2 + (Math.random() * 25)));
}
return c;
})();
console.log(data);
var h = 300, w = 960;
var x = function() { return Math.floor(Math.random() * (w-50) + 25); };
var y = function() { return Math.floor(Math.random() * (h-60)) + 25; };
//configure the SVG.
var svg = d3.select('#circles')
.append('svg')
.attr('width', w)
.attr('height', h);
//Bind the data and set attribs
svg.selectAll('circles')
.data(data)
.enter().append('circle')
.attr('cx', x)
.attr('cy', y)
.attr('r', function(d) { return d; })
.attr('class', 'circle-section')
.attr('opacity', function() { return Math.random() + 0.15; });
return svg;
})();