From d3a6d608f528275751bd9b03741fbc920e621aca Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 6 Jan 2025 23:16:16 +0100 Subject: [PATCH] update analyst estimate graph --- src/lib/components/AnalystEstimate.svelte | 43 +++++++++++++++++++++-- src/lib/components/EstimationGraph.svelte | 2 +- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/lib/components/AnalystEstimate.svelte b/src/lib/components/AnalystEstimate.svelte index f2255797..76b01ff8 100644 --- a/src/lib/components/AnalystEstimate.svelte +++ b/src/lib/components/AnalystEstimate.svelte @@ -213,7 +213,7 @@ // Normalize the data if needed (not required in this case, but leaving it here for reference) - let currentYearSuffix = new Date().getFullYear().toString().slice(-2); + let currentYearSuffix = new Date().getFullYear()?.toString().slice(-2); let searchString = `FY${currentYearSuffix}`; let currentYearIndex = dates?.findIndex((date) => date === searchString); @@ -287,7 +287,6 @@ val: val, })) || []; } - const growthList = dates?.map((date) => { const fy = parseInt(date.replace("FY", ""), 10); // Extract numeric FY value const listToUse = @@ -301,7 +300,6 @@ 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: { @@ -324,6 +322,38 @@ color: "#fff", }, }, + tooltip: { + trigger: "axis", + hideDelay: 100, + borderColor: "#969696", // Black border color + borderWidth: 1, // Border width of 1px + backgroundColor: "#313131", // Optional: Set background color for contrast + textStyle: { + color: "#fff", // Optional: Text color for better visibility + }, + formatter: function (params) { + // Get the timestamp from the first parameter + const timestamp = params[0].axisValue; + + // Sort the params array to arrange High, Avg, Low + const sortedParams = params.sort((a, b) => { + const order = { High: 0, Avg: 1, Low: 2 }; + return order[a.seriesName] - order[b.seriesName]; + }); + + // Initialize result with timestamp + let result = timestamp + "
"; + + // Loop through each sorted series data + sortedParams.forEach((param) => { + result += + param.seriesName + ": " + abbreviateNumber(param.value) + "
"; + }); + + return result; + }, + }, + yAxis: [ { type: "value", @@ -543,6 +573,13 @@ ], tooltip: { trigger: "axis", + hideDelay: 100, + borderColor: "#969696", // Black border color + borderWidth: 1, // Border width of 1px + backgroundColor: "#313131", // Optional: Set background color for contrast + textStyle: { + color: "#fff", // Optional: Text color for better visibility + }, formatter: (params) => { const dataIndex = params[0].dataIndex; const mainValue = params[0].value; diff --git a/src/lib/components/EstimationGraph.svelte b/src/lib/components/EstimationGraph.svelte index e1966316..897f8895 100644 --- a/src/lib/components/EstimationGraph.svelte +++ b/src/lib/components/EstimationGraph.svelte @@ -185,7 +185,7 @@ {/each} Avg - {#each avgGrowthList?.filter((item) => item.FY >= 24) as item, index} + {#each avgGrowthList?.filter((item) => item.FY >= 25) as item, index} {#if index !== 0} {#if userTier !== "Pro" && index >= avgDataList?.length - 2}