Skip to content

Commit 2799f0d

Browse files
committed
Visualization code for holiday annotations updated for clarity/concision.
Fixed some trailing whitespace.
1 parent b724fca commit 2799f0d

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

assets/js/visualize/line_repoActivity.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ function draw_line_repoActivity(areaID, repoNameWOwner) {
5757
.nice();
5858

5959
var dToday = x.domain()[1];
60-
// Supercomputing
61-
var dSupercomp = '11-18';
62-
// Thanksgiving
63-
var dThnxgiv = '11-25';
64-
// Christmas
65-
var dXmas = '12-25';
6660

6761
function addDateLine(dateString, label) {
6862
var dateObj = getYearDate(dateString, dToday);
@@ -160,9 +154,15 @@ function draw_line_repoActivity(areaID, repoNameWOwner) {
160154
.attr('d', valueline);
161155

162156
// Draw date-of-interest reference lines
163-
addDateLine(dSupercomp, 'Supercomputing');
164-
addDateLine(dThnxgiv, 'Thanksgiving');
165-
addDateLine(dXmas, 'Christmas');
157+
var annotationDates = {
158+
'Supercomputing': '11-18',
159+
'Thanksgiving': '11-25',
160+
'Christmas': '12-25'
161+
};
162+
for (var annotationName in annotationDates) {
163+
var annotationDate = annotationDates[annotationName];
164+
addDateLine(annotationDate, annotationName);
165+
}
166166

167167
// Draw dots
168168
chart

assets/js/visualize/line_repoActivityExplore.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function draw_line_repoActivity(areaID, repoNameWOwner) {
3434
element = document.querySelector('.' + areaID).parentNode,
3535
containerWidth = element.offsetWidth,
3636
width = containerWidth - margin.left - margin.right,
37-
height = Math.max(containerWidth / 3, 400) - margin.top - margin.bottom;
37+
height = Math.max(containerWidth / 3, 400) - margin.top - margin.bottom;
3838
var dotRadius = stdDotRadius;
3939

4040
var x = d3
@@ -86,7 +86,7 @@ function draw_line_repoActivity(areaID, repoNameWOwner) {
8686
}
8787
return '<sub>[Week of ' + formatTime(d.date) + ']</sub>' + '<br>' + d.value + repos;
8888
});
89-
89+
9090
var pieTip = d3
9191
.tip()
9292
.attr('class', 'd3-tip')
@@ -96,14 +96,8 @@ function draw_line_repoActivity(areaID, repoNameWOwner) {
9696
});
9797

9898
var dToday = x.domain()[1];
99-
// Supercomputing
100-
var dSupercomp = '11-18';
101-
// Thanksgiving
102-
var dThnxgiv = '11-25';
103-
// Christmas
104-
var dXmas = '12-25';
105-
106-
function update(x, y) {
99+
100+
function update(x, y) {
107101
chart.selectAll('g').remove();
108102

109103
var xAxis = d3.axisBottom().scale(x);
@@ -187,9 +181,15 @@ function draw_line_repoActivity(areaID, repoNameWOwner) {
187181
.attr('d', valueline);
188182

189183
// Draw date-of-interest reference lines
190-
addDateLine(dSupercomp, 'Supercomputing');
191-
addDateLine(dThnxgiv, 'Thanksgiving');
192-
addDateLine(dXmas, 'Christmas');
184+
var annotationDates = {
185+
'Supercomputing': '11-18',
186+
'Thanksgiving': '11-25',
187+
'Christmas': '12-25'
188+
};
189+
for (var annotationName in annotationDates) {
190+
var annotationDate = annotationDates[annotationName];
191+
addDateLine(annotationDate, annotationName);
192+
}
193193

194194
// Draw dots
195195
chart
@@ -269,7 +269,7 @@ function draw_line_repoActivity(areaID, repoNameWOwner) {
269269

270270
// Colors used for coloring the pie chart
271271
const colors = d3.scaleSequential(d3.interpolate('lightblue', 'white')).domain([0, root.descendants().length]);
272-
272+
273273
// Equivalent of chart but for the pie chart
274274
const pieGroup = chart
275275
.append('g')

0 commit comments

Comments
 (0)