|
|
@@ -4,156 +4,161 @@ $("#leftside-navigation .sub-menu > a").click(function(e) {
|
|
4
|
4
|
e.stopPropagation()
|
|
5
|
5
|
});
|
|
6
|
6
|
|
|
7
|
|
-
|
|
8
|
|
-// heatmap SVG
|
|
9
|
|
-const margin = { top: 50, right: 0, bottom: 100, left: 30 },
|
|
10
|
|
- width =520 - margin.left - margin.right,
|
|
11
|
|
- height = 320 - margin.top - margin.bottom,
|
|
12
|
|
- gridSize = Math.floor(width / 24),
|
|
13
|
|
- legendElementWidth = gridSize*2,
|
|
14
|
|
- buckets = 9,
|
|
15
|
|
-
|
|
16
|
|
- // blue colors
|
|
17
|
|
- // colors = ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"], // alternatively colorbrewer.YlGnBu[9]
|
|
18
|
|
-
|
|
19
|
|
- // orange colors
|
|
20
|
|
- // colors = ['#fff5eb','#fee6ce','#fdd0a2','#fdae6b','#fd8d3c','#f16913','#d94801','#a63603','#7f2704'],
|
|
21
|
|
-
|
|
22
|
|
- // yellow colors
|
|
23
|
|
- colors =["#ECE622","#D5CF22","#BEB922","#A7A222","#908C22","#797522","#625F22","#625F22","#4B4822","#343222"],
|
|
24
|
|
-
|
|
25
|
|
- days = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
|
26
|
|
- times = ["1a", "2a", "3a", "4a", "5a", "6a", "7a", "8a", "9a", "10a", "11a", "12a", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p", "10p", "11p", "12p"];
|
|
27
|
|
- datasets = ["../static/data/data_dummy.tsv", "../static/data/data2_dummy.tsv"];
|
|
28
|
|
-
|
|
29
|
|
-const svg = d3.select("#chart").append("svg")
|
|
30
|
|
- .attr("width", width + margin.left + margin.right)
|
|
31
|
|
- .attr("height", height + margin.top + margin.bottom)
|
|
32
|
|
- .append("g")
|
|
33
|
|
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
|
34
|
|
-
|
|
35
|
|
-
|
|
36
|
|
-const dayLabels = svg.selectAll(".dayLabel")
|
|
37
|
|
- .data(days)
|
|
38
|
|
- .enter().append("text")
|
|
39
|
|
- .text(function (d) { return d; })
|
|
40
|
|
- .attr("x", 0)
|
|
41
|
|
- .attr("y", (d, i) => i * gridSize)
|
|
42
|
|
- .style("text-anchor", "end")
|
|
43
|
|
- .attr("transform", "translate(-6," + gridSize / 1.5 + ")")
|
|
44
|
|
- .attr("class", (d, i) => ((i >= 0 && i <= 4) ? "dayLabel mono axis axis-workweek" : "dayLabel mono axis"));
|
|
45
|
|
-
|
|
46
|
|
-const timeLabels = svg.selectAll(".timeLabel")
|
|
47
|
|
- .data(times)
|
|
48
|
|
- .enter().append("text")
|
|
49
|
|
- .text((d) => d)
|
|
50
|
|
- .attr("x", (d, i) => i * gridSize)
|
|
51
|
|
- .attr("y", 0)
|
|
52
|
|
- .style("text-anchor", "middle")
|
|
53
|
|
- .attr("transform", "translate(" + gridSize / 2 + ", -6)")
|
|
54
|
|
- .attr("class", (d, i) => ((i >= 7 && i <= 16) ? "timeLabel mono axis axis-worktime" : "timeLabel mono axis"));
|
|
55
|
|
-
|
|
56
|
|
-const type = (d) => {
|
|
57
|
|
- return {
|
|
58
|
|
- day: +d.day,
|
|
59
|
|
- hour: +d.hour,
|
|
60
|
|
- value: +d.value
|
|
|
7
|
+// generateHeatMap(["../static/data/data_dummy.tsv", "../static/data/data2_dummy.tsv"], "#chart");
|
|
|
8
|
+
|
|
|
9
|
+function generateHeatMap(datasets, divID){
|
|
|
10
|
+ // heatmap SVG
|
|
|
11
|
+ const margin = { top: 50, right: 0, bottom: 100, left: 30 },
|
|
|
12
|
+ width =520 - margin.left - margin.right,
|
|
|
13
|
+ height = 320 - margin.top - margin.bottom,
|
|
|
14
|
+ gridSize = Math.floor(width / 24),
|
|
|
15
|
+ legendElementWidth = gridSize*2,
|
|
|
16
|
+ buckets = 9,
|
|
|
17
|
+
|
|
|
18
|
+ // blue colors
|
|
|
19
|
+ // colors = ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"], // alternatively colorbrewer.YlGnBu[9]
|
|
|
20
|
+
|
|
|
21
|
+ // orange colors
|
|
|
22
|
+ // colors = ['#fff5eb','#fee6ce','#fdd0a2','#fdae6b','#fd8d3c','#f16913','#d94801','#a63603','#7f2704'],
|
|
|
23
|
+
|
|
|
24
|
+ // yellow colors
|
|
|
25
|
+ colors =["#ECE622","#D5CF22","#BEB922","#A7A222","#908C22","#797522","#625F22","#625F22","#4B4822","#343222"],
|
|
|
26
|
+
|
|
|
27
|
+ days = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
|
|
28
|
+ times = ["1a", "2a", "3a", "4a", "5a", "6a", "7a", "8a", "9a", "10a", "11a", "12a", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p", "10p", "11p", "12p"];
|
|
|
29
|
+
|
|
|
30
|
+ // datasets = ["../static/data/data_dummy.tsv", "../static/data/data2_dummy.tsv"];
|
|
|
31
|
+
|
|
|
32
|
+ const svg = d3.select(divID).append("svg")
|
|
|
33
|
+ .attr("width", width + margin.left + margin.right)
|
|
|
34
|
+ .attr("height", height + margin.top + margin.bottom)
|
|
|
35
|
+ .append("g")
|
|
|
36
|
+ .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
|
|
37
|
+
|
|
|
38
|
+
|
|
|
39
|
+ const dayLabels = svg.selectAll(".dayLabel")
|
|
|
40
|
+ .data(days)
|
|
|
41
|
+ .enter().append("text")
|
|
|
42
|
+ .text(function (d) { return d; })
|
|
|
43
|
+ .attr("x", 0)
|
|
|
44
|
+ .attr("y", (d, i) => i * gridSize)
|
|
|
45
|
+ .style("text-anchor", "end")
|
|
|
46
|
+ .attr("transform", "translate(-6," + gridSize / 1.5 + ")")
|
|
|
47
|
+ .attr("class", (d, i) => ((i >= 0 && i <= 4) ? "dayLabel mono axis axis-workweek" : "dayLabel mono axis"));
|
|
|
48
|
+
|
|
|
49
|
+ const timeLabels = svg.selectAll(".timeLabel")
|
|
|
50
|
+ .data(times)
|
|
|
51
|
+ .enter().append("text")
|
|
|
52
|
+ .text((d) => d)
|
|
|
53
|
+ .attr("x", (d, i) => i * gridSize)
|
|
|
54
|
+ .attr("y", 0)
|
|
|
55
|
+ .style("text-anchor", "middle")
|
|
|
56
|
+ .attr("transform", "translate(" + gridSize / 2 + ", -6)")
|
|
|
57
|
+ .attr("class", (d, i) => ((i >= 7 && i <= 16) ? "timeLabel mono axis axis-worktime" : "timeLabel mono axis"));
|
|
|
58
|
+
|
|
|
59
|
+ const type = (d) => {
|
|
|
60
|
+ return {
|
|
|
61
|
+ day: +d.day,
|
|
|
62
|
+ hour: +d.hour,
|
|
|
63
|
+ value: +d.value
|
|
|
64
|
+ };
|
|
61
|
65
|
};
|
|
62
|
|
-};
|
|
63
|
|
-
|
|
64
|
|
-const heatmapChart = function(tsvFile) {
|
|
65
|
|
-d3.tsv(tsvFile, type, (error, data) => {
|
|
66
|
|
-
|
|
67
|
|
- var div = d3.select("body").append("div")
|
|
68
|
|
- .attr("class", "tooltip")
|
|
69
|
|
- .style("opacity", 0);
|
|
70
|
|
-
|
|
71
|
|
- const colorScale = d3.scaleQuantile()
|
|
72
|
|
- .domain([0, buckets - 1, d3.max(data, (d) => d.value)])
|
|
73
|
|
- .range(colors);
|
|
74
|
|
-
|
|
75
|
|
- const cards = svg.selectAll(".hour")
|
|
76
|
|
- .data(data, (d) => d.day+':'+d.hour);
|
|
77
|
|
-
|
|
78
|
|
- cards.append("title");
|
|
79
|
|
-
|
|
80
|
|
- cards.enter().append("rect")
|
|
81
|
|
- .attr("x", (d) => (d.hour - 1) * gridSize)
|
|
82
|
|
- .attr("y", (d) => (d.day - 1) * gridSize)
|
|
83
|
|
- .attr("rx", 4)
|
|
84
|
|
- .attr("ry", 4)
|
|
85
|
|
- .attr("class", "hour bordered")
|
|
86
|
|
- .attr("width", gridSize)
|
|
87
|
|
- .attr("height", gridSize)
|
|
88
|
|
- .style("fill", colors[0])
|
|
89
|
|
- .on("mouseover", function(d) {
|
|
90
|
|
- div.transition()
|
|
91
|
|
- .duration(200)
|
|
92
|
|
- .style("opacity", .9);
|
|
93
|
|
- div.html("Day: " +days[d.day-1]+ "<br>Hour: " +times[d.hour-1]+ "<br>Commits: " +d.value+ "")
|
|
94
|
|
- .style("left", (d3.event.pageX + 20) + "px")
|
|
95
|
|
- .style("top", (d3.event.pageY - 20) + "px");
|
|
96
|
|
- })
|
|
97
|
|
- .on("mouseout", function(d) {
|
|
98
|
|
- div.transition()
|
|
99
|
|
- .duration(500)
|
|
100
|
|
- .style("opacity", 0);
|
|
101
|
|
- })
|
|
102
|
|
- .merge(cards)
|
|
103
|
|
- .transition()
|
|
104
|
|
- .duration(1000)
|
|
105
|
|
- .style("fill", (d) => colorScale(d.value));
|
|
106
|
|
-
|
|
107
|
|
- // cards.select("title").text((d) => d.value);
|
|
108
|
66
|
|
|
109
|
|
- cards.exit().remove();
|
|
|
67
|
+ const heatmapChart = function(tsvFile) {
|
|
|
68
|
+ d3.tsv(tsvFile, type, (error, data) => {
|
|
110
|
69
|
|
|
111
|
|
- const legend = svg.selectAll(".legend")
|
|
112
|
|
- .data([0].concat(colorScale.quantiles()), (d) => d);
|
|
113
|
|
-
|
|
114
|
|
- const legend_g = legend.enter().append("g")
|
|
115
|
|
- .attr("class", "legend");
|
|
116
|
|
-
|
|
117
|
|
- legend_g.append("rect")
|
|
118
|
|
- .attr("x", (d, i) => legendElementWidth * i)
|
|
119
|
|
- .attr("y", height)
|
|
120
|
|
- .attr("width", legendElementWidth)
|
|
121
|
|
- .attr("height", gridSize / 2)
|
|
122
|
|
- .style("fill", (d, i) => colors[i]);
|
|
|
70
|
+ var div = d3.select("body").append("div")
|
|
|
71
|
+ .attr("class", "tooltip")
|
|
|
72
|
+ .style("opacity", 0);
|
|
123
|
73
|
|
|
124
|
|
- legend_g.append("text")
|
|
125
|
|
- .attr("class", "mono")
|
|
126
|
|
- .text((d) => "≥ " + Math.round(d))
|
|
127
|
|
- .attr("x", (d, i) => legendElementWidth * i)
|
|
128
|
|
- .attr("y", height + gridSize);
|
|
|
74
|
+ const colorScale = d3.scaleQuantile()
|
|
|
75
|
+ .domain([0, buckets - 1, d3.max(data, (d) => d.value)])
|
|
|
76
|
+ .range(colors);
|
|
|
77
|
+
|
|
|
78
|
+ const cards = svg.selectAll(".hour")
|
|
|
79
|
+ .data(data, (d) => d.day+':'+d.hour);
|
|
|
80
|
+
|
|
|
81
|
+ cards.append("title");
|
|
|
82
|
+
|
|
|
83
|
+ cards.enter().append("rect")
|
|
|
84
|
+ .attr("x", (d) => (d.hour - 1) * gridSize)
|
|
|
85
|
+ .attr("y", (d) => (d.day - 1) * gridSize)
|
|
|
86
|
+ .attr("rx", 4)
|
|
|
87
|
+ .attr("ry", 4)
|
|
|
88
|
+ .attr("class", "hour bordered")
|
|
|
89
|
+ .attr("width", gridSize)
|
|
|
90
|
+ .attr("height", gridSize)
|
|
|
91
|
+ .style("fill", colors[0])
|
|
|
92
|
+ .on("mouseover", function(d) {
|
|
|
93
|
+ div.transition()
|
|
|
94
|
+ .duration(200)
|
|
|
95
|
+ .style("opacity", .9);
|
|
|
96
|
+ div.html("Day: " +days[d.day-1]+ "<br>Hour: " +times[d.hour-1]+ "<br>Commits: " +d.value+ "")
|
|
|
97
|
+ .style("left", (d3.event.pageX + 20) + "px")
|
|
|
98
|
+ .style("top", (d3.event.pageY - 20) + "px");
|
|
|
99
|
+ })
|
|
|
100
|
+ .on("mouseout", function(d) {
|
|
|
101
|
+ div.transition()
|
|
|
102
|
+ .duration(500)
|
|
|
103
|
+ .style("opacity", 0);
|
|
|
104
|
+ })
|
|
|
105
|
+ .merge(cards)
|
|
|
106
|
+ .transition()
|
|
|
107
|
+ .duration(1000)
|
|
|
108
|
+ .style("fill", (d) => colorScale(d.value));
|
|
|
109
|
+
|
|
|
110
|
+ // cards.select("title").text((d) => d.value);
|
|
|
111
|
+
|
|
|
112
|
+ cards.exit().remove();
|
|
|
113
|
+
|
|
|
114
|
+ const legend = svg.selectAll(".legend")
|
|
|
115
|
+ .data([0].concat(colorScale.quantiles()), (d) => d);
|
|
|
116
|
+
|
|
|
117
|
+ const legend_g = legend.enter().append("g")
|
|
|
118
|
+ .attr("class", "legend");
|
|
|
119
|
+
|
|
|
120
|
+ legend_g.append("rect")
|
|
|
121
|
+ .attr("x", (d, i) => legendElementWidth * i)
|
|
|
122
|
+ .attr("y", height)
|
|
|
123
|
+ .attr("width", legendElementWidth)
|
|
|
124
|
+ .attr("height", gridSize / 2)
|
|
|
125
|
+ .style("fill", (d, i) => colors[i]);
|
|
|
126
|
+
|
|
|
127
|
+ legend_g.append("text")
|
|
|
128
|
+ .attr("class", "mono")
|
|
|
129
|
+ .text((d) => "≥ " + Math.round(d))
|
|
|
130
|
+ .attr("x", (d, i) => legendElementWidth * i)
|
|
|
131
|
+ .attr("y", height + gridSize);
|
|
|
132
|
+
|
|
|
133
|
+ legend.exit().remove();
|
|
|
134
|
+ });
|
|
|
135
|
+ };
|
|
129
|
136
|
|
|
130
|
|
- legend.exit().remove();
|
|
131
|
|
-});
|
|
132
|
|
-};
|
|
|
137
|
+ // use first dataset by default
|
|
|
138
|
+ heatmapChart(datasets[0]);
|
|
133
|
139
|
|
|
134
|
|
-// use first dataset by default
|
|
135
|
|
-heatmapChart(datasets[0]);
|
|
|
140
|
+ // dataset buttons
|
|
|
141
|
+ const datasetpicker = d3.select("#dataset-picker")
|
|
|
142
|
+ .selectAll(".btn btn-primary")
|
|
|
143
|
+ .data(datasets);
|
|
136
|
144
|
|
|
137
|
|
-// dataset buttons
|
|
138
|
|
-const datasetpicker = d3.select("#dataset-picker")
|
|
139
|
|
- .selectAll(".btn btn-primary")
|
|
140
|
|
- .data(datasets);
|
|
|
145
|
+ // dataset picking button
|
|
|
146
|
+ datasetpicker.enter()
|
|
|
147
|
+ .append("input")
|
|
|
148
|
+ .attr("value", (d) => "Dataset " + d)
|
|
|
149
|
+ .attr("type", "button")
|
|
|
150
|
+ .attr("class", "btn-sm btn-primary")
|
|
|
151
|
+ .on("click", (d) => heatmapChart(d));
|
|
141
|
152
|
|
|
142
|
|
-// dataset picking button
|
|
143
|
|
-datasetpicker.enter()
|
|
144
|
|
- .append("input")
|
|
145
|
|
- .attr("value", (d) => "Dataset " + d)
|
|
146
|
|
- .attr("type", "button")
|
|
147
|
|
- .attr("class", "btn-sm btn-primary")
|
|
148
|
|
- .on("click", (d) => heatmapChart(d));
|
|
149
|
153
|
|
|
|
154
|
+}
|
|
150
|
155
|
|
|
151
|
156
|
|
|
152
|
157
|
|
|
153
|
158
|
|
|
154
|
159
|
|
|
155
|
160
|
|
|
156
|
|
-generateBarChart("../static/data/day_of_week_copy.tsv", "#day_of_week");
|
|
|
161
|
+// generateBarChart("../static/data/day_of_week_copy.tsv", "#day_of_week");
|
|
157
|
162
|
|
|
158
|
163
|
function generateBarChart (pathToTSV,divID){
|
|
159
|
164
|
// Bar chart, see function 'main' for main execution wheel
|
|
|
@@ -173,6 +178,7 @@ function generateBarChart (pathToTSV,divID){
|
|
173
|
178
|
var svg = d3.select(divID).append("svg")
|
|
174
|
179
|
var axisLayer = svg.append("g").classed("axisLayer", true)
|
|
175
|
180
|
var chartLayer = svg.append("g").classed("chartLayer", true)
|
|
|
181
|
+ var margin = {top:50, right:0, bottom:100, left:30}
|
|
176
|
182
|
|
|
177
|
183
|
var xScale = d3.scaleBand()
|
|
178
|
184
|
var yScale = d3.scaleLinear()
|
|
|
@@ -189,7 +195,6 @@ function generateBarChart (pathToTSV,divID){
|
|
189
|
195
|
|
|
190
|
196
|
function setSize() {
|
|
191
|
197
|
|
|
192
|
|
- var margin = {top:50, right:0, bottom:100, left:30}
|
|
193
|
198
|
chartWidth = width - margin.left - margin.right,
|
|
194
|
199
|
chartHeight = height - margin.top - margin.bottom,
|
|
195
|
200
|
|
|
|
@@ -291,8 +296,12 @@ function generateBarChart (pathToTSV,divID){
|
|
291
|
296
|
|
|
292
|
297
|
} //end of generateBarChart
|
|
293
|
298
|
|
|
294
|
|
-generateLineChart("../static/data/commits_by_author_copy.tsv", "#lineChart");
|
|
295
|
|
-generateLineChart("../static/data/lines_of_code_by_author_copy.tsv", "#lineChart2");
|
|
|
299
|
+// generateLineChart("../static/data/commits_by_author_copy.tsv", "#lineChart");
|
|
|
300
|
+// generateLineChart("../static/data/lines_of_code_by_author_copy.tsv", "#lineChart2");
|
|
|
301
|
+
|
|
|
302
|
+
|
|
|
303
|
+
|
|
|
304
|
+
|
|
296
|
305
|
|
|
297
|
306
|
function generateLineChart(pathToTSV, divID){
|
|
298
|
307
|
|