-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlan.html
More file actions
167 lines (131 loc) · 3.73 KB
/
Copy pathlan.html
File metadata and controls
167 lines (131 loc) · 3.73 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.progress-meter .background {
fill: #ccc;
}
.progress-meter .foreground {
fill: #06D4EC;
}
.progress-meter text {
color: #555;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 20px;
}
.wrapper{
overflow:hidden; /*make sure the wrapper has no dimension*/
margin-bottom:10px;
}
.item{
float:left;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
font-size:18px;
color:#555;
width:200px;
height:150px;
margin:10px;
}
</style>
<body>
<div id="l1" class="item">
English (TOEIC Score)
</div>
<div id="l2" class="item">
French (Native tongue)
</div>
<div id="l3" class="item">
Arabic (Native tongue)
</div>
<script src="./js/d3.v3.js"></script>
<script>
var width = 200,
height = 150,
twoPi = 2 * Math.PI,
progress = 0,
progress2 = 0,
progress3 = 0,
total = 990,
score = 970,
duration = 3000,
formatPercent = d3.format(".0%");
var arc = d3.svg.arc()
.startAngle(0)
.innerRadius(45)
.outerRadius(60);
var svg = d3.select("#l1").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
var meter = svg.append("g")
.attr("class", "progress-meter");
meter.append("path")
.attr("class", "background")
.attr("d", arc.endAngle(twoPi));
var foreground = meter.append("path")
.attr("class", "foreground");
var text = meter.append("text")
.attr("text-anchor", "middle")
.attr("dy", "0.35em");
var i = d3.interpolate(0, score / total);
d3.transition().duration(duration).tween("progress", function() {
return function(t) {
progress = i(t);
foreground.attr("d", arc.endAngle(twoPi * progress));
text.text(~~(progress*total)+"/" +total);
};
});
var arc2 = d3.svg.arc()
.startAngle(0)
.innerRadius(45)
.outerRadius(60);
var svg2 = d3.select("#l2").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
var meter2 = svg2.append("g")
.attr("class", "progress-meter");
meter2.append("path")
.attr("class", "background")
.attr("d", arc2.endAngle(twoPi));
var foreground2 = meter2.append("path")
.attr("class", "foreground");
var text2 = meter2.append("text")
.attr("text-anchor", "middle")
.attr("dy", "0.35em").text("N/A");
var i2 = d3.interpolate(0, 1);
d3.transition().duration(duration/2).delay(duration+1).tween("progress2", function() {
return function(t) {
progress2 = i2(t);
foreground2.attr("d", arc2.endAngle(twoPi * progress2));
};
});
var arc3 = d3.svg.arc()
.startAngle(0)
.innerRadius(45)
.outerRadius(60);
var svg3 = d3.select("#l3").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
var meter3 = svg3.append("g")
.attr("class", "progress-meter");
meter3.append("path")
.attr("class", "background")
.attr("d", arc3.endAngle(twoPi));
var foreground3 = meter3.append("path")
.attr("class", "foreground");
var text3 = meter3.append("text")
.attr("text-anchor", "middle")
.attr("dy", "0.35em").text("N/A");
d3.transition().duration(duration/2).delay(duration*1.5+1).tween("progress3", function() {
return function(t) {
progress3 = i2(t);
foreground3.attr("d", arc3.endAngle(twoPi * progress3));
};
});
</script>
</body>