diff --git a/src/lib/components/HoverStockChart.svelte b/src/lib/components/HoverStockChart.svelte index 35cac216..38ee42d7 100644 --- a/src/lib/components/HoverStockChart.svelte +++ b/src/lib/components/HoverStockChart.svelte @@ -6,7 +6,7 @@ import { Chart, BaselineSeries, PriceLine } from "svelte-lightweight-charts"; import { screenWidth } from "$lib/store"; import { abbreviateNumber } from "$lib/utils"; - + import { afterUpdate } from "svelte"; export let stockChartData; export let symbol; @@ -108,10 +108,18 @@ }, }; - if ($screenWidth && chart && typeof window !== "undefined") { - console.log("yes"); - chart?.timeScale()?.fitContent(); - } + afterUpdate(async () => { + if ( + $screenWidth && + stockChartData && + chart && + typeof window !== "undefined" + ) { + console.log("yes"); + + chart?.timeScale()?.fitContent(); + } + });