From 158dff6b2ede1888f0a61f6d9198daaec134b0e0 Mon Sep 17 00:00:00 2001
From: Bjarke Madsen <bjarke@nordu.net>
Date: Fri, 17 Jan 2025 16:15:43 +0100
Subject: [PATCH] Fix graph sizes according to NRENs in selected data instead
 of the number of selected NRENs

---
 compendium-frontend/src/pages/Network/CapacityCoreIP.tsx        | 2 +-
 compendium-frontend/src/pages/Network/CapacityLargestLink.tsx   | 2 +-
 compendium-frontend/src/pages/Network/NonRAndEPeer.tsx          | 2 +-
 compendium-frontend/src/pages/Organization/FundingSource.tsx    | 2 +-
 .../src/pages/Organization/StaffGraphAbsolute.tsx               | 2 +-
 .../src/pages/Standards&Policies/CentralProcurement.tsx         | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/compendium-frontend/src/pages/Network/CapacityCoreIP.tsx b/compendium-frontend/src/pages/Network/CapacityCoreIP.tsx
index faa850cb..4c49cbe6 100644
--- a/compendium-frontend/src/pages/Network/CapacityCoreIP.tsx
+++ b/compendium-frontend/src/pages/Network/CapacityCoreIP.tsx
@@ -40,7 +40,7 @@ function CapacityCoreIPPage() {
         setFilterSelection={setFilterSelection}
     />
 
-    const numNrens = filterSelection.selectedNrens.length;
+    const numNrens = Array.from(new Set(selectedData.map(c => c.nren))).length;
     const heightPerBar = 1.5; // every added bar should give this much additional height
 
     // set a minimum height of 50rem
diff --git a/compendium-frontend/src/pages/Network/CapacityLargestLink.tsx b/compendium-frontend/src/pages/Network/CapacityLargestLink.tsx
index 09de1c99..d3d7a50d 100644
--- a/compendium-frontend/src/pages/Network/CapacityLargestLink.tsx
+++ b/compendium-frontend/src/pages/Network/CapacityLargestLink.tsx
@@ -40,7 +40,7 @@ function CapacityLargestLinkPage() {
         setFilterSelection={setFilterSelection}
     />
 
-    const numNrens = filterSelection.selectedNrens.length;
+    const numNrens = Array.from(new Set(selectedData.map(c => c.nren))).length;
     const heightPerBar = 1.5; // every added bar should give this much additional height
 
     // set a minimum height of 50rem
diff --git a/compendium-frontend/src/pages/Network/NonRAndEPeer.tsx b/compendium-frontend/src/pages/Network/NonRAndEPeer.tsx
index df143fbe..d83768e5 100644
--- a/compendium-frontend/src/pages/Network/NonRAndEPeer.tsx
+++ b/compendium-frontend/src/pages/Network/NonRAndEPeer.tsx
@@ -37,7 +37,7 @@ function NonRAndEPeerPage() {
         setFilterSelection={setFilterSelection}
     />
 
-    const numNrens = filterSelection.selectedNrens.length;
+    const numNrens = Array.from(new Set(selectedData.map(c => c.nren))).length;
     const heightPerBar = 1.5; // every added bar should give this much additional height
 
     // set a minimum height of 50rem
diff --git a/compendium-frontend/src/pages/Organization/FundingSource.tsx b/compendium-frontend/src/pages/Organization/FundingSource.tsx
index d9c1248c..9d6befe9 100644
--- a/compendium-frontend/src/pages/Organization/FundingSource.tsx
+++ b/compendium-frontend/src/pages/Organization/FundingSource.tsx
@@ -148,7 +148,7 @@ function FundingSourcePage() {
     setFilterSelection={setFilterSelection}
   />
 
-  const numNrens = filterSelection.selectedNrens.length;
+  const numNrens = Array.from(new Set(selectedData.map(c => c.nren))).length;
   const numYears = filterSelection.selectedYears.length;
   const heightPerBar = 2; // every added bar should give this much additional height
 
diff --git a/compendium-frontend/src/pages/Organization/StaffGraphAbsolute.tsx b/compendium-frontend/src/pages/Organization/StaffGraphAbsolute.tsx
index dec574fb..8e218480 100644
--- a/compendium-frontend/src/pages/Organization/StaffGraphAbsolute.tsx
+++ b/compendium-frontend/src/pages/Organization/StaffGraphAbsolute.tsx
@@ -38,7 +38,7 @@ function StaffGraphAbsolutePage() {
         setFilterSelection={setFilterSelection}
     />
 
-    const numNrens = filterSelection.selectedNrens.length;
+    const numNrens = Array.from(new Set(selectedData.map(c => c.nren))).length;
     const heightPerBar = 1.5; // every added bar should give this much additional height
 
     // set a minimum height of 50rem
diff --git a/compendium-frontend/src/pages/Standards&Policies/CentralProcurement.tsx b/compendium-frontend/src/pages/Standards&Policies/CentralProcurement.tsx
index ea02b82a..10093a7e 100644
--- a/compendium-frontend/src/pages/Standards&Policies/CentralProcurement.tsx
+++ b/compendium-frontend/src/pages/Standards&Policies/CentralProcurement.tsx
@@ -48,7 +48,7 @@ function CentralProcurementPage() {
         setFilterSelection={setFilterSelection}
     />
 
-    const numNrens = filterSelection.selectedNrens.length;
+    const numNrens = Array.from(new Set(selectedData.map(c => c.nren))).length;
     const heightPerBar = 1.5; // every added bar should give this much additional height
 
     // set a minimum height of 50rem
-- 
GitLab