File size: 3,580 Bytes
3eba919
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { motion } from "framer-motion";
import {
  BarChart,
  Bar,
  XAxis,
  YAxis,
  CartesianGrid,
  Tooltip,
  ResponsiveContainer,
  PieChart,
  Pie,
  Cell,
} from "recharts";

const zoneData = [
  { zone: "Z1", infestation: 12 },
  { zone: "Z2", infestation: 28 },
  { zone: "Z3", infestation: 8 },
  { zone: "Z4", infestation: 35 },
  { zone: "Z5", infestation: 22 },
  { zone: "Z6", infestation: 18 },
  { zone: "Z7", infestation: 42 },
  { zone: "Z8", infestation: 15 },
  { zone: "Z9", infestation: 9 },
];

const weedTypes = [
  { name: "Amaranthus", value: 35, color: "hsl(0, 65%, 50%)" },
  { name: "Cyperus", value: 25, color: "hsl(30, 80%, 50%)" },
  { name: "Echinochloa", value: 20, color: "hsl(45, 90%, 50%)" },
  { name: "Digitaria", value: 12, color: "hsl(145, 50%, 40%)" },
  { name: "Other", value: 8, color: "hsl(200, 40%, 50%)" },
];

const AnalyticsPanel = () => (
  <motion.div
    initial={{ opacity: 0, y: 20 }}
    animate={{ opacity: 1, y: 0 }}
    transition={{ delay: 0.2 }}
    className="space-y-6"
  >
    <h3 className="text-lg font-semibold text-foreground">Analytics Dashboard</h3>

    <div className="grid gap-6 lg:grid-cols-2">
      {/* Bar chart */}
      <div className="rounded-xl border bg-card p-5 shadow-card">
        <h4 className="mb-4 text-sm font-medium text-muted-foreground">
          Infestation Rate by Zone (%)
        </h4>
        <ResponsiveContainer width="100%" height={240}>
          <BarChart data={zoneData}>
            <CartesianGrid strokeDasharray="3 3" stroke="hsl(40 20% 88%)" />
            <XAxis dataKey="zone" tick={{ fontSize: 12 }} stroke="hsl(25 15% 45%)" />
            <YAxis tick={{ fontSize: 12 }} stroke="hsl(25 15% 45%)" />
            <Tooltip
              contentStyle={{
                background: "hsl(40 33% 97%)",
                border: "1px solid hsl(40 20% 88%)",
                borderRadius: "8px",
                fontSize: 12,
              }}
            />
            <Bar dataKey="infestation" fill="hsl(145 45% 28%)" radius={[4, 4, 0, 0]} />
          </BarChart>
        </ResponsiveContainer>
      </div>

      {/* Pie chart */}
      <div className="rounded-xl border bg-card p-5 shadow-card">
        <h4 className="mb-4 text-sm font-medium text-muted-foreground">
          Weed Species Distribution
        </h4>
        <ResponsiveContainer width="100%" height={240}>
          <PieChart>
            <Pie
              data={weedTypes}
              cx="50%"
              cy="50%"
              innerRadius={55}
              outerRadius={90}
              paddingAngle={3}
              dataKey="value"
            >
              {weedTypes.map((entry, index) => (
                <Cell key={index} fill={entry.color} />
              ))}
            </Pie>
            <Tooltip
              contentStyle={{
                background: "hsl(40 33% 97%)",
                border: "1px solid hsl(40 20% 88%)",
                borderRadius: "8px",
                fontSize: 12,
              }}
            />
          </PieChart>
        </ResponsiveContainer>
        <div className="mt-3 flex flex-wrap justify-center gap-3">
          {weedTypes.map((w) => (
            <div key={w.name} className="flex items-center gap-1.5 text-xs text-muted-foreground">
              <span
                className="h-2.5 w-2.5 rounded-full"
                style={{ background: w.color }}
              />
              {w.name} ({w.value}%)
            </div>
          ))}
        </div>
      </div>
    </div>
  </motion.div>
);

export default AnalyticsPanel;