ui fixes
This commit is contained in:
parent
88eb12e514
commit
1982c18cb6
@ -487,6 +487,19 @@ export function pageTransitionOut(node, { duration }) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function convertTimestamp(timestamp) {
|
||||||
|
const date = new Date(timestamp * 1000); // Convert seconds to milliseconds
|
||||||
|
|
||||||
|
return date.toLocaleString("en-US", {
|
||||||
|
year: "numeric", // e.g., "2024"
|
||||||
|
month: "short", // e.g., "Aug"
|
||||||
|
day: "2-digit", // e.g., "23"
|
||||||
|
hour: "numeric", // e.g., "3"
|
||||||
|
minute: "2-digit", // e.g., "59"
|
||||||
|
hour12: true, // e.g., "PM"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
function convertNYTimeToLocalTime(nyTimeString) {
|
function convertNYTimeToLocalTime(nyTimeString) {
|
||||||
// New York Time Zone
|
// New York Time Zone
|
||||||
|
|||||||
@ -469,7 +469,6 @@ $: {
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:options immutable={true} />
|
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
corporateLobbyingComponent,
|
corporateLobbyingComponent,
|
||||||
taRatingComponent,
|
taRatingComponent,
|
||||||
swapComponent,
|
swapComponent,
|
||||||
analystInsightComponent,
|
|
||||||
governmentContractComponent,
|
governmentContractComponent,
|
||||||
optionsNetFlowComponent,
|
optionsNetFlowComponent,
|
||||||
borrowedShareComponent,
|
borrowedShareComponent,
|
||||||
@ -16,8 +15,6 @@
|
|||||||
optionComponent,
|
optionComponent,
|
||||||
failToDeliverComponent,
|
failToDeliverComponent,
|
||||||
marketMakerComponent,
|
marketMakerComponent,
|
||||||
analystEstimateComponent,
|
|
||||||
sentimentComponent,
|
|
||||||
screenWidth,
|
screenWidth,
|
||||||
displayCompanyName,
|
displayCompanyName,
|
||||||
numberOfUnreadNotification,
|
numberOfUnreadNotification,
|
||||||
@ -28,10 +25,6 @@
|
|||||||
darkPoolComponent,
|
darkPoolComponent,
|
||||||
retailVolumeComponent,
|
retailVolumeComponent,
|
||||||
shareholderComponent,
|
shareholderComponent,
|
||||||
trendAnalysisComponent,
|
|
||||||
revenueSegmentationComponent,
|
|
||||||
priceAnalysisComponent,
|
|
||||||
fundamentalAnalysisComponent,
|
|
||||||
isCrosshairMoveActive,
|
isCrosshairMoveActive,
|
||||||
realtimePrice,
|
realtimePrice,
|
||||||
priceIncrease,
|
priceIncrease,
|
||||||
@ -46,6 +39,7 @@
|
|||||||
import NextEarnings from "$lib/components/NextEarnings.svelte";
|
import NextEarnings from "$lib/components/NextEarnings.svelte";
|
||||||
import CommunitySentiment from "$lib/components/CommunitySentiment.svelte";
|
import CommunitySentiment from "$lib/components/CommunitySentiment.svelte";
|
||||||
import Lazy from "$lib/components/Lazy.svelte";
|
import Lazy from "$lib/components/Lazy.svelte";
|
||||||
|
import { convertTimestamp } from '$lib/utils';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let form;
|
export let form;
|
||||||
@ -83,7 +77,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (displayData === "6M") {
|
} else if (displayData === "6M") {
|
||||||
currentDataRow = sixMonthPrice?.slice(-1)[0];
|
currentDataRow = sixMonthPrice?.slice(-1)?.at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//currentDataRow = oneWeekPrice.slice(-1)[0]
|
//currentDataRow = oneWeekPrice.slice(-1)[0]
|
||||||
@ -100,9 +94,19 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
//const formattedDate = (displayData === '1D' || displayData === '1W' || displayData === '1M') ? date.toLocaleString('en-GB', options).replace(/\//g, '.') : date.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' }).replace(/\//g, '.');
|
//const formattedDate = (displayData === '1D' || displayData === '1W' || displayData === '1M') ? date.toLocaleString('en-GB', options).replace(/\//g, '.') : date.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' }).replace(/\//g, '.');
|
||||||
const formattedDate = displayData === "1D" || displayData === "1W" || displayData === "1M" ? date.toLocaleString("en-US", options) : date.toLocaleDateString("en-US", { day: "2-digit", month: "short", year: "numeric" });
|
const formattedDate = displayData === "1D" || displayData === "1W" || displayData === "1M"
|
||||||
|
? date.toLocaleString("en-US", options)
|
||||||
|
: date.toLocaleDateString("en-US", { day: "2-digit", month: "short", year: "numeric" });
|
||||||
|
|
||||||
|
const safeFormattedDate = formattedDate === "Invalid Date" ? convertTimestamp(data?.getStockQuote?.timestamp) : formattedDate;
|
||||||
|
displayLegend = {
|
||||||
|
close: currentDataRow?.value === '-' && currentDataRow?.close === undefined
|
||||||
|
? data?.getStockQuote?.price
|
||||||
|
: (currentDataRow?.close ?? currentDataRow?.value),
|
||||||
|
date: safeFormattedDate,
|
||||||
|
change: change
|
||||||
|
};
|
||||||
|
|
||||||
displayLegend = { close: currentDataRow?.close ?? currentDataRow?.value, date: formattedDate, change: change };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,6 +537,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: dataMapping = {
|
||||||
|
"1D": oneDayPrice,
|
||||||
|
"1W": oneWeekPrice,
|
||||||
|
"1M": oneMonthPrice,
|
||||||
|
"6M": sixMonthPrice,
|
||||||
|
"1Y": oneYearPrice,
|
||||||
|
"MAX": threeYearPrice,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if ($stockTicker && typeof window !== "undefined") {
|
if ($stockTicker && typeof window !== "undefined") {
|
||||||
// add a check to see if running on client-side
|
// add a check to see if running on client-side
|
||||||
@ -720,18 +734,13 @@
|
|||||||
|
|
||||||
{#if output !== null}
|
{#if output !== null}
|
||||||
<div class="w-full sm:pl-7 ml-auto max-w-5xl mb-10">
|
<div class="w-full sm:pl-7 ml-auto max-w-5xl mb-10">
|
||||||
{#if displayData === "1D" && oneDayPrice?.length === 0}
|
{#if dataMapping[displayData]?.length === 0}
|
||||||
<h2 class=" mt-20 flex h-[240px] justify-center items-center text-3xl font-bold text-slate-700 mb-20 m-auto">No data available</h2>
|
<div class="mt-20 flex h-[240px] justify-center items-center mb-20 m-auto">
|
||||||
{:else if displayData === "1W" && oneWeekPrice?.length === 0}
|
<div class="text-white p-5 mt-5 w-fit m-auto rounded-lg sm:flex sm:flex-row sm:items-center border border-slate-800 text-[1rem]">
|
||||||
<h2 class=" mt-20 flex h-[240px] justify-center items-center text-3xl font-bold text-slate-700 mb-20 m-auto">No data available</h2>
|
<svg class="w-6 h-6 flex-shrink-0 inline-block sm:mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><path fill="#a474f6" d="M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24m-4 48a12 12 0 1 1-12 12a12 12 0 0 1 12-12m12 112a16 16 0 0 1-16-16v-40a8 8 0 0 1 0-16a16 16 0 0 1 16 16v40a8 8 0 0 1 0 16"/></svg>
|
||||||
{:else if displayData === "1M" && oneMonthPrice?.length === 0}
|
No {displayData} chart data available
|
||||||
<h2 class=" mt-20 flex h-[240px] justify-center items-center text-3xl font-bold text-slate-700 mb-20 m-auto">No data available</h2>
|
</div>
|
||||||
{:else if displayData === "6M" && sixMonthPrice?.length === 0}
|
</div>
|
||||||
<h2 class=" mt-20 flex h-[240px] justify-center items-center text-3xl font-bold text-slate-700 mb-20 m-auto">No data available</h2>
|
|
||||||
{:else if displayData === "1Y" && oneYearPrice?.length === 0}
|
|
||||||
<h2 class=" mt-20 flex h-[240px] justify-center items-center text-3xl font-bold text-slate-700 mb-20 m-auto">No data available</h2>
|
|
||||||
{:else if displayData === "MAX" && threeYearPrice?.length === 0}
|
|
||||||
<h2 class=" mt-20 flex h-[240px] justify-center items-center text-3xl font-bold text-slate-700 mb-20 m-auto">No data available</h2>
|
|
||||||
{:else}
|
{:else}
|
||||||
<Chart {...options} autoSize={true} ref={(ref) => (chart = ref)} on:crosshairMove={handleCrosshairMove}>
|
<Chart {...options} autoSize={true} ref={(ref) => (chart = ref)} on:crosshairMove={handleCrosshairMove}>
|
||||||
{#if displayData === "1D"}
|
{#if displayData === "1D"}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user