bugfixing

This commit is contained in:
MuslemRahimi 2024-11-27 16:28:26 +01:00
parent ef6e0d2261
commit bbb2b42013

View File

@ -35,26 +35,37 @@
let highEPSList = []; let highEPSList = [];
let revenueAvgGrowthList = []; let revenueAvgGrowthList = [];
let revenueLowGrowthList = [];
let epsAvgGrowthList = []; let epsAvgGrowthList = [];
let displayData = "Revenue"; let displayData = "Revenue";
function fillMissingDates(dates, highGrowthList) { function fillMissingDates(dates, highGrowthList) {
// Get the current year
const currentYear = new Date().getFullYear();
const currentFiscalYear = `FY${currentYear % 100}`; // Get the current fiscal year (e.g., 2024 => FY24)
// Create a map from the highGrowthList for quick lookup // Create a map from the highGrowthList for quick lookup
const highGrowthMap = new Map( const highGrowthMap = new Map(
highGrowthList?.map((item) => [`FY${item.FY}`, item]), highGrowthList?.map((item) => [`FY${item.FY}`, item]),
); );
// Generate the complete list based on the dates array // Generate the complete list based on the dates array
return dates.map( return dates?.map((date) => {
(date) => // Check if the date is the current fiscal year or it exists in the map
highGrowthMap.get(date) || { const data = highGrowthMap?.get(date) || {
FY: date?.slice(2), FY: date?.slice(2),
val: null, val: null,
growth: null, growth: null,
}, };
);
// If the fiscal year is the current one, set val and growth to null
if (date === currentFiscalYear) {
data.val = null;
data.growth = null;
}
return data;
});
} }
function computeGrowthSingleList(data, actualList) { function computeGrowthSingleList(data, actualList) {
@ -357,11 +368,9 @@
lowGrowthList = computeGrowthSingleList(lowEPSList, tableActualEPS); lowGrowthList = computeGrowthSingleList(lowEPSList, tableActualEPS);
} }
console.log(highGrowthList);
highGrowthList = fillMissingDates(dates, highGrowthList)?.map( highGrowthList = fillMissingDates(dates, highGrowthList)?.map(
(item) => item?.growth, (item) => item?.growth,
); );
console.log(highGrowthList);
lowGrowthList = fillMissingDates(dates, lowGrowthList)?.map( lowGrowthList = fillMissingDates(dates, lowGrowthList)?.map(
(item) => item?.growth, (item) => item?.growth,