From 3a79ff0855799820477803db6a51f628bcc53c60 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Fri, 12 Feb 2021 23:15:30 +0800 Subject: [PATCH] fix: fix data empty issue --- web/public/js/graph/git/tags-timeline.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/public/js/graph/git/tags-timeline.js b/web/public/js/graph/git/tags-timeline.js index c5215835..04c6f6cb 100644 --- a/web/public/js/graph/git/tags-timeline.js +++ b/web/public/js/graph/git/tags-timeline.js @@ -65,7 +65,13 @@ function renderTagsTimeline(data) { .attr("transform", "translate(0," + height + ")") .call(d3.axisBottom(x)); - let first_year = new Date(selectData[0].date).getFullYear(); + let first_year; + if (selectData.length > 0) { + first_year = new Date(selectData[0].date).getFullYear(); + } else { + first_year = new Date().getFullYear(); + } + let startDate = new Date(first_year, 0, 1); let y = d3.scaleTime() .domain([startDate, Date.now()])