-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript.js
290 lines (245 loc) · 8.04 KB
/
javascript.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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
$(function() {
var graph = new Graph($("#graph"));
});
var Graph = function (container){
// Variables
var body = d3.select('body');
var margin = { top: 25, right: 300, bottom: 150, left: 200 }; //change position of the graph;
var h = 600 - margin.top - margin.bottom; //height of axis;
var w = 1500 - margin.left - margin.right; //width of axis
var formatPercent = d3.format(','); //format the Y Axis number
d3.csv('data.csv', function (data) {
// Scales
var colorScale = d3.scale.category20()
var xScale = d3.scale.linear()
.domain([
d3.min([0,d3.min(data,function (d) { return d.dataAnalysis })]),
//d3.max([0,d3.max(data,function (d) { return d.dataAnalysis })])
d3.max([0,30])
])
.range([0,w])
var yScale = d3.scale.linear()
.domain([
d3.min([0,d3.min(data,function (d) { return d.teamWork })]),
//d3.max([0,d3.max(data,function (d) { return d.teamWork })])
d3.max([0,30])
])
.range([h,0])
// SVG
var svg = body.append('svg')
.attr('height',h + margin.top + margin.bottom)
.attr('width',w + margin.left + margin.right)
.append('g')
.attr('transform','translate(' + margin.left + ',' + margin.top + ')')
// X-axis
var xAxis = d3.svg.axis()
.scale(xScale)
.tickFormat(formatPercent)
.ticks(5)
.orient('bottom')
// Y-axis
var yAxis = d3.svg.axis()
.scale(yScale)
.tickFormat(formatPercent)
.ticks(5)
.orient('left')
// Circles
var circles = svg.selectAll('circle')
.data(data)
.enter()
.append('circle')
.attr('cx',function (d) { return xScale(d.dataAnalysis) })
.attr('cy',function (d) { return yScale(d.teamWork) })
.attr('r','10')
.attr('stroke','black')
.attr('stroke-width',1)
.attr('fill',function (d,i) { return colorScale(i) })
.on('mouseover', function () {
d3.select(this)
.transition()
.duration(500)
.attr('r',20)
.attr('stroke-width',3)
})
.on('mouseout', function () {
d3.select(this)
.transition()
.duration(500)
.attr('r',10)
.attr('stroke-width',1)
})
.append('title')
.attr("id","toolTipText") // Tooltip
.text( function (d) { return d.Alias +
'\nProgramming Skill: ' +formatPercent(d.programmingSkills) +
'\nDrawing Skill: ' +formatPercent(d.drawingSkill) +
'\nUX Evaluation: ' +formatPercent(d.userEvaluation) +
'\nData Analysis: ' +formatPercent(d.dataAnalysis) +
'\nTeam Work: ' + formatPercent(d.teamWork) })
// X-axis
svg.append('g')
.attr('class','axis')
.attr('transform', 'translate(0,' + h + ')')
.call(xAxis)
.append('text') // X-axis Label
.attr('class','label')
.attr('y',-10)
.attr('x',w)
.attr('dy','.71em')
.attr("id","xLabel")
.style('text-anchor','end')
.text("Data Analysis")
// Y-axis
svg.append('g')
.attr('class', 'axis')
.call(yAxis)
.append('text') // y-axis Label
.attr('class','label')
.attr('transform','rotate(-90)')
.attr('x',0)
.attr('y',5)
.attr('dy','.71em')
.style('text-anchor','end')
.text('Team Work Skill')
})
//Update Data Programming Skill
function updateDataProgrammingSkill() {
d3.csv('data.csv', function (data) {
var svg = d3.select("body").transition();
// Scales
var colorScale = d3.scale.category20()
var xScale = d3.scale.linear()
.domain([
d3.min([0,30]),
d3.max([0,30])
])
.range([0,w])
var yScale = d3.scale.linear()
.domain([
d3.min([0,30]),
d3.max([0,30])
])
.range([h,0])
// Change X axis label
d3.select("#xLabel").text("Programming Skill");
// Circles
svg.selectAll('circle').duration(1250)
.attr('cx',function (d) { return xScale(d.programmingSkills) })
.attr('cy',function (d) { return yScale(d.teamWork) })
.attr('r','10')
.attr('stroke','black')
.attr('stroke-width',1)
.attr('fill',function (d,i) { return colorScale(i) })
});
}
//Update Data Programming Skill
function updateDataDrawingSkill() {
d3.csv('data.csv', function (data) {
var svg = d3.select("body").transition();
// Scales
var colorScale = d3.scale.category20()
var xScale = d3.scale.linear()
.domain([
d3.min([0,30]),
d3.max([0,30])
])
.range([0,w])
var yScale = d3.scale.linear()
.domain([
d3.min([0,30]),
d3.max([0,30])
])
.range([h,0])
// Change X axis label
d3.select("#xLabel").text("Drawing Skill");
// Circles
svg.selectAll('circle').duration(1250)
.attr('cx',function (d) { return xScale(d.drawingSkill) })
.attr('cy',function (d) { return yScale(d.teamWork) })
.attr('r','10')
.attr('stroke','black')
.attr('stroke-width',1)
.attr('fill',function (d,i) { return colorScale(i) })
});
}
//Update Data Programming Skill
function updateDataUXSkill() {
d3.csv('data.csv', function (data) {
var svg = d3.select("body").transition();
// Scales
var colorScale = d3.scale.category20()
var xScale = d3.scale.linear()
.domain([
d3.min([0,30]),
d3.max([0,30])
])
.range([0,w])
var yScale = d3.scale.linear()
.domain([
d3.min([0,30]),
d3.max([0,30])
])
.range([h,0])
// Change X axis label
d3.select("#xLabel").text("User Evaluation Skill");
// Circles
svg.selectAll('circle').duration(1250)
.attr('cx',function (d) { return xScale(d.userEvaluation) })
.attr('cy',function (d) { return yScale(d.teamWork) })
.attr('r','10')
.attr('stroke','black')
.attr('stroke-width',1)
.attr('fill',function (d,i) { return colorScale(i) })
});
}
//Update Data Programming Skill
function updateDataDataAnalysisSkill() {
d3.csv('data.csv', function (data) {
var svg = d3.select("body").transition();
// Scales
var colorScale = d3.scale.category20()
var xScale = d3.scale.linear()
.domain([
d3.min([0,30]),
d3.max([0,30])
])
.range([0,w])
var yScale = d3.scale.linear()
.domain([
d3.min([0,30]),
d3.max([0,30])
])
.range([h,0])
// Change X axis label
d3.select("#xLabel").text("Data Analysis");
// Circles
svg.selectAll('circle').duration(1250)
.attr('cx',function (d) { return xScale(d.dataAnalysis) })
.attr('cy',function (d) { return yScale(d.teamWork) })
.attr('r','10')
.attr('stroke','black')
.attr('stroke-width',1)
.attr('fill',function (d,i) { return colorScale(i) })
});
}
var btn= document.getElementById("programmingSkill");
var listener= function(evt){
updateDataProgrammingSkill();
}
btn.addEventListener("click", listener , false);
var btn1= document.getElementById("drawingSkill");
var listener1= function(evt){
updateDataDrawingSkill();
}
btn1.addEventListener("click", listener1 , false);
var btn2= document.getElementById("userEvaluationSkill");
var listener2= function(evt){
updateDataUXSkill();
}
btn2.addEventListener("click", listener2 , false);
var btn3= document.getElementById("statisticalSkill");
var listener3= function(evt){
updateDataDataAnalysisSkill();
}
btn3.addEventListener("click", listener3 , false);
}