From 87a7102b123ac1c2d16d7fba6436546b86bd1649 Mon Sep 17 00:00:00 2001 From: lumijiez <59575049+lumijiez@users.noreply.github.com> Date: Thu, 22 May 2025 00:47:48 +0300 Subject: [PATCH] charts are now pretty --- src/app/page.js | 14 ++++++++++++-- src/components/SolarChart.js | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/app/page.js b/src/app/page.js index 599699e..461f8b7 100644 --- a/src/app/page.js +++ b/src/app/page.js @@ -16,6 +16,7 @@ export default function Dashboard() { const [currentData, setCurrentData] = useState([]) const [timeRange, setTimeRange] = useState('today') const [loading, setLoading] = useState(true) + const [minLoadingComplete, setMinLoadingComplete] = useState(false) const fetchCurrentData = async () => { try { @@ -40,16 +41,25 @@ export default function Dashboard() { } useEffect(() => { + // Set minimum loading time + const minLoadingTimer = setTimeout(() => { + setMinLoadingComplete(true) + }, 500) + fetchCurrentData() const currentInterval = setInterval(fetchCurrentData, 20000) - return () => clearInterval(currentInterval) + + return () => { + clearInterval(currentInterval) + clearTimeout(minLoadingTimer) + } }, []) useEffect(() => { fetchHistoricalData() }, [timeRange]) - if (loading) { + if (loading || !minLoadingComplete) { return (
))} - + {config.lines.map(line => (