From 12b3662c5aaa9820f96846af44e5db163791512f Mon Sep 17 00:00:00 2001
From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>
Date: Tue, 28 Oct 2025 10:33:14 +0400
Subject: fix/frontend: start timeline at the start of the year (#294)

---
 frontend/src/pages/Homepage.tsx | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

(limited to 'frontend/src/pages/Homepage.tsx')

diff --git a/frontend/src/pages/Homepage.tsx b/frontend/src/pages/Homepage.tsx
index 77dc220..c0dbf68 100644
--- a/frontend/src/pages/Homepage.tsx
+++ b/frontend/src/pages/Homepage.tsx
@@ -18,19 +18,18 @@ const Homepage: React.FC = () => {
     if (data.length === 0) {
       return [];
     };
-    const sortedData = [...data].sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
-    const startDate = new Date(sortedData[0].date);
+    const startDate = new Date(data[0].date);
     const today = new Date();
 
     const result: PortalCountData[] = [];
-    let currentDate = new Date(startDate.getFullYear(), startDate.getMonth(), 1);
+    let currentDate = new Date(startDate.getFullYear(), 0, 1);
 
     let dataIndex = 0;
-    let currentCount = sortedData[0].count;
+    let currentCount = data[0].count;
 
     while (currentDate <= today) {
-      while (dataIndex < sortedData.length && new Date(sortedData[dataIndex].date) <= currentDate) {
-        currentCount = sortedData[dataIndex].count;
+      while (dataIndex < data.length && new Date(data[dataIndex].date) <= currentDate) {
+        currentCount = data[dataIndex].count;
         dataIndex++;
       }
       result.push({
-- 
cgit v1.2.3

