Commit 321d3d6beec4f08e77f9908469c1debf555a578b
Committed by
xp.Huang
1 parent
3050a412
fix: 统一统计时间间隔计算
Showing
1 changed file
with
4 additions
and
1 deletions
| ... | ... | @@ -55,7 +55,7 @@ export const formSchema: DescItem[] = [ |
| 55 | 55 | function generateFullXAxis(type: DateInterval) { |
| 56 | 56 | if (type === 'hour') { |
| 57 | 57 | let minute = dateUtil().minute(); |
| 58 | - minute = minute - (minute % 10); | |
| 58 | + minute = Math.floor(minute / 5) * 5; | |
| 59 | 59 | |
| 60 | 60 | return Array.from({ length: 60 / 5 }, (_, index) => |
| 61 | 61 | dateUtil() |
| ... | ... | @@ -65,8 +65,11 @@ function generateFullXAxis(type: DateInterval) { |
| 65 | 65 | .valueOf() |
| 66 | 66 | ); |
| 67 | 67 | } else if (type === 'day') { |
| 68 | + let hour = dateUtil().hour(); | |
| 69 | + hour = Math.floor(hour / 2) * 2; | |
| 68 | 70 | return Array.from({ length: 24 / 2 }, (_, index) => |
| 69 | 71 | dateUtil() |
| 72 | + .hour(hour) | |
| 70 | 73 | .subtract(index * 2, 'hour') |
| 71 | 74 | .startOf('hour') |
| 72 | 75 | .valueOf() | ... | ... |