From 6bca300fe583a6af9af55b70dba30a70fd4c820e Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Mon, 10 Mar 2025 20:53:09 +0100 Subject: [PATCH] ui fixes --- src/lib/components/FailToDeliver.svelte | 100 +++++++++--------- .../statistics/fail-to-deliver/+layout.svelte | 20 ++-- .../statistics/fail-to-deliver/+page.svelte | 32 +++--- .../statistics/price-reaction/+page.svelte | 10 +- 4 files changed, 79 insertions(+), 83 deletions(-) diff --git a/src/lib/components/FailToDeliver.svelte b/src/lib/components/FailToDeliver.svelte index 8e816972..ff9b4a2e 100644 --- a/src/lib/components/FailToDeliver.svelte +++ b/src/lib/components/FailToDeliver.svelte @@ -8,6 +8,7 @@ import { abbreviateNumber, removeCompanyStrings } from "$lib/utils"; import { goto } from "$app/navigation"; import highcharts from "$lib/highcharts.ts"; + import { mode } from "mode-watcher"; export let data; export let rawData = []; @@ -78,21 +79,21 @@ }, chart: { // Removed global type so each series can define its own type. - backgroundColor: "#09090B", - plotBackgroundColor: "#09090B", + backgroundColor: $mode === "light" ? "#fff" : "#09090B", + plotBackgroundColor: $mode === "light" ? "#fff" : "#09090B", height: 360, animation: false, }, title: { text: `

${removeCompanyStrings($displayCompanyName)} FTD

`, style: { - color: "white", + color: $mode === "light" ? "black" : "white", }, useHTML: true, }, plotOptions: { series: { - color: "white", + color: $mode === "light" ? "black" : "white", animation: false, // Disable series animation states: { hover: { @@ -118,7 +119,7 @@ borderRadius: 4, formatter: function () { // Format the x value to display time in hh:mm format - let tooltipContent = `${new Date( + let tooltipContent = `${new Date( this?.x, ).toLocaleDateString("en-US", { year: "numeric", @@ -128,8 +129,8 @@ // Loop through each point in the shared tooltip this.points.forEach((point) => { - tooltipContent += `${point.series.name}: - ${abbreviateNumber( + tooltipContent += `${point.series.name}: + ${abbreviateNumber( point.y, )}
`; }); @@ -141,15 +142,13 @@ endOnTick: false, categories: dates, crosshair: { - color: "#fff", // Set the color of the crosshair line + color: $mode === "light" ? "black" : "white", // Set the color of the crosshair line width: 1, // Adjust the line width as needed dashStyle: "Solid", }, labels: { - style: { - color: "#fff", - }, + style: { color: $mode === "light" ? "black" : "white" }, distance: 20, // Increases space between label and axis formatter: function () { return new Date(this.value).toLocaleDateString("en-US", { @@ -163,7 +162,7 @@ yAxis: [ { gridLineWidth: 1, - gridLineColor: "#111827", + gridLineColor: $mode === "light" ? "#d1d5dc" : "#111827", labels: { enabled: false, }, @@ -174,7 +173,7 @@ }, { gridLineWidth: 1, - gridLineColor: "#111827", + gridLineColor: $mode === "light" ? "#d1d5dc" : "#111827", labels: { enabled: false, }, @@ -207,7 +206,7 @@ name: "Price", type: "line", data: priceList, - color: "#fff", + color: $mode === "light" ? "#2C6288" : "#fff", marker: { enabled: false, states: { @@ -225,29 +224,31 @@ } $: { - const ticker = $assetType === "stock" ? $stockTicker : $etfTicker; - if (ticker) { - if (rawData?.length > 0) { - weightedFTD = ( - (rawData?.slice(-1)?.at(0)?.failToDeliver / - data?.getStockQuote?.avgVolume) * - 100 - )?.toFixed(2); - config = getPlotOptions(); + if ($stockTicker || $etfTicker || $mode) { + const ticker = $assetType === "stock" ? $stockTicker : $etfTicker; + if (ticker) { + if (rawData?.length > 0) { + weightedFTD = ( + (rawData?.slice(-1)?.at(0)?.failToDeliver / + data?.getStockQuote?.avgVolume) * + 100 + )?.toFixed(2); + config = getPlotOptions(); + } } } } -
+
-

FTD Chart

+

FTD Chart

{#if rawData?.length !== 0}
-
+
Over the past year, {$displayCompanyName} has seen a monthly average of {avgFailToDeliver?.toLocaleString("en-US")} @@ -256,22 +257,20 @@
-

- FTD History -

+

FTD History

{#each tabs as item, i} {#if !["Pro", "Plus"]?.includes(data?.user?.tier) && i > 0} @@ -286,7 +285,7 @@ xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > @@ -307,7 +306,7 @@ class="relative text-sm block font-semibold whitespace-nowrap {activeIdx === i ? 'text-black' - : 'text-white'}" + : ''}" > {item.title} @@ -320,24 +319,23 @@
- + - - - - + + + + {#each tableList as item, index} - - + -
DatePriceFTD Shares% ChangeDatePriceFTD Shares% Change
+
{new Date(item?.date)?.toLocaleDateString("en-US", { day: "2-digit", // Include day number month: "short", // Display short month name @@ -346,24 +344,22 @@ {item?.price} {abbreviateNumber(item?.failToDeliver)} + {#if index === tableList?.length - 1} n/a {:else if item?.failToDeliver > tableList[index + 1]?.failToDeliver} - + +{( ((item?.failToDeliver - tableList[index + 1]?.failToDeliver) / @@ -372,7 +368,7 @@ )?.toFixed(2)}% {:else if item?.failToDeliver < tableList[index + 1]?.failToDeliver} - + -{( Math.abs( (item?.failToDeliver - diff --git a/src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+layout.svelte b/src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+layout.svelte index 46a01199..588b5fb3 100644 --- a/src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+layout.svelte +++ b/src/routes/stocks/[tickerID]/statistics/fail-to-deliver/+layout.svelte @@ -21,18 +21,18 @@