From 68f7d20592039ad6d2396adcf382deb8f6d0d704 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Thu, 18 Feb 2021 22:21:26 +0800 Subject: [PATCH] feat(calendar): add default colors --- web/public/js/graph/git/team-commit-calendar.js | 7 ++++++- web/public/js/support/commit-convert.js | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/web/public/js/graph/git/team-commit-calendar.js b/web/public/js/graph/git/team-commit-calendar.js index d97bb90c..0cd1193e 100644 --- a/web/public/js/graph/git/team-commit-calendar.js +++ b/web/public/js/graph/git/team-commit-calendar.js @@ -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} diff --git a/web/public/js/support/commit-convert.js b/web/public/js/support/commit-convert.js index ded1b18b..9ee67907 100644 --- a/web/public/js/support/commit-convert.js +++ b/web/public/js/support/commit-convert.js @@ -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++;