update forecast overview page
This commit is contained in:
parent
04e4c12560
commit
2e6f640b0e
@ -50,36 +50,6 @@ function findIndex(data) {
|
||||
let tableDataActual = [];
|
||||
let tableDataForecast = [];
|
||||
|
||||
const getAnalystEstimate = async (ticker) => {
|
||||
// Get cached data for the specific tickerID
|
||||
const cachedData = getCache(ticker, "getAnalystEstimate");
|
||||
if (cachedData) {
|
||||
analystEstimateList = cachedData;
|
||||
} else {
|
||||
const postData = { ticker: ticker };
|
||||
|
||||
const response = await fetch(data?.apiURL + "/analyst-estimate", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
analystEstimateList = await response?.json();
|
||||
analystEstimateList = analystEstimateList?.filter((item) => !item.date.toString().startsWith("19"));
|
||||
|
||||
// Cache the data for this specific tickerID with a specific name 'getAnalystEstimate'
|
||||
setCache(ticker, analystEstimateList, "getAnalystEstimate");
|
||||
}
|
||||
|
||||
if (analystEstimateList?.length !== 0) {
|
||||
$analystEstimateComponent = true;
|
||||
} else {
|
||||
$analystEstimateComponent = false;
|
||||
}
|
||||
};
|
||||
|
||||
function getPlotOptions() {
|
||||
let dates = [];
|
||||
@ -289,17 +259,15 @@ function findIndex(data) {
|
||||
$: {
|
||||
if ($stockTicker && displayData && typeof window !== "undefined") {
|
||||
isLoaded = false;
|
||||
|
||||
const asyncFunctions = [getAnalystEstimate($stockTicker)];
|
||||
Promise.all(asyncFunctions)
|
||||
.then((results) => {
|
||||
//prepareData(analystEstimateList)
|
||||
analystEstimateList = [];
|
||||
analystEstimateList = data?.getAnalystEstimate || [];
|
||||
if (analystEstimateList?.length !== 0) {
|
||||
$analystEstimateComponent = true;
|
||||
optionsData = getPlotOptions();
|
||||
prepareData();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("An error occurred:", error);
|
||||
});
|
||||
} else {
|
||||
$analystEstimateComponent = false;
|
||||
}
|
||||
isLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { numberOfUnreadNotification, displayCompanyName, stockTicker, analystEstimateComponent } from "$lib/store";
|
||||
import { abbreviateNumber } from "$lib/utils";
|
||||
import InfoModal from "$lib/components/InfoModal.svelte";
|
||||
|
||||
import { Chart } from "svelte-echarts";
|
||||
import { init, use } from "echarts/core";
|
||||
import { LineChart } from "echarts/charts";
|
||||
import { GridComponent, TooltipComponent } from "echarts/components";
|
||||
import { CanvasRenderer } from "echarts/renderers";
|
||||
|
||||
export let data;
|
||||
use([LineChart, GridComponent, TooltipComponent, CanvasRenderer]);
|
||||
|
||||
|
||||
function findIndex(data) {
|
||||
const currentYear = new Date().getFullYear();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user