From a3e41cb90830bfbd21035cb68fd0efcc4d0ed349 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Thu, 9 Jan 2025 12:11:13 +0100 Subject: [PATCH] bugfixing forecast page --- src/lib/components/AnalystEstimate.svelte | 24 ++++++++++--------- .../stocks/[tickerID]/forecast/+page.svelte | 2 -- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/components/AnalystEstimate.svelte b/src/lib/components/AnalystEstimate.svelte index 76b01ff8..be0d2f7f 100644 --- a/src/lib/components/AnalystEstimate.svelte +++ b/src/lib/components/AnalystEstimate.svelte @@ -123,14 +123,13 @@ function findIndex(data) { const currentYear = new Date().getFullYear(); - // Find the index where the item's date is greater than or equal to the current year and revenue is null - const index = data.findIndex( - (item) => item.date > currentYear && item.revenue === null, + let index = data.findIndex( + (item) => item.date >= currentYear && item?.revenue === null, ); // Check if there is any item for the current year with non-null revenue - const hasNonNullRevenue = data.some( + const hasNonNullRevenue = data?.some( (item) => item.date === currentYear && item.revenue !== null, ); @@ -171,19 +170,21 @@ dates.push(`FY${date}`); switch (dataType) { case "Revenue": - valueList.push(item?.revenue); - avgList.push(isAfterStartIndex ? item.estimatedRevenueAvg : null); - lowList.push(isAfterStartIndex ? item.estimatedRevenueLow : null); - highList.push(isAfterStartIndex ? item.estimatedRevenueHigh : null); + valueList.push(isAfterStartIndex ? null : item.revenue); + avgList.push(isAfterStartIndex ? item?.estimatedRevenueAvg : null); + lowList.push(isAfterStartIndex ? item?.estimatedRevenueLow : null); + highList.push( + isAfterStartIndex ? item?.estimatedRevenueHigh : null, + ); break; case "EPS": - valueList.push(item?.eps); + valueList.push(isAfterStartIndex ? null : item.eps); avgList.push(isAfterStartIndex ? item.estimatedEpsAvg : null); lowList.push(isAfterStartIndex ? item.estimatedEpsLow : null); highList.push(isAfterStartIndex ? item.estimatedEpsHigh : null); break; case "NetIncome": - valueList.push(item?.netIncome); + valueList.push(isAfterStartIndex ? null : item.netIncome); avgList.push(isAfterStartIndex ? item.estimatedNetIncomeAvg : null); lowList.push(isAfterStartIndex ? item.estimatedNetIncomeLow : null); highList.push( @@ -191,7 +192,7 @@ ); break; case "Ebitda": - valueList.push(item?.ebitda); + valueList.push(isAfterStartIndex ? null : item.ebitda); avgList.push(isAfterStartIndex ? item.estimatedEbitdaAvg : null); lowList.push(isAfterStartIndex ? item.estimatedEbitdaLow : null); highList.push(isAfterStartIndex ? item.estimatedEbitdaHigh : null); @@ -300,6 +301,7 @@ const growth = listToUse?.find((r) => r.FY === fy); // Find matching FY return growth ? growth?.growth : null; // Return growth or null if not found }); + const option = { silent: true, tooltip: { diff --git a/src/routes/stocks/[tickerID]/forecast/+page.svelte b/src/routes/stocks/[tickerID]/forecast/+page.svelte index 03171d68..8cf0dba7 100644 --- a/src/routes/stocks/[tickerID]/forecast/+page.svelte +++ b/src/routes/stocks/[tickerID]/forecast/+page.svelte @@ -285,8 +285,6 @@ estimatedEPSAvgNextYear, estimatedEpsAvg, ); - - console.log(changeRevenue, revenue, estimatedRevenueAvg); } function getPriceForecastChart() {