charts are now pretty
This commit is contained in:
@@ -16,6 +16,7 @@ export default function Dashboard() {
|
|||||||
const [currentData, setCurrentData] = useState([])
|
const [currentData, setCurrentData] = useState([])
|
||||||
const [timeRange, setTimeRange] = useState('today')
|
const [timeRange, setTimeRange] = useState('today')
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [minLoadingComplete, setMinLoadingComplete] = useState(false)
|
||||||
|
|
||||||
const fetchCurrentData = async () => {
|
const fetchCurrentData = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -40,16 +41,25 @@ export default function Dashboard() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// Set minimum loading time
|
||||||
|
const minLoadingTimer = setTimeout(() => {
|
||||||
|
setMinLoadingComplete(true)
|
||||||
|
}, 500)
|
||||||
|
|
||||||
fetchCurrentData()
|
fetchCurrentData()
|
||||||
const currentInterval = setInterval(fetchCurrentData, 20000)
|
const currentInterval = setInterval(fetchCurrentData, 20000)
|
||||||
return () => clearInterval(currentInterval)
|
|
||||||
|
return () => {
|
||||||
|
clearInterval(currentInterval)
|
||||||
|
clearTimeout(minLoadingTimer)
|
||||||
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchHistoricalData()
|
fetchHistoricalData()
|
||||||
}, [timeRange])
|
}, [timeRange])
|
||||||
|
|
||||||
if (loading) {
|
if (loading || !minLoadingComplete) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
<div className="flex items-center justify-center min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
||||||
<motion.div
|
<motion.div
|
||||||
|
|||||||
@@ -207,7 +207,12 @@ export function SolarChart({ data, type, timeRange, onTimeRangeChange }) {
|
|||||||
</linearGradient>
|
</linearGradient>
|
||||||
))}
|
))}
|
||||||
</defs>
|
</defs>
|
||||||
<CartesianGrid strokeDasharray="3 3" stroke="#374151" opacity={0.1} />
|
<CartesianGrid
|
||||||
|
strokeDasharray="3 3"
|
||||||
|
stroke="#374151"
|
||||||
|
opacity={0.1}
|
||||||
|
vertical={false}
|
||||||
|
/>
|
||||||
<XAxis
|
<XAxis
|
||||||
dataKey="timestamp"
|
dataKey="timestamp"
|
||||||
stroke="#6B7280"
|
stroke="#6B7280"
|
||||||
@@ -230,6 +235,7 @@ export function SolarChart({ data, type, timeRange, onTimeRangeChange }) {
|
|||||||
stroke="#6B7280"
|
stroke="#6B7280"
|
||||||
tick={{ fill: '#6B7280', fontSize: 11 }}
|
tick={{ fill: '#6B7280', fontSize: 11 }}
|
||||||
tickLine={{ stroke: '#6B7280' }}
|
tickLine={{ stroke: '#6B7280' }}
|
||||||
|
axisLine={false}
|
||||||
/>
|
/>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
contentStyle={{
|
contentStyle={{
|
||||||
@@ -242,6 +248,7 @@ export function SolarChart({ data, type, timeRange, onTimeRangeChange }) {
|
|||||||
backdropFilter: 'blur(8px)'
|
backdropFilter: 'blur(8px)'
|
||||||
}}
|
}}
|
||||||
labelStyle={{ color: '#F3F4F6', fontSize: '11px' }}
|
labelStyle={{ color: '#F3F4F6', fontSize: '11px' }}
|
||||||
|
cursor={{ stroke: 'rgba(255, 255, 255, 0.1)', strokeWidth: 2 }}
|
||||||
/>
|
/>
|
||||||
<Legend
|
<Legend
|
||||||
wrapperStyle={{
|
wrapperStyle={{
|
||||||
@@ -249,6 +256,8 @@ export function SolarChart({ data, type, timeRange, onTimeRangeChange }) {
|
|||||||
color: '#6B7280',
|
color: '#6B7280',
|
||||||
fontSize: '10px'
|
fontSize: '10px'
|
||||||
}}
|
}}
|
||||||
|
iconType="circle"
|
||||||
|
iconSize={8}
|
||||||
/>
|
/>
|
||||||
{config.lines.map(line => (
|
{config.lines.map(line => (
|
||||||
<Line
|
<Line
|
||||||
@@ -259,7 +268,13 @@ export function SolarChart({ data, type, timeRange, onTimeRangeChange }) {
|
|||||||
stroke={line.color}
|
stroke={line.color}
|
||||||
strokeWidth={2}
|
strokeWidth={2}
|
||||||
dot={false}
|
dot={false}
|
||||||
activeDot={{ r: 6, fill: line.color, strokeWidth: 2, stroke: 'rgba(255, 255, 255, 0.2)' }}
|
activeDot={{
|
||||||
|
r: 6,
|
||||||
|
fill: line.color,
|
||||||
|
strokeWidth: 2,
|
||||||
|
stroke: 'rgba(255, 255, 255, 0.2)',
|
||||||
|
filter: 'drop-shadow(0 0 4px rgba(255, 255, 255, 0.2))'
|
||||||
|
}}
|
||||||
animationDuration={1500}
|
animationDuration={1500}
|
||||||
animationBegin={0}
|
animationBegin={0}
|
||||||
strokeLinecap="round"
|
strokeLinecap="round"
|
||||||
|
|||||||
Reference in New Issue
Block a user