File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 1- // components/charts/echarts-trend-chart.tsx
21"use client" ;
32
43import ReactECharts from 'echarts-for-react' ;
@@ -15,15 +14,20 @@ interface EchartsTrendChartProps {
1514const EchartsTrendChart : React . FC < EchartsTrendChartProps > = ( { trendData } ) => {
1615 const { theme } = useTheme ( ) ;
1716
17+ const truncateToMinute = ( timestamp : number ) : number => {
18+ const date = new Date ( timestamp ) ;
19+ date . setSeconds ( 0 , 0 ) ;
20+ return date . getTime ( ) ;
21+ } ;
22+
1823 const allTimePoints = new Set < number > ( ) ;
1924 trendData . forEach ( user => {
2025 user . history . forEach ( point => {
21- allTimePoints . add ( new Date ( point . time ) . getTime ( ) ) ;
26+ allTimePoints . add ( truncateToMinute ( new Date ( point . time ) . getTime ( ) ) ) ;
2227 } ) ;
2328 } ) ;
2429
25- // Add the current time to the set to extend the axis to now
26- allTimePoints . add ( new Date ( ) . getTime ( ) ) ;
30+ allTimePoints . add ( truncateToMinute ( new Date ( ) . getTime ( ) ) ) ;
2731
2832 const sortedTimePoints = Array . from ( allTimePoints ) . sort ( ( a , b ) => a - b ) ;
2933
You can’t perform that action at this time.
0 commit comments