Skip to content

Commit 517f6ad

Browse files
committed
feat: update date range to display at least 7 days of data in Dashboard
1 parent 10aba11 commit 517f6ad

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

web/default/src/pages/Dashboard/index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { useEffect, useState } from 'react';
2-
import { useTranslation } from 'react-i18next';
3-
import { Card, Grid } from 'semantic-ui-react';
1+
import React, {useEffect, useState} from 'react';
2+
import {useTranslation} from 'react-i18next';
3+
import {Card, Grid} from 'semantic-ui-react';
44
import {
55
Bar,
66
BarChart,
@@ -122,11 +122,11 @@ const Dashboard = () => {
122122
? new Date(Math.min(...dates.map((d) => new Date(d))))
123123
: new Date();
124124

125-
// 确保至少显示5天的数据
126-
const fiveDaysAgo = new Date();
127-
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 4); // -4是因为包含今天
128-
if (minDate > fiveDaysAgo) {
129-
minDate = fiveDaysAgo;
125+
// 确保至少显示7天的数据
126+
const sevenDaysAgo = new Date();
127+
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6); // -6是因为包含今天
128+
if (minDate > sevenDaysAgo) {
129+
minDate = sevenDaysAgo;
130130
}
131131

132132
// 生成所有日期
@@ -164,11 +164,11 @@ const Dashboard = () => {
164164
? new Date(Math.min(...dates.map((d) => new Date(d))))
165165
: new Date();
166166

167-
// 确保至少显示5天的数据
168-
const fiveDaysAgo = new Date();
169-
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 4); // -4是因为包含今天
170-
if (minDate > fiveDaysAgo) {
171-
minDate = fiveDaysAgo;
167+
// 确保至少显示7天的数据
168+
const sevenDaysAgo = new Date();
169+
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6); // -6是因为包含今天
170+
if (minDate > sevenDaysAgo) {
171+
minDate = sevenDaysAgo;
172172
}
173173

174174
// 生成所有日期

0 commit comments

Comments
 (0)