forked from featherart/d3_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawing_svgs_circles.html
43 lines (39 loc) · 919 Bytes
/
drawing_svgs_circles.html
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
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>D3: Drawing SVG circles with data</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style type="text/css">
/* No style rules here yet */
</style>
</head>
<body>
<div id="append_here"> </div>
<script type="text/javascript">
window.onload = function(){
//Width and height
var w = 500;
var h = 50;
//Data
var dataset = [ 5, 10, 15, 20, 25 ];
//Create SVG element
var svg = d3.select("#append_here")
.append("svg")
.attr("width", 500)
.attr("height", 50);
var circles = svg.selectAll("circle")
.data(dataset)
.enter()
.append("circle");
circles.attr("cx", function(d, i) {
return (i * 50) + 25;
})
.attr("cy", h/2)
.attr("r", function(d) {
return d;
});
}
</script>
</body>
</html>