update forecast overview page
This commit is contained in:
parent
defd8a9283
commit
6c44831338
@ -4,13 +4,13 @@
|
|||||||
|
|
||||||
import { Chart } from "svelte-echarts";
|
import { Chart } from "svelte-echarts";
|
||||||
import { init, use } from "echarts/core";
|
import { init, use } from "echarts/core";
|
||||||
import { ScatterChart } from "echarts/charts";
|
import { LineChart } from "echarts/charts";
|
||||||
import { GridComponent, TooltipComponent } from "echarts/components";
|
import { GridComponent, TooltipComponent } from "echarts/components";
|
||||||
import { CanvasRenderer } from "echarts/renderers";
|
import { CanvasRenderer } from "echarts/renderers";
|
||||||
import { abbreviateNumber } from "$lib/utils";
|
import { abbreviateNumber } from "$lib/utils";
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
use([ScatterChart, GridComponent, TooltipComponent, CanvasRenderer]);
|
use([LineChart, GridComponent, TooltipComponent, CanvasRenderer]);
|
||||||
|
|
||||||
let analystEstimateList = [];
|
let analystEstimateList = [];
|
||||||
let isLoaded = false;
|
let isLoaded = false;
|
||||||
@ -20,7 +20,12 @@
|
|||||||
let xData = [];
|
let xData = [];
|
||||||
let optionsData;
|
let optionsData;
|
||||||
|
|
||||||
let displayData = "Revenue";
|
let displayData = "Revenue";
|
||||||
|
|
||||||
|
function findIndex(data) {
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
return data.findIndex(item => item.date >= currentYear && item.revenue === null);
|
||||||
|
}
|
||||||
|
|
||||||
function changeStatement(event) {
|
function changeStatement(event) {
|
||||||
displayData = event.target.value;
|
displayData = event.target.value;
|
||||||
@ -79,39 +84,57 @@
|
|||||||
function getPlotOptions() {
|
function getPlotOptions() {
|
||||||
let dates = [];
|
let dates = [];
|
||||||
let valueList = [];
|
let valueList = [];
|
||||||
let estimatedValueList = [];
|
let avgList = [];
|
||||||
|
let lowList = [];
|
||||||
|
let highList = [];
|
||||||
|
|
||||||
let filteredData = analystEstimateList?.filter((item) => item.date >= 2015) ?? [];
|
|
||||||
|
|
||||||
// Iterate over the data and extract required information
|
let filteredData = analystEstimateList?.filter((item) => item.date >= 2019) ?? [];
|
||||||
if (displayData === "Revenue") {
|
const stopIndex = findIndex(filteredData);
|
||||||
filteredData?.slice(-20)?.forEach((item) => {
|
|
||||||
dates.push(`FY${item?.date?.toString()?.slice(-2)}`);
|
if (filteredData) {
|
||||||
valueList.push(item?.revenue); // Handle null values by using 0 or any placeholder value
|
filteredData.forEach((item, index) => {
|
||||||
estimatedValueList.push(item?.estimatedRevenueAvg);
|
const date = item.date?.toString().slice(-2);
|
||||||
});
|
const isBeforeStopIndex = index < stopIndex - 1;
|
||||||
} else if (displayData === "Net Income") {
|
const isAfterStartIndex = index >= stopIndex - 2;
|
||||||
filteredData?.slice(-20)?.forEach((item) => {
|
dates.push(`FY${date}`);
|
||||||
dates.push(`FY${item?.date?.toString()?.slice(-2)}`);
|
|
||||||
valueList.push(item?.netIncome); // Handle null values by using 0 or any placeholder value
|
switch (displayData) {
|
||||||
estimatedValueList.push(item?.estimatedNetIncomeAvg);
|
case "Revenue":
|
||||||
});
|
valueList.push(isBeforeStopIndex ? item.revenue : null);
|
||||||
} else if (displayData === "EBITDA") {
|
avgList.push(isAfterStartIndex ? item.estimatedRevenueAvg : null);
|
||||||
filteredData?.slice(-20)?.forEach((item) => {
|
lowList.push(isAfterStartIndex ? item.estimatedRevenueLow : null);
|
||||||
dates.push(`FY${item?.date?.toString()?.slice(-2)}`);
|
highList.push(isAfterStartIndex ? item.estimatedRevenueHigh : null);
|
||||||
valueList.push(item?.ebitda); // Handle null values by using 0 or any placeholder value
|
break;
|
||||||
estimatedValueList.push(item?.estimatedEbitdaAvg);
|
|
||||||
});
|
case "Net Income":
|
||||||
} else if (displayData === "EPS") {
|
valueList.push(isBeforeStopIndex ? item.netIncome : null);
|
||||||
filteredData?.slice(-20)?.forEach((item) => {
|
avgList.push(isAfterStartIndex ? item.estimatedNetIncomeAvg : null);
|
||||||
dates.push(`FY${item?.date?.toString()?.slice(-2)}`);
|
lowList.push(isAfterStartIndex ? item.estimatedNetIncomeLow : null);
|
||||||
valueList.push(item?.eps); // Handle null values by using 0 or any placeholder value
|
highList.push(isAfterStartIndex ? item.estimatedNetIncomeHigh : null);
|
||||||
estimatedValueList.push(item?.estimatedEpsAvg);
|
break;
|
||||||
});
|
case "EBITDA":
|
||||||
}
|
valueList.push(isBeforeStopIndex ? item.ebitda : null);
|
||||||
|
avgList.push(isAfterStartIndex ? item.estimatedEbitdaAvg : null);
|
||||||
|
lowList.push(isAfterStartIndex ? item.estimatedEbitdaLow : null);
|
||||||
|
highList.push(isAfterStartIndex ? item.estimatedEbitdaHigh : null);
|
||||||
|
break;
|
||||||
|
case "EPS":
|
||||||
|
valueList.push(isBeforeStopIndex ? item.eps : null);
|
||||||
|
avgList.push(isAfterStartIndex ? item.estimatedEpsAvg : null);
|
||||||
|
lowList.push(isAfterStartIndex ? item.estimatedEpsLow : null);
|
||||||
|
highList.push(isAfterStartIndex ? item.estimatedEpsHigh : null);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Normalize the data if needed (not required in this case, but leaving it here for reference)
|
// Normalize the data if needed (not required in this case, but leaving it here for reference)
|
||||||
const { unit, denominator } = normalizer(Math.max(...valueList, ...estimatedValueList) ?? 0);
|
const { unit, denominator } = normalizer(Math.max(...valueList, ...avgList) ?? 0);
|
||||||
|
|
||||||
const option = {
|
const option = {
|
||||||
silent: true,
|
silent: true,
|
||||||
@ -156,20 +179,47 @@
|
|||||||
{
|
{
|
||||||
name: "Actual",
|
name: "Actual",
|
||||||
data: valueList,
|
data: valueList,
|
||||||
type: "scatter",
|
type: "line",
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
color: "#fff", // Change scatter plot color to white
|
color: "#fff", // Change line plot color to white
|
||||||
},
|
},
|
||||||
showSymbol: true, // Show symbols for scatter plot points
|
showSymbol: false, // Show symbols for line plot points
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Forecast",
|
name: "Avg",
|
||||||
data: estimatedValueList,
|
data: avgList,
|
||||||
type: "scatter",
|
type: "line",
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
color: "#E11D48", // Change scatter plot color to green
|
color: "#fff", // Change line plot color to green
|
||||||
},
|
},
|
||||||
showSymbol: true, // Show symbols for scatter plot points
|
lineStyle: {
|
||||||
|
type: "dashed" // Set the line type to dashed
|
||||||
|
},
|
||||||
|
showSymbol: false, // Show symbols for line plot points
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Low",
|
||||||
|
data: lowList,
|
||||||
|
type: "line",
|
||||||
|
itemStyle: {
|
||||||
|
color: "#3CB2EF", // Change line plot color to green
|
||||||
|
},
|
||||||
|
lineStyle: {
|
||||||
|
type: "dashed" // Set the line type to dashed
|
||||||
|
},
|
||||||
|
showSymbol: false, // Show symbols for line plot points
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "High",
|
||||||
|
data: highList,
|
||||||
|
type: "line",
|
||||||
|
itemStyle: {
|
||||||
|
color: "#3CB2EF", // Change line plot color to green
|
||||||
|
},
|
||||||
|
lineStyle: {
|
||||||
|
type: "dashed" // Set the line type to dashed
|
||||||
|
},
|
||||||
|
showSymbol: false, // Show symbols for line plot points
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@ -260,7 +310,9 @@
|
|||||||
<main class="overflow-hidden">
|
<main class="overflow-hidden">
|
||||||
<div class="w-full m-auto mt-5 sm:mt-0">
|
<div class="w-full m-auto mt-5 sm:mt-0">
|
||||||
<div class="flex flex-row items-center">
|
<div class="flex flex-row items-center">
|
||||||
<label for="predictiveFundamentalsInfo" class="mr-1 cursor-pointer flex flex-row items-center text-white text-xl sm:text-3xl font-bold"> Predictive Fundamentals </label>
|
<label for="predictiveFundamentalsInfo" class="mr-1 cursor-pointer flex flex-row items-center text-white text-xl sm:text-3xl font-bold">
|
||||||
|
Revenue Forecast
|
||||||
|
</label>
|
||||||
<InfoModal
|
<InfoModal
|
||||||
title={"Predictive Fundamentals"}
|
title={"Predictive Fundamentals"}
|
||||||
content={`If quarterly earnings for a year are incomplete, we offer a summarized view based on available data. For instance, if the Q4 report is missing, we display revenue as X, reflecting the sum of Q1-Q3 only. Q4 data will be added later when available.`}
|
content={`If quarterly earnings for a year are incomplete, we offer a summarized view based on available data. For instance, if the Q4 report is missing, we display revenue as X, reflecting the sum of Q1-Q3 only. Q4 data will be added later when available.`}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user