From fbe4502a92ef2a545241dbb6cd1a404e001d40b4 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Wed, 5 Mar 2025 01:32:08 +0100 Subject: [PATCH] bugfixing chart --- src/routes/stocks/[tickerID]/+page.svelte | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/routes/stocks/[tickerID]/+page.svelte b/src/routes/stocks/[tickerID]/+page.svelte index ab704714..a5ffb289 100644 --- a/src/routes/stocks/[tickerID]/+page.svelte +++ b/src/routes/stocks/[tickerID]/+page.svelte @@ -65,21 +65,13 @@ item?.close, ]); - // Convert close values to numbers and filter out any non-numeric entries - const validPrices = rawData - ?.map((item) => Number(item?.close)) - ?.filter((price) => !isNaN(price)); - - // If there are no valid prices, set some default values (or handle this case appropriately) - if (validPrices.length === 0) { - return {}; // or set default yAxis values - } const padding = 0.015; - const minValue = Math.min(...validPrices); - const maxValue = Math.max(...validPrices); + const minValue = Math.min(...priceList); + const maxValue = Math.max(...priceList); const yMin = minValue * (1 - padding); const yMax = maxValue * (1 + padding); console.log(yMin, yMax); + console.log(priceData); const baseDate = rawData && rawData?.length ? new Date(rawData?.at(0)?.time) : new Date(); @@ -283,9 +275,6 @@ currentDataRowOneDay = oneDayPrice?.at(-1); switch (displayData) { - case "1D": - config = plotData(oneDayPrice) || null; - break; case "1W": currentDataRow = oneWeekPrice?.at(-1); graphBaseClose = oneWeekPrice?.at(0)?.close; @@ -395,6 +384,7 @@ displayLastLogicalRangeValue = null; lastValue = null; } + config = plotData(oneDayPrice) || null; break; case "1W": displayData = "1W";