mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
Compare commits
No commits in common. "f49ca034cb8b85828349101ddf618986023bf90e" and "8fbe50fd8d51ae1d56a9108ff36ca00fe7af0c99" have entirely different histories.
f49ca034cb
...
8fbe50fd8d
@ -289,34 +289,16 @@ export const NetworkChart = React.memo(function NetworkChart({
|
|||||||
axisLine={false}
|
axisLine={false}
|
||||||
tickMargin={8}
|
tickMargin={8}
|
||||||
minTickGap={80}
|
minTickGap={80}
|
||||||
|
interval={0}
|
||||||
ticks={processedData
|
ticks={processedData
|
||||||
.filter((item, index, array) => {
|
.filter((item) => {
|
||||||
if (array.length < 6) {
|
|
||||||
return index === 0 || index === array.length - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算数据的总时间跨度(毫秒)
|
|
||||||
const timeSpan = array[array.length - 1].created_at - array[0].created_at
|
|
||||||
const hours = timeSpan / (1000 * 60 * 60)
|
|
||||||
|
|
||||||
// 根据时间跨度调整显示间隔
|
|
||||||
if (hours <= 12) {
|
|
||||||
// 12小时内,每60分钟显示一个刻度
|
|
||||||
return (
|
|
||||||
index === 0 ||
|
|
||||||
index === array.length - 1 ||
|
|
||||||
new Date(item.created_at).getMinutes() % 60 === 0
|
|
||||||
)
|
|
||||||
}
|
|
||||||
// 超过12小时,每2小时显示一个刻度
|
|
||||||
const date = new Date(item.created_at)
|
const date = new Date(item.created_at)
|
||||||
return date.getMinutes() === 0 && date.getHours() % 2 === 0
|
return date.getMinutes() === 0 && date.getHours() % 3 === 0
|
||||||
})
|
})
|
||||||
.map((item) => item.created_at)}
|
.map((item) => item.created_at)}
|
||||||
tickFormatter={(value) => {
|
tickFormatter={(value) => {
|
||||||
const date = new Date(value)
|
const date = new Date(value)
|
||||||
const minutes = date.getMinutes()
|
return `${date.getHours()}:00`
|
||||||
return minutes === 0 ? `${date.getHours()}:00` : `${date.getHours()}:${minutes}`
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<YAxis
|
<YAxis
|
||||||
|
@ -30,7 +30,7 @@ const useCurrentTime = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const intervalId = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
const now = DateTime.now().setLocale("en-US")
|
const now = DateTime.now().setLocale("en-US")
|
||||||
setTime({
|
setTime({
|
||||||
hh: now.hour,
|
hh: now.hour,
|
||||||
@ -39,7 +39,7 @@ const useCurrentTime = () => {
|
|||||||
})
|
})
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
return () => clearInterval(intervalId)
|
return () => clearInterval(timer)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return time
|
return time
|
||||||
|
Loading…
Reference in New Issue
Block a user