Skip to content

Commit

Permalink
fix: fix format date issue & make contributions works
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 19, 2021
1 parent a60f923 commit 2d138f5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
24 changes: 6 additions & 18 deletions web/public/js/graph/git/commit-code-frequency.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ function renderCodeFrequency(data) {
.data(yearOptions)
.enter()
.append('option')
.text(function (d) {
return d;
})
.attr("value", function (d) {
return d;
})
.text(d => d)
.attr("value", d => d)

// When the button is changed, run the updateChart function
d3.select("#code-frequency-select").on("change", function (d) {
Expand Down Expand Up @@ -68,27 +64,19 @@ function renderCodeFrequency(data) {
.datum(data)
.attr("fill", "#2cbe4e")
.attr("d", d3.area()
.x(function (d) {
return x(d.date);
})
.y1(function (d) {
return y1(d.added);
})
.x(d => x(d.date))
.y0(height / 2)
.y1(d => y1(d.added))
);

svg.append("path")
.attr("class", "deletion")
.datum(data)
.attr("fill", "#cb2431")
.attr("d", d3.area()
.x(function (d) {
return x(d.date);
})
.x(d => x(d.date))
.y0(height / 2)
.y1(function (d) {
return y2(d.deleted);
})
.y1(d => y2(d.deleted))
);

svg.append("circle").attr("cx", 290).attr("cy", 30).attr("r", 6).style("fill", "#2cbe4e")
Expand Down
6 changes: 4 additions & 2 deletions web/public/js/graph/git/commit-contributions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function renderCommitContributions(data, elementId) {
.range([margin.left, width - margin.right])

let y = d3.scaleLinear()
.domain([0, d3.max(data, d => d.value)]).nice()
.domain([0, d3.max(data, d => d.value)])
.range([height - margin.bottom, margin.top])

let xAxis = g => g
Expand All @@ -34,7 +34,9 @@ function renderCommitContributions(data, elementId) {

svg.append("path")
.datum(data)
.attr("fill", "steelblue")
.attr("fill", "#cce5df")
.attr("stroke", "#69b3a2")
.attr("stroke-width", 1.5)
.attr("d", d3.area()
.curve(d3.curveLinear)
.x(d => x(d.date))
Expand Down
4 changes: 2 additions & 2 deletions web/public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ d3.json("data/git-commits.json").then(function (data) {
renderHeatmapChart(commits_by_hours(data, {before_month: 3}), "#hour-heatmap-three-month");

let commitByDays = commit_by_days(data);
console.log(commitByDays);
// renderCommitCalendar(commitByDays, "#commit-calendar");

renderCommitCalendar(commitByDays, "#commit-calendar");
renderCommitContributions(commitByDays, '#commit-contributions');

renderCodeFrequency(commit_by_weeks(data));
Expand Down
5 changes: 3 additions & 2 deletions web/public/js/support/commit-convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ function commit_by_days(data) {
let range = data[0].date * 1000;

while (range <= last_date) {
range = range + 24 * 60 * 60 * 1000;
let day = formatDate(range);
let day = standardFormatDate(range);
dayMap[day] = {
date: new Date(range),
value: 0,
commits: []
}

range = range + 24 * 60 * 60 * 1000;
}

for (let i = 0; i < data.length; i++) {
Expand Down

0 comments on commit 2d138f5

Please sign in to comment.