Skip to content

Commit

Permalink
feat(calendar): add default colors
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 18, 2021
1 parent db174cd commit 68f7d20
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 6 additions & 1 deletion web/public/js/graph/git/team-commit-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ function renderTeamCommitCalendar(data) {
.attr("y", d => countDay(d.date.getUTCDay()) * cellSize + 0.5)
.attr("rx", 2)
.attr("ry", 2)
.attr("fill", d => color(d.value))
.attr("fill", (d) => {
if (d.value === 0) {
return '#EBEDF0'
}
return color(d.value)
})
.append("title")
.text(d => `date: ${standardFormatDate(d.date)}
commits: ${d.value}
Expand Down
16 changes: 15 additions & 1 deletion web/public/js/support/commit-convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,21 @@ function commit_to_author_map(data) {

function commit_by_days(data) {
let dayMap = {};
for (let datum of data.reverse()) {
let reverse = data.reverse();

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

for (let datum of reverse) {
let day = formatDate(datum.date);
if (dayMap[day]) {
dayMap[day].value++;
Expand Down

0 comments on commit 68f7d20

Please sign in to comment.