diff --git a/src/components/pages/uniformity/UniformityChart.tsx b/src/components/pages/uniformity/UniformityChart.tsx index b89ce504..ba598a59 100644 --- a/src/components/pages/uniformity/UniformityChart.tsx +++ b/src/components/pages/uniformity/UniformityChart.tsx @@ -1,92 +1,25 @@ import React from 'react'; -import { - Bar, - BarChart, - Cell, - Pie, - PieChart, - Rectangle, - ResponsiveContainer, - Tooltip, - XAxis, - YAxis, -} from 'recharts'; import Card from '@/components/Card'; -import { Icon } from '@iconify/react'; -import { formatNumber } from '@/lib/helper'; +import UniformityBarChart from './chart/UniformityBarChart'; +import UniformityGaugeChart from './chart/UniformityGaugeChart'; -interface Payload { - value?: number; - name?: string; - dataKey?: string | number; +interface BarChartData { + name: string; + uv: number; } -interface CustomTooltipProps { - active?: boolean; - payload?: readonly Payload[]; - label?: string | number; -} - -interface GaugeChartProps { +interface GaugeChartData { value: number; label: string; + kandang?: string; + week?: string; + currentValue?: number; + totalValue?: number; } -const GaugeChart: React.FC = ({ value, label }) => { - const numberOfSegments = 50; - const filledSegments = Math.round((value / 100) * numberOfSegments); - - const data = Array.from({ length: numberOfSegments }, (_, index) => ({ - name: index, - value: 1, - filled: index < filledSegments, - })); - - const activeColor = '#1890ff'; - const inactiveColor = '#f0f0f0'; - - return ( -
- - - - {data.map((entry, index) => ( - - ))} - - - -
- - {value}% - -
- - {label} - -
-
-
- ); -}; - const UniformityChart = () => { - const data = [ + // TODO: Replace with actual API call + const barChartData: BarChartData[] = [ { name: '48-52', uv: 80, @@ -133,113 +66,40 @@ const UniformityChart = () => { }, ]; - const margin = { - top: 20, - right: 30, - left: 20, - bottom: 5, + // TODO: Replace with actual API call + const gaugeChartData: GaugeChartData = { + value: 52, + label: 'Uniformity', + kandang: 'Kandang Cirangga', + week: 'Week 2', + currentValue: 512, + totalValue: 1024, }; - function CustomTooltip({ payload, label, active }: CustomTooltipProps) { - if (active && payload && payload.length && label !== undefined) { - const labelStr = String(label); - return ( -
-

Uniformity 2025

-
-
-
- {payload[0].value} of Birds -
- {labelStr} -
-
- ); - } - - return null; - } - return ( -
+
- - - - - - - } - /> - - +
-
-
- -
- -
-
- -
-
-
- Kandang Cirangga - - - Week 2 - -
-
- - {formatNumber(512)} - - From - - {formatNumber(1024)} - -
-
-
-
-
+
); diff --git a/src/components/pages/uniformity/chart/UniformityBarChart.tsx b/src/components/pages/uniformity/chart/UniformityBarChart.tsx new file mode 100644 index 00000000..b37fccf2 --- /dev/null +++ b/src/components/pages/uniformity/chart/UniformityBarChart.tsx @@ -0,0 +1,91 @@ +import React from 'react'; +import { + Bar, + BarChart, + Rectangle, + ResponsiveContainer, + Tooltip, + XAxis, + YAxis, +} from 'recharts'; + +interface Payload { + value?: number; + name?: string; + dataKey?: string | number; +} + +interface CustomTooltipProps { + active?: boolean; + payload?: readonly Payload[]; + label?: string | number; +} + +interface BarChartData { + name: string; + uv: number; +} + +interface UniformityBarChartProps { + data: BarChartData[]; +} + +function CustomTooltip({ payload, label, active }: CustomTooltipProps) { + if (active && payload && payload.length && label !== undefined) { + const labelStr = String(label); + return ( +
+

Uniformity 2025

+
+
+
+ {payload[0].value} of Birds +
+ {labelStr} +
+
+ ); + } + + return null; +} + +const UniformityBarChart: React.FC = ({ data }) => { + const margin = { + top: 20, + right: 30, + left: 20, + bottom: 5, + }; + + return ( + + + + + + + } + /> + + + ); +}; + +export default UniformityBarChart; diff --git a/src/components/pages/uniformity/chart/UniformityGaugeChart.tsx b/src/components/pages/uniformity/chart/UniformityGaugeChart.tsx new file mode 100644 index 00000000..eda3d0ab --- /dev/null +++ b/src/components/pages/uniformity/chart/UniformityGaugeChart.tsx @@ -0,0 +1,108 @@ +import React from 'react'; +import { Cell, Pie, PieChart, ResponsiveContainer } from 'recharts'; +import Card from '@/components/Card'; +import { Icon } from '@iconify/react'; +import { formatNumber } from '@/lib/helper'; + +interface UniformityGaugeChartProps { + value: number; + label: string; + kandang?: string; + week?: string; + currentValue?: number; + totalValue?: number; +} + +const UniformityGaugeChart: React.FC = ({ + value, + label, + kandang, + week, + currentValue, + totalValue, +}) => { + const numberOfSegments = 50; + const filledSegments = Math.round((value / 100) * numberOfSegments); + + const data = Array.from({ length: numberOfSegments }, (_, index) => ({ + name: index, + value: 1, + filled: index < filledSegments, + })); + + const activeColor = '#1890ff'; + const inactiveColor = '#f0f0f0'; + + return ( +
+
+
+ + + + {data.map((entry, index) => ( + + ))} + + + +
+ + {value}% + +
+ + {label} + +
+
+
+
+ +
+
+ +
+
+
+ {kandang} + + + {week} + +
+
+ + {formatNumber(currentValue ?? 0)} + + From + {formatNumber(totalValue ?? 0)} +
+
+
+
+
+ ); +}; + +export default UniformityGaugeChart;