2026-02-19 15:48:32 +03:30
|
|
|
'use client'
|
|
|
|
|
|
|
|
|
|
// Next Imports
|
|
|
|
|
import dynamic from 'next/dynamic'
|
2026-02-19 17:21:43 +03:30
|
|
|
import { useTranslations } from 'next-intl'
|
2026-02-19 15:48:32 +03:30
|
|
|
|
|
|
|
|
// MUI Imports
|
|
|
|
|
import Card from '@mui/material/Card'
|
|
|
|
|
import CardHeader from '@mui/material/CardHeader'
|
|
|
|
|
import CardContent from '@mui/material/CardContent'
|
|
|
|
|
import { useTheme } from '@mui/material/styles'
|
|
|
|
|
|
|
|
|
|
// Third Party Imports
|
|
|
|
|
import type { ApexOptions } from 'apexcharts'
|
|
|
|
|
|
|
|
|
|
// Component Imports
|
|
|
|
|
import OptionMenu from '@core/components/option-menu'
|
|
|
|
|
|
|
|
|
|
// Styled Component Imports
|
|
|
|
|
const AppReactApexCharts = dynamic(() => import('@/libs/styles/AppReactApexCharts'))
|
|
|
|
|
|
2026-02-19 16:58:30 +03:30
|
|
|
interface SensorRadarChartProps {
|
|
|
|
|
data?: Record<string, unknown>
|
|
|
|
|
}
|
2026-02-19 15:48:32 +03:30
|
|
|
|
2026-02-19 16:58:30 +03:30
|
|
|
const SensorRadarChart = ({ data }: SensorRadarChartProps) => {
|
2026-02-19 17:21:43 +03:30
|
|
|
const t = useTranslations('farmDashboard')
|
2026-02-19 16:58:30 +03:30
|
|
|
const series = (data?.series as Array<{ name: string; data: number[] }>) ?? []
|
|
|
|
|
const labels = (data?.labels as string[]) ?? []
|
2026-02-19 15:48:32 +03:30
|
|
|
const theme = useTheme()
|
|
|
|
|
const textDisabled = 'var(--mui-palette-text-disabled)'
|
|
|
|
|
const divider = 'var(--mui-palette-divider)'
|
2026-02-19 16:58:30 +03:30
|
|
|
if (series.length === 0) return null
|
2026-02-19 15:48:32 +03:30
|
|
|
|
|
|
|
|
const options: ApexOptions = {
|
|
|
|
|
chart: {
|
|
|
|
|
parentHeightOffset: 0,
|
|
|
|
|
toolbar: { show: false }
|
|
|
|
|
},
|
|
|
|
|
colors: ['var(--mui-palette-primary-main)', 'var(--mui-palette-success-main)'],
|
|
|
|
|
plotOptions: {
|
|
|
|
|
radar: {
|
|
|
|
|
polygons: {
|
|
|
|
|
connectorColors: divider,
|
|
|
|
|
strokeColors: divider
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
stroke: { width: 0 },
|
|
|
|
|
fill: { opacity: [1, 0.5] },
|
|
|
|
|
labels,
|
|
|
|
|
markers: { size: 0 },
|
|
|
|
|
legend: {
|
|
|
|
|
fontSize: '13px',
|
|
|
|
|
labels: { colors: 'var(--mui-palette-text-secondary)' },
|
|
|
|
|
markers: { offsetY: -1, offsetX: theme.direction === 'rtl' ? 7 : -4 },
|
|
|
|
|
itemMargin: { horizontal: 9 }
|
|
|
|
|
},
|
|
|
|
|
grid: { show: false },
|
|
|
|
|
xaxis: {
|
|
|
|
|
labels: {
|
|
|
|
|
show: true,
|
|
|
|
|
style: {
|
|
|
|
|
fontSize: '13px',
|
2026-02-19 16:58:30 +03:30
|
|
|
colors: Array(labels.length || 6).fill(textDisabled)
|
2026-02-19 15:48:32 +03:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
yaxis: { show: false }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Card>
|
|
|
|
|
<CardHeader
|
2026-02-19 17:21:43 +03:30
|
|
|
title={t('cards.sensorRadarChart')}
|
2026-02-19 15:48:32 +03:30
|
|
|
subheader='Today vs Ideal Ranges'
|
|
|
|
|
action={<OptionMenu options={['Today', 'This Week', 'This Month']} />}
|
|
|
|
|
/>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<AppReactApexCharts type='radar' height={373} width='100%' series={series} options={options} />
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default SensorRadarChart
|