Files
Frontend/src/views/dashboards/farm/SensorRadarChart.tsx
T

86 lines
2.2 KiB
TypeScript
Raw Normal View History

'use client'
// Next Imports
import dynamic from 'next/dynamic'
// 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'))
// Vars - Today vs ideal ranges (normalized 0-100)
const series = [
{ name: 'Today', data: [75, 65, 80, 70, 85, 60] },
{ name: 'Ideal', data: [80, 70, 75, 75, 90, 50] }
]
const labels = ['Temp', 'Humidity', 'pH', 'EC', 'Light', 'Wind']
const SensorRadarChart = () => {
const theme = useTheme()
const textDisabled = 'var(--mui-palette-text-disabled)'
const divider = 'var(--mui-palette-divider)'
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',
colors: Array(6).fill(textDisabled)
}
}
},
yaxis: { show: false }
}
return (
<Card>
<CardHeader
title='Sensor Comparison'
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