|
|
@@ -5,7 +5,7 @@ $("#leftside-navigation .sub-menu > a").click(function(e) {
|
|
5
|
5
|
});
|
|
6
|
6
|
|
|
7
|
7
|
|
|
8
|
|
-// Commits SVG
|
|
|
8
|
+// heatmap SVG
|
|
9
|
9
|
const margin = { top: 50, right: 0, bottom: 100, left: 30 },
|
|
10
|
10
|
width =520 - margin.left - margin.right,
|
|
11
|
11
|
height = 320 - margin.top - margin.bottom,
|
|
|
@@ -153,145 +153,145 @@ datasetpicker.enter()
|
|
153
|
153
|
|
|
154
|
154
|
|
|
155
|
155
|
|
|
|
156
|
+generateBarChart("../static/data/day_of_week_copy.tsv", "#day_of_week");
|
|
156
|
157
|
|
|
|
158
|
+function generateBarChart (pathToTSV,divID){
|
|
|
159
|
+ // Bar chart, see function 'main' for main execution wheel
|
|
157
|
160
|
|
|
158
|
|
-// day_of_week_copy.tsv graph
|
|
159
|
|
-
|
|
160
|
|
- function toNum(d){
|
|
161
|
|
- //cleaner function
|
|
162
|
|
- d.commits= +d.commits
|
|
163
|
|
- return d
|
|
164
|
|
-};
|
|
|
161
|
+ function toNum(d){
|
|
|
162
|
+ //cleaner function
|
|
|
163
|
+ d.commits= +d.commits
|
|
|
164
|
+ return d
|
|
|
165
|
+ };
|
|
165
|
166
|
|
|
166
|
|
-d3.tsv("../static/data/day_of_week_copy.tsv", toNum, function (error,data){
|
|
167
|
|
- "use strict"
|
|
168
|
|
- // declare outside for reference later
|
|
169
|
|
- var width=520
|
|
170
|
|
- var height=380
|
|
171
|
|
- var chartWidth, chartHeight
|
|
172
|
|
- var margin
|
|
173
|
|
- var svg = d3.select("#day_of_week").append("svg")
|
|
174
|
|
- var axisLayer = svg.append("g").classed("axisLayer", true)
|
|
175
|
|
- var chartLayer = svg.append("g").classed("chartLayer", true)
|
|
176
|
|
-
|
|
177
|
|
- var xScale = d3.scaleBand()
|
|
178
|
|
- var yScale = d3.scaleLinear()
|
|
179
|
|
-
|
|
180
|
|
- var div = d3.select("body").append("div")
|
|
181
|
|
- .attr("class", "rect_tooltip")
|
|
182
|
|
- .style("opacity", 0);
|
|
183
|
|
-
|
|
184
|
|
- function main(data) {
|
|
185
|
|
- setSize(data)
|
|
186
|
|
- drawAxis()
|
|
187
|
|
- drawChart(data)
|
|
188
|
|
- }
|
|
189
|
|
-
|
|
190
|
|
- function setSize(data) {
|
|
191
|
|
-
|
|
192
|
|
- margin = {top:50, right:0, bottom:100, left:30}
|
|
193
|
|
- chartWidth = width - margin.left - margin.right,
|
|
194
|
|
- chartHeight = height - margin.top - margin.bottom,
|
|
195
|
|
-
|
|
196
|
|
- svg
|
|
197
|
|
- .attr("width", 520)
|
|
198
|
|
- .attr("height", 320)
|
|
199
|
|
-
|
|
200
|
|
- axisLayer
|
|
201
|
|
- .attr("width", chartWidth)
|
|
202
|
|
- .attr("height", chartHeight)
|
|
203
|
|
-
|
|
204
|
|
- chartLayer
|
|
|
167
|
+ d3.tsv(pathToTSV, toNum, function (error,data){
|
|
|
168
|
+ "use strict"
|
|
|
169
|
+ // declare outside for reference later
|
|
|
170
|
+ var width=520
|
|
|
171
|
+ var height=380
|
|
|
172
|
+ var chartWidth, chartHeight
|
|
|
173
|
+ var margin
|
|
|
174
|
+ var svg = d3.select(divID).append("svg")
|
|
|
175
|
+ var axisLayer = svg.append("g").classed("axisLayer", true)
|
|
|
176
|
+ var chartLayer = svg.append("g").classed("chartLayer", true)
|
|
|
177
|
+
|
|
|
178
|
+ var xScale = d3.scaleBand()
|
|
|
179
|
+ var yScale = d3.scaleLinear()
|
|
|
180
|
+
|
|
|
181
|
+ var div = d3.select("body").append("div")
|
|
|
182
|
+ .attr("class", "rect_tooltip")
|
|
|
183
|
+ .style("opacity", 0);
|
|
|
184
|
+
|
|
|
185
|
+ function main(data) {
|
|
|
186
|
+ setSize(data)
|
|
|
187
|
+ drawAxis()
|
|
|
188
|
+ drawChart(data)
|
|
|
189
|
+ }
|
|
|
190
|
+
|
|
|
191
|
+ function setSize(data) {
|
|
|
192
|
+
|
|
|
193
|
+ margin = {top:50, right:0, bottom:100, left:30}
|
|
|
194
|
+ chartWidth = width - margin.left - margin.right,
|
|
|
195
|
+ chartHeight = height - margin.top - margin.bottom,
|
|
|
196
|
+
|
|
|
197
|
+ svg
|
|
|
198
|
+ .attr("width", 520)
|
|
|
199
|
+ .attr("height", 320)
|
|
|
200
|
+
|
|
|
201
|
+ axisLayer
|
|
205
|
202
|
.attr("width", chartWidth)
|
|
206
|
203
|
.attr("height", chartHeight)
|
|
207
|
|
- .attr("transform", "translate("+[margin.left, margin.top]+")")
|
|
208
|
|
-
|
|
209
|
|
-
|
|
210
|
|
-
|
|
211
|
|
- xScale.domain(data.map(function(d){ return d.day_name })).range([0, chartWidth])
|
|
212
|
|
- .paddingInner(0.1)
|
|
213
|
|
- .paddingOuter(0.5)
|
|
|
204
|
+
|
|
|
205
|
+ chartLayer
|
|
|
206
|
+ .attr("width", chartWidth)
|
|
|
207
|
+ .attr("height", chartHeight)
|
|
|
208
|
+ .attr("transform", "translate("+[margin.left, margin.top]+")")
|
|
|
209
|
+
|
|
|
210
|
+ xScale.domain(data.map(function(d){ return d.day_name })).range([0, chartWidth])
|
|
|
211
|
+ .paddingInner(0.1)
|
|
|
212
|
+ .paddingOuter(0.5)
|
|
|
213
|
+
|
|
|
214
|
+ yScale.domain([0, d3.max(data, function(d){ return d.commits})]).range([chartHeight, 0])
|
|
|
215
|
+
|
|
|
216
|
+ }
|
|
|
217
|
+
|
|
|
218
|
+ function drawChart(data) {
|
|
|
219
|
+ // monitor the transition
|
|
|
220
|
+ var t = d3.transition()
|
|
|
221
|
+ .duration(1000)
|
|
|
222
|
+ .ease(d3.easeLinear)
|
|
|
223
|
+ .on("start", function(d){ console.log("Transiton start") })
|
|
|
224
|
+ .on("end", function(d){ console.log("Transiton end") })
|
|
|
225
|
+
|
|
|
226
|
+ var bar = chartLayer
|
|
|
227
|
+ .selectAll(".bar")
|
|
|
228
|
+ .data(data)
|
|
|
229
|
+
|
|
|
230
|
+ bar.exit().remove()
|
|
|
231
|
+
|
|
|
232
|
+
|
|
|
233
|
+ var labels = chartLayer
|
|
|
234
|
+ .selectAll("labels")
|
|
|
235
|
+ .data(data)
|
|
|
236
|
+
|
|
|
237
|
+ bar
|
|
|
238
|
+ .enter()
|
|
|
239
|
+ .append("rect")
|
|
|
240
|
+ .classed("bar", true)
|
|
|
241
|
+ .merge(bar)
|
|
|
242
|
+ .attr("fill", "rgb(236, 230, 34)")
|
|
|
243
|
+ .attr("width", xScale.bandwidth())
|
|
|
244
|
+ .attr("stroke", "#323232")
|
|
|
245
|
+ //setup for cool transition
|
|
|
246
|
+ .attr("height", 0)
|
|
|
247
|
+ .attr("transform", function(d){ return "translate("+[xScale(d.day_name), chartHeight]+")"})
|
|
|
248
|
+
|
|
|
249
|
+
|
|
|
250
|
+ var totalCommits=0
|
|
|
251
|
+ data.forEach(function(d){
|
|
|
252
|
+ totalCommits+=d.commits
|
|
|
253
|
+ })
|
|
|
254
|
+ labels
|
|
|
255
|
+ .enter()
|
|
|
256
|
+ .append("text")
|
|
|
257
|
+ .text(function(d){
|
|
|
258
|
+ var percentage= (d.commits/totalCommits *100).toFixed(2)
|
|
|
259
|
+
|
|
|
260
|
+ return ""+percentage+"%";
|
|
|
261
|
+ })
|
|
|
262
|
+ .attr("transform", function(d){
|
|
|
263
|
+ return "translate("+[xScale(d.day_name)+5, chartHeight-5]+")"
|
|
|
264
|
+ })
|
|
214
|
265
|
|
|
215
|
|
- yScale.domain([0, d3.max(data, function(d){ return d.commits})]).range([chartHeight, 0])
|
|
216
|
|
-
|
|
217
|
|
- }
|
|
218
|
|
-
|
|
219
|
|
- function drawChart(data) {
|
|
220
|
|
- // monitor the transition
|
|
221
|
|
- var t = d3.transition()
|
|
222
|
|
- .duration(1000)
|
|
223
|
|
- .ease(d3.easeLinear)
|
|
224
|
|
- .on("start", function(d){ console.log("Transiton start") })
|
|
225
|
|
- .on("end", function(d){ console.log("Transiton end") })
|
|
226
|
|
-
|
|
227
|
|
- var bar = chartLayer
|
|
228
|
|
- .selectAll(".bar")
|
|
229
|
|
- .data(data)
|
|
230
|
|
-
|
|
231
|
|
- bar.exit().remove()
|
|
232
|
|
-
|
|
233
|
|
-
|
|
234
|
|
- var labels = chartLayer
|
|
235
|
|
- .selectAll("labels")
|
|
236
|
|
- .data(data)
|
|
237
|
|
-
|
|
238
|
|
- bar
|
|
239
|
|
- .enter()
|
|
240
|
|
- .append("rect")
|
|
241
|
|
- .classed("bar", true)
|
|
242
|
|
- .merge(bar)
|
|
243
|
|
- .attr("fill", "rgb(236, 230, 34)")
|
|
244
|
|
- .attr("width", xScale.bandwidth())
|
|
245
|
|
- .attr("stroke", "#323232")
|
|
246
|
|
- //setup for cool transition
|
|
247
|
|
- .attr("height", 0)
|
|
248
|
|
- .attr("transform", function(d){ return "translate("+[xScale(d.day_name), chartHeight]+")"})
|
|
249
|
|
-
|
|
250
|
|
-
|
|
251
|
|
-
|
|
252
|
|
- var totalCommits=0
|
|
253
|
|
- data.forEach(function(d){
|
|
254
|
|
- totalCommits+=d.commits
|
|
255
|
|
- })
|
|
256
|
|
- labels
|
|
257
|
|
- .enter()
|
|
258
|
|
- .append("text")
|
|
259
|
|
- .text(function(d){
|
|
260
|
|
- var percentage= (d.commits/totalCommits *100).toFixed(2)
|
|
261
|
|
-
|
|
262
|
|
- return ""+percentage+"%";
|
|
263
|
|
- })
|
|
264
|
|
- .attr("transform", function(d){
|
|
265
|
|
- return "translate("+[xScale(d.day_name)+5, chartHeight-5]+")"
|
|
266
|
|
- })
|
|
267
|
|
-
|
|
268
|
|
- chartLayer.selectAll(".bar").transition(t)
|
|
269
|
|
- // grows to appropriate amount
|
|
270
|
|
- .attr("height", function(d){ return chartHeight - yScale(d.commits) })
|
|
271
|
|
- .attr("transform", function(d){ return "translate("+[xScale(d.day_name), yScale(d.commits)]+")"})
|
|
272
|
|
- }
|
|
273
|
|
-
|
|
274
|
|
- function drawAxis(){
|
|
275
|
|
- var yAxis = d3.axisLeft(yScale)
|
|
276
|
|
- .tickSizeInner(-chartWidth)
|
|
277
|
|
-
|
|
278
|
|
- axisLayer.append("g")
|
|
279
|
|
- .attr("transform", "translate("+[margin.left, margin.top]+")")
|
|
280
|
|
- .attr("class", "axis y")
|
|
281
|
|
- .call(yAxis);
|
|
282
|
|
-
|
|
283
|
|
- var xAxis = d3.axisBottom(xScale)
|
|
284
|
|
-
|
|
285
|
|
- axisLayer.append("g")
|
|
286
|
|
- .attr("class", "axis x")
|
|
287
|
|
- .attr("transform", "translate("+[margin.left, (height-margin.bottom)]+")")
|
|
288
|
|
- .call(xAxis);
|
|
289
|
|
-
|
|
290
|
|
- }
|
|
291
|
|
-
|
|
292
|
|
- main(data)
|
|
293
|
|
-
|
|
294
|
|
-});
|
|
|
266
|
+ chartLayer.selectAll(".bar").transition(t)
|
|
|
267
|
+ // grows to appropriate amount
|
|
|
268
|
+ .attr("height", function(d){ return chartHeight - yScale(d.commits) })
|
|
|
269
|
+ .attr("transform", function(d){ return "translate("+[xScale(d.day_name), yScale(d.commits)]+")"})
|
|
|
270
|
+ }
|
|
|
271
|
+
|
|
|
272
|
+ function drawAxis(){
|
|
|
273
|
+ var yAxis = d3.axisLeft(yScale)
|
|
|
274
|
+ .tickSizeInner(-chartWidth)
|
|
|
275
|
+
|
|
|
276
|
+ axisLayer.append("g")
|
|
|
277
|
+ .attr("transform", "translate("+[margin.left, margin.top]+")")
|
|
|
278
|
+ .attr("class", "axis y")
|
|
|
279
|
+ .call(yAxis);
|
|
|
280
|
+
|
|
|
281
|
+ var xAxis = d3.axisBottom(xScale)
|
|
|
282
|
+
|
|
|
283
|
+ axisLayer.append("g")
|
|
|
284
|
+ .attr("class", "axis x")
|
|
|
285
|
+ .attr("transform", "translate("+[margin.left, (height-margin.bottom)]+")")
|
|
|
286
|
+ .call(xAxis);
|
|
|
287
|
+
|
|
|
288
|
+ }
|
|
|
289
|
+
|
|
|
290
|
+ //kicks of execution of the bar chart
|
|
|
291
|
+ main(data);
|
|
|
292
|
+ });
|
|
|
293
|
+
|
|
|
294
|
+} //end of generateBarChart
|
|
295
|
295
|
|
|
296
|
296
|
generateLineChart("../static/data/commits_by_author.tsv", "#lineChart");
|
|
297
|
297
|
generateLineChart("../static/data/lines_of_code_by_author.tsv", "#lineChart2");
|
|
|
@@ -353,9 +353,11 @@ function generateLineChart(pathToTSV, divID){
|
|
353
|
353
|
|
|
354
|
354
|
z.domain(authors.map(function(c) { return c.id; }));
|
|
355
|
355
|
|
|
356
|
|
- drawAxisLineChart();
|
|
357
|
|
- drawChartLineChart();
|
|
358
|
|
- drawLegend();
|
|
|
356
|
+ function main(){
|
|
|
357
|
+ drawAxisLineChart();
|
|
|
358
|
+ drawChartLineChart();
|
|
|
359
|
+ drawLegend();
|
|
|
360
|
+ }
|
|
359
|
361
|
|
|
360
|
362
|
// gridlines in x axis
|
|
361
|
363
|
function make_x_gridlines() {
|
|
|
@@ -451,6 +453,8 @@ function generateLineChart(pathToTSV, divID){
|
|
451
|
453
|
});
|
|
452
|
454
|
}
|
|
453
|
455
|
|
|
|
456
|
+ main(); //kicks off main execution wheel
|
|
|
457
|
+
|
|
454
|
458
|
}); //end tsv read in
|
|
455
|
459
|
|
|
456
|
460
|
}; //end generate line chart
|