-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathadv_circle.html
More file actions
71 lines (61 loc) · 2.08 KB
/
adv_circle.html
File metadata and controls
71 lines (61 loc) · 2.08 KB
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
64
65
66
67
68
69
70
71
<!-- Author : Ayush Kumar - aykumar@cs.stonybrook.edu -->
<!doctype html>
<html>
<head>
<script src="https://d3js.org/d3.v4.min.js"></script>
</head>
<style>
svg rect {
fill: orange;
}
svg text {
fill:white;
font: 10px sans-serif;
text-anchor: end;
}
</style>
<body>
<script>
var width = 700;
var height = 700;
var data = [10, 15, 20, 25, 30, 18, 26];
// var colors = ['#9999cc','#c2e699','red','blue','#006837','#99dddd','orange'];
var svg = d3.select("body") // Almost same like Bar Chart
.append("svg")
.attr("width", width)
.attr("height", height);
var g = svg.selectAll("g")
.data(data)
.enter()
.append("g")
.attr("transform", function(d, i) {
return "translate(10,0)"; // Tell why We Need
})
g.append("circle")
.attr("cx", function(d, i) {
return i*100 + 50; // Replace the value of 100 with d and see the change
})
.attr("cy", function(d, i) {
return 100;
})
.attr("r", function(d) {
return d*1.5;
})
.attr("fill", function(d, i){
return "red";//colors[i]; // Using an array to assign the color value to each of the element
// try to change the numbers of colors from Color Array and see the change
})
g.append("text")
.attr("x", function(d, i) {
return i * 100 + 55;
})
.attr("y", 105)
.attr("stroke", "black")
.attr("font-size", "12px")
.attr("font-family", "sans-serif")
.text(function(d) {
return d;
});
</script>
</body>
</html>