bugfixing

This commit is contained in:
MuslemRahimi 2024-08-31 19:32:27 +02:00
parent 4e5c7d5719
commit 424c93977a
2 changed files with 17 additions and 9 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { analystEstimateComponent, stockTicker, screenWidth, getCache, setCache } from "$lib/store";
import { analystEstimateComponent, stockTicker } from "$lib/store";
import InfoModal from "$lib/components/InfoModal.svelte";
import { Chart } from "svelte-echarts";
@ -71,11 +71,10 @@ function findIndex(data) {
switch (displayData) {
case "Revenue":
valueList.push(isBeforeStopIndex ? item.revenue : null);
avgList.push(isAfterStartIndex ? item.estimatedRevenueAvg : null);
lowList.push(isAfterStartIndex ? item.estimatedRevenueLow : null);
highList.push(isAfterStartIndex ? item.estimatedRevenueHigh : null);
break;
avgList.push(isAfterStartIndex ? item.estimatedRevenueAvg : null);
lowList.push(isAfterStartIndex ? item.estimatedRevenueLow : null);
highList.push(isAfterStartIndex ? item.estimatedRevenueHigh : null);
break;
case "Net Income":
valueList.push(isBeforeStopIndex ? item.netIncome : null);
avgList.push(isAfterStartIndex ? item.estimatedNetIncomeAvg : null);
@ -99,8 +98,18 @@ function findIndex(data) {
break;
}
});
}
}
try {
const lastValue = valueList[stopIndex-2];
avgList[stopIndex-2] = lastValue;
lowList[stopIndex-2] = lastValue;
highList[stopIndex-2] = lastValue;
} catch(e) {
console.log(e)
}
// Normalize the data if needed (not required in this case, but leaving it here for reference)
const { unit, denominator } = normalizer(Math.max(...valueList, ...avgList) ?? 0);
@ -204,7 +213,6 @@ function findIndex(data) {
let filteredData = analystEstimateList?.filter((item) => item.date >= 2015) ?? [];
xData = filteredData?.map(({ date }) => Number(String(date)?.slice(-2)));
if (displayData === "Revenue") {
filteredData?.forEach((item) => {
tableDataActual?.push({

View File

@ -66,7 +66,7 @@ if(data?.getAnalystEstimate?.length !== 0) {
</div>
<div class="inline-flex items-baseline rounded-full px-2.5 py-0.5 text-sm font-semibold md:mt-2 lg:mt-0 bg-green-100 text-green-800 dark:bg-green-700 dark:text-dark-100">
<svg class="-ml-1 mr-0.5 h-5 w-5 flex-shrink-0 self-center {changeRevenue > 0 ? 'text-green-500' : 'text-red-500 rotate-180'}" fill="none" viewBox="0 0 24 24" stroke="currentColor" style="max-width:40px" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 11l5-5m0 0l5 5m-5-5v12"></path></svg>
{abbreviateNumber(changeRevenue)}%
{abbreviateNumber(changeRevenue?.toFixed(1))}%
</div>
</div>
<div class="ml-0.5 mt-1.5 text-sm font-semibold text-white/60 lg:block">