-
Notifications
You must be signed in to change notification settings - Fork 0
/
circles2.html
63 lines (52 loc) · 1.5 KB
/
circles2.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Little vintage circles</title>
<script type="text/javascript" src="d3.js"></script>
<style type="text/css">
p{
padding: 10px
}
</style>
</head>
<body>
<p>
It is simple but behind, it's not a pixel-picture made on Photoshop and pasted here.
<br>
Behind is an SVG (Scalable Vector Graphic) and a dataset, morphed into size, <em>x</em> and <em>y</em> coordinates.
<br>
This time, the colors are arbitrary chosen (not linked to a data): it because they are so cool. But the things
will go worser...
</p>
<script type="text/javascript">
var w = 800;
var h = 800;
var dataset = [150, 126, 59, 30, 16, 9];
var svg = d3.select("body")
.append('svg')
.attr("width", w)
.attr("height", h);
var circles = svg.selectAll("circle")
.data(dataset)
.enter()
.append("circle")
;
circles.attr("cx", function(d, i){
return (i*60) +200;
})
.attr("cy", function(d, i){
return (i*40) + 200;
})
.attr("r", function (d){
return d;
})
.style("fill", "orangered")
.attr("stroke", "pink")
.attr("stroke-width", function(d){
return d/4
})
;
</script>
</body>
</html>