From 92e7304989738379d0d521da5a3d308e0f015735 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sun, 25 Aug 2024 17:12:43 +0200 Subject: [PATCH] bugfixing --- src/lib/components/Swap.svelte | 32 ++++++++----------- src/routes/earnings-calendar/+page.svelte | 2 +- .../etf/[tickerID]/dividends/+page.svelte | 23 +++++++------ .../stocks/[tickerID]/dividends/+page.svelte | 19 ++++++----- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/lib/components/Swap.svelte b/src/lib/components/Swap.svelte index 396b35d7..4bb07f8e 100644 --- a/src/lib/components/Swap.svelte +++ b/src/lib/components/Swap.svelte @@ -59,27 +59,21 @@ function getPlotOptions(state) { + // Combine the data into an array of objects to keep them linked + const combinedData = rawData?.map(item => ({ + date: state === 'effectiveDate' ? item['Effective Date'] : item['Expiration Date'], + notionalAmount: item['Notional amount-Leg 1'], + notionalQuantity: item['Total notional quantity-Leg 1'] + })); - let dates = []; - let notionalAmount = []; - let notionalQuantity = []; + // Sort the combined data array based on the date + combinedData?.sort((a, b) => new Date(a.date) - new Date(b.date)); + + // Separate the sorted data back into individual arrays + const dates = combinedData?.map(item => item?.date); + const notionalAmount = combinedData?.map(item => item?.notionalAmount); + const notionalQuantity = combinedData?.map(item => item?.notionalQuantity); - // Iterate over the data and extract required information - rawData?.forEach(item => { - - if ( state === 'effectiveDate') { - dates?.push(item['Effective Date']); - } - else { - dates?.push(item['Expiration Date']); - } - notionalAmount?.push(item['Notional amount-Leg 1']); - notionalQuantity?.push(item['Total notional quantity-Leg 1']); - }); - - dates?.sort((a, b) => { - return new Date(a) - new Date(b); - }); // Compute the average of item?.traded const totalNotionalAmount = notionalAmount?.reduce((acc, item) => acc + item, 0); diff --git a/src/routes/earnings-calendar/+page.svelte b/src/routes/earnings-calendar/+page.svelte index 3a528e06..57bcca17 100644 --- a/src/routes/earnings-calendar/+page.svelte +++ b/src/routes/earnings-calendar/+page.svelte @@ -335,7 +335,7 @@ $: { {#each weekday as day,index}
-