diff --git a/src/admin/components/ResourceTabs/MonitoredTab/components/EcoRegionDoughnutChart.tsx b/src/admin/components/ResourceTabs/MonitoredTab/components/EcoRegionDoughnutChart.tsx
new file mode 100644
index 000000000..c0a4efc4f
--- /dev/null
+++ b/src/admin/components/ResourceTabs/MonitoredTab/components/EcoRegionDoughnutChart.tsx
@@ -0,0 +1,128 @@
+import React, { useState } from "react";
+import { Cell, Label, Legend, Pie, PieChart, ResponsiveContainer, Sector, Tooltip } from "recharts";
+
+interface ChartDataItem {
+ name: string;
+ value: number;
+}
+
+export interface EcoRegionData {
+ chartData: ChartDataItem[];
+ total: number;
+}
+
+interface EcoRegionDoughnutChartProps {
+ data: EcoRegionData;
+}
+
+type LegendPayload = {
+ value: string;
+ id?: string;
+ type?: string;
+ color?: string;
+};
+
+interface CustomLegendProps {
+ payload?: LegendPayload[];
+}
+
+const COLORS = ["#FFD699", "#90EE90", "#2F4F4F", "#BDB76B", "#98FB98"];
+
+const CustomLegend = ({ payload }: CustomLegendProps) => {
+ if (!payload) return null;
+ return (
+
+ {payload.map((entry, index) => (
+ -
+
+ {entry.value}
+
+ ))}
+
+ );
+};
+
+const CustomTooltip = ({ active, payload }: any) => {
+ if (active && payload && payload.length) {
+ return (
+
+
{payload[0].name}
+
{`Value: ${payload[0].value}`}
+
+ );
+ }
+ return null;
+};
+
+const renderActiveShape = (props: any) => {
+ const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, fill } = props;
+ return (
+
+
+
+ );
+};
+
+const EcoRegionDoughnutChart: React.FC
= ({ data }) => {
+ const { chartData } = data;
+ const [activeIndex, setActiveIndex] = useState(undefined);
+
+ const onPieEnter = (_: any, index: number) => {
+ setActiveIndex(index);
+ };
+
+ const onPieLeave = () => {
+ setActiveIndex(undefined);
+ };
+
+ return (
+
+
+
+ } />
+
+
+ {chartData.map((entry, index) => (
+ |
+ ))}
+
+
+
+
+ );
+};
+
+export default EcoRegionDoughnutChart;
diff --git a/src/constants/dashboardConsts.ts b/src/constants/dashboardConsts.ts
index b64565569..71f1f109e 100644
--- a/src/constants/dashboardConsts.ts
+++ b/src/constants/dashboardConsts.ts
@@ -58,6 +58,11 @@ export const DEFAULT_POLYGONS_DATA_STRATEGIES = [
{ label: "Multiple Strategies", value: 0 }
];
+export const DEFAULT_POLYGONS_DATA_ECOREGIONS = {
+ chartData: [],
+ total: 0
+};
+
export const DUMMY_DATA_FOR_CHART_MULTI_LINE_CHART = [
{
name: "Total",
diff --git a/src/utils/dashboardUtils.ts b/src/utils/dashboardUtils.ts
index 8137e4ab2..b2dd8436b 100644
--- a/src/utils/dashboardUtils.ts
+++ b/src/utils/dashboardUtils.ts
@@ -139,6 +139,11 @@ export interface ParsedPolygonsData {
};
}
+interface ParsedResult {
+ chartData: ChartDataItem[];
+ total: number;
+}
+
export const formatNumberUS = (value: number) =>
value ? (value >= 1000000 ? `${(value / 1000000).toFixed(2)}M` : value.toLocaleString("en-US")) : "";
@@ -519,3 +524,28 @@ export const parsePolygonsIndicatorDataForStrategies = (polygonsIndicator: Polyg
value: Number(value.toFixed(2))
}));
};
+
+export const parsePolygonsIndicatorDataForEcoRegion = (polygons: PolygonIndicator[]): ParsedResult => {
+ const result: ParsedResult = {
+ chartData: [],
+ total: 0
+ };
+
+ const ecoRegionMap = new Map();
+
+ polygons.forEach(polygon => {
+ polygon.data &&
+ Object.entries(polygon.data).forEach(([name, value]) => {
+ ecoRegionMap.set(name, (ecoRegionMap.get(name) || 0) + value);
+ });
+ });
+
+ result.chartData = Array.from(ecoRegionMap, ([name, value]) => ({
+ name: formatLabel(name),
+ value: Number(value.toFixed(3))
+ }));
+
+ result.total = Number(result.chartData.reduce((sum, item) => sum + Number(item.value), 0).toFixed(3));
+
+ return result;
+};