25 Angajamente dc59d692d2 ... 8a8383f710

Autor SHA1 Permisiunea de a trimite mesaje. Dacă este dezactivată, utilizatorul nu va putea trimite nici un fel de mesaj Data
  raylu 8a8383f710 render company rank without profits 5 zile în urmă
  raylu 79f040da8a stop busting the cache with ?cb=now 1 săptămână în urmă
  raylu 60aeafd7b6 update all companies 1 săptămână în urmă
  raylu c016085c8d known companies 1 săptămână în urmă
  raylu 27c1fdb0bb permalink to new domain 1 săptămână în urmă
  raylu 5308b23586 may26 1 săptămână în urmă
  raylu 63a3bdbc47 prepare data 1 săptămână în urmă
  raylu 92c38b7e56 rename raw data to match www/data/ 1 săptămână în urmă
  raylu 716cff8217 may 2026 raw data 1 săptămână în urmă
  raylu 265e40a4b9 fix tsconfig 1 săptămână în urmă
  raylu 6f3ba21a05 get off webpack, move compiled files to www 1 săptămână în urmă
  raylu da6a35c199 move out of reports/ 1 săptămână în urmă
  raylu 914da1c04c switch to bun 1 săptămână în urmă
  raylu dc59d692d2 stop busting the cache with ?cb=now 1 săptămână în urmă
  raylu f8e4a7d5a7 update all companies 1 săptămână în urmă
  raylu e1d74ab55b known companies 1 săptămână în urmă
  raylu 1ee4d87c94 permalink to new domain 1 săptămână în urmă
  raylu de027f5906 may26 1 săptămână în urmă
  raylu 45c9e31fc4 prepare data 1 săptămână în urmă
  raylu b5575885d7 rename raw data to match www/data/ 1 săptămână în urmă
  raylu f491d700e5 may 2026 raw data 1 săptămână în urmă
  raylu 8da54bff78 fix tsconfig 1 săptămână în urmă
  raylu 5ad3aa01f9 get off webpack, move compiled files to www 1 săptămână în urmă
  raylu 3a9069ab19 move out of reports/ 1 săptămână în urmă
  raylu eb0ddd752d switch to bun 1 săptămână în urmă
1 a modificat fișierele cu 29 adăugiri și 18 ștergeri
  1. 29 18
      src/graphs/companyRank.ts

+ 29 - 18
src/graphs/companyRank.ts

@@ -44,9 +44,10 @@ export class CompanyRank implements Graph {
         if(!companyID){ return; }
         var companyName = knownCompanies[companyID]?.Username;
 
-        // Get Data
-        const fullCompanyData = await getData(this.loadedData, "company", configValues.month);    // Company data for the current month
-        const fullPrevCompanyData = configValues.month == months[0] ? {individual: {}} : await getData(this.loadedData, "company", months[months.indexOf(configValues.month) - 1])
+        const fullCompanyData: FullCompanyData = await getData(this.loadedData, "company", configValues.month);
+        const fullPrevCompanyData: FullCompanyData = configValues.month == months[0] ?
+                {individual: {}} :
+                await getData(this.loadedData, "company", months[months.indexOf(configValues.month) - 1]);
         
         const companyData = fullCompanyData.individual[companyID];  // Company data for this company for this month
         const prevCompanyData = fullPrevCompanyData.individual[companyID];  // Company data for this company for last month. May be undefined.
@@ -82,7 +83,7 @@ export class CompanyRank implements Graph {
 				    symbolDiv.style.color = increasing ? "#d9534f" : "#5cb85c";
                 }
                 
-                rankDiv.textContent = companyData[ticker].rank;
+                rankDiv.textContent = companyData[ticker].rank.toLocaleString();
 
                 outerRankDiv.appendChild(symbolDiv);
                 outerRankDiv.appendChild(rankDiv);
@@ -91,7 +92,7 @@ export class CompanyRank implements Graph {
             else
             {
                 const rankDiv = document.createElement("div");
-                rankDiv.textContent = companyData[ticker].rank;
+                rankDiv.textContent = companyData[ticker].rank.toLocaleString();
                 tableDisplayRow.push(rankDiv);
             }
 
@@ -112,15 +113,12 @@ export class CompanyRank implements Graph {
 
             // Add profit
             const profitDiv = document.createElement("div");
-            var profitText: string;
-            if(companyData[ticker].profit < 0)
-            {
-                profitText = "-$" + (-companyData[ticker].profit).toLocaleString(undefined, {notation: "compact", maximumSignificantDigits: 3});
-            }
-            else
-            {
-                profitText = "$" + companyData[ticker].profit.toLocaleString(undefined, {notation: "compact", maximumSignificantDigits: 3});
-            }
+            const profit = companyData[ticker].profit ?? NaN;
+            let profitText: string = "";
+            if (profit < 0)
+                profitText = "-$" + (-profit).toLocaleString(undefined, {notation: "compact", maximumSignificantDigits: 3});
+            else if (profit > 0)
+                profitText = "$" + profit.toLocaleString(undefined, {notation: "compact", maximumSignificantDigits: 3});
             profitDiv.textContent = profitText;
             tableDisplayRow.push(profitDiv);
 
@@ -136,12 +134,25 @@ export class CompanyRank implements Graph {
         tableDisplay = indices.map(i => tableDisplay[i]);
 
         // Get overall ranks for the title
-        const volumeRank = fullCompanyData.totals.volumeRank;
-
         const title = "Production Ranking of " + companyName + " - " + prettyMonthName(configValues.month) + "\nVolume: #" + fullCompanyData.totals[companyID].volumeRank + ", Profit: #" + fullCompanyData.totals[companyID].profitRank;
 
         const headers = ["Rank", "Ticker", "Amount [/day]", "Volume [$/day]", "Profit [$/day]"];
-
         createTable(plotContainerID, title, headers, tableData, tableDisplay);
     }
-}
+}
+
+interface FullCompanyData {
+    totals: Record<string, CompanyTotals>;
+    individual: Record<string, Record<string, CompanyTickerData>>;
+}
+interface CompanyTotals {
+	volume: number;
+	volumeRank: number;
+    profitRank?: number;
+}
+interface CompanyTickerData {
+	amount: number;
+	volume: number;
+	rank: number;
+	profit?: number;
+}