|
|
@@ -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;
|
|
|
+}
|