mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-18 11:36:17 +00:00
Update network-traffic-chart.tsx
This commit is contained in:
@@ -47,6 +47,7 @@ export function NetworkTrafficChart({
|
|||||||
const [data, setData] = useState<NetworkMetricsData[]>([])
|
const [data, setData] = useState<NetworkMetricsData[]>([])
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
|
const [isInitialLoad, setIsInitialLoad] = useState(true)
|
||||||
const [visibleLines, setVisibleLines] = useState({
|
const [visibleLines, setVisibleLines] = useState({
|
||||||
netIn: true,
|
netIn: true,
|
||||||
netOut: true,
|
netOut: true,
|
||||||
@@ -158,6 +159,10 @@ export function NetworkTrafficChart({
|
|||||||
if (onTotalsCalculated) {
|
if (onTotalsCalculated) {
|
||||||
onTotalsCalculated({ received: totalReceived, sent: totalSent })
|
onTotalsCalculated({ received: totalReceived, sent: totalSent })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isInitialLoad) {
|
||||||
|
setIsInitialLoad(false)
|
||||||
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.error("[v0] Error fetching network metrics:", err)
|
console.error("[v0] Error fetching network metrics:", err)
|
||||||
setError(err.message || "Error loading metrics")
|
setError(err.message || "Error loading metrics")
|
||||||
@@ -171,7 +176,7 @@ export function NetworkTrafficChart({
|
|||||||
const handleLegendClick = (dataKey: string) => {
|
const handleLegendClick = (dataKey: string) => {
|
||||||
setVisibleLines((prev) => ({
|
setVisibleLines((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
[dataKey]: !prev[dataKey as keyof typeof prev],
|
[dataKey as keyof typeof prev]: !prev[dataKey as keyof typeof prev],
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,6 +259,8 @@ export function NetworkTrafficChart({
|
|||||||
fillOpacity={0.3}
|
fillOpacity={0.3}
|
||||||
name="Received"
|
name="Received"
|
||||||
hide={!visibleLines.netIn}
|
hide={!visibleLines.netIn}
|
||||||
|
isAnimationActive={isInitialLoad}
|
||||||
|
animationDuration={800}
|
||||||
/>
|
/>
|
||||||
<Area
|
<Area
|
||||||
type="monotone"
|
type="monotone"
|
||||||
@@ -264,6 +271,8 @@ export function NetworkTrafficChart({
|
|||||||
fillOpacity={0.3}
|
fillOpacity={0.3}
|
||||||
name="Sent"
|
name="Sent"
|
||||||
hide={!visibleLines.netOut}
|
hide={!visibleLines.netOut}
|
||||||
|
isAnimationActive={isInitialLoad}
|
||||||
|
animationDuration={800}
|
||||||
/>
|
/>
|
||||||
</AreaChart>
|
</AreaChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
|
|||||||
Reference in New Issue
Block a user