From 0ed2a9249761627e6b78bfca0dd001c018f214eb Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sat, 27 Jul 2024 09:22:13 +0200 Subject: [PATCH] lazy loading stock splits --- src/routes/stocks/[tickerID]/+page.svelte | 465 +++++++++++----------- 1 file changed, 224 insertions(+), 241 deletions(-) diff --git a/src/routes/stocks/[tickerID]/+page.svelte b/src/routes/stocks/[tickerID]/+page.svelte index 2b2a8b38..fa185d19 100644 --- a/src/routes/stocks/[tickerID]/+page.svelte +++ b/src/routes/stocks/[tickerID]/+page.svelte @@ -45,13 +45,7 @@ onMount(async() => { - - if (chart) { - chart.timeScale().fitContent(); - } WIIM = (await import('$lib/components/WIIM.svelte')).default; - StockSplits = (await import('$lib/components/StockSplits.svelte')).default; - }) @@ -61,7 +55,6 @@ - //==========================// $: { @@ -902,228 +895,226 @@ function changeChartType() { No data available {:else} + + chart = ref} on:crosshairMove={handleCrosshairMove} > -
- chart = ref} on:crosshairMove={handleCrosshairMove} > - - {#if displayData === '1D'} - {#if displayChartType === 'line'} - ({ time, value: close }))} - lineWidth={1.5} - priceScaleId="left" - lineColor={colorChange} - topColor={topColorChange} - bottomColor={bottomColorChange} + {#if displayData === '1D'} + {#if displayChartType === 'line'} + ({ time, value: close }))} + lineWidth={1.5} + priceScaleId="left" + lineColor={colorChange} + topColor={topColorChange} + bottomColor={bottomColorChange} + crosshairMarkerVisible={false} + ref={handleSeriesReference} + priceLineVisible= {false} + lastPriceAnimation={1} + > + + + {:else} + - - - {:else} - - - - {/if} - {:else if displayData === '1W'} - {#if displayChartType === 'line'} - ({ time, value: close }))} - lineWidth={1.5} - priceScaleId="left" - lineColor={colorChange} - topColor={topColorChange} - bottomColor={bottomColorChange} - crosshairMarkerVisible={false} - ref={handleSeriesReference} - priceLineVisible= {false} - lastPriceAnimation={1} - > - - - {:else} - - - - {/if} - - {:else if displayData === '1M'} - {#if displayChartType === 'line'} - ({ time, value: close }))} - lineWidth={1.5} - priceScaleId="left" - lineColor={colorChange} - topColor={topColorChange} - bottomColor={bottomColorChange} - crosshairMarkerVisible={false} - ref={handleSeriesReference} - priceLineVisible= {false} - lastPriceAnimation={1} - > - - - {:else} - - - - {/if} - - - {:else if displayData === '6M'} - {#if displayChartType === 'line'} - ({ time, value: close }))} - lineWidth={1.5} - priceScaleId="left" - lineColor={colorChange} - topColor={topColorChange} - bottomColor={bottomColorChange} - crosshairMarkerVisible={false} - ref={handleSeriesReference} - priceLineVisible= {false} - lastPriceAnimation={1} - > - - - {:else} - - - - {/if} - - - - {:else if displayData === '1Y'} - {#if displayChartType === 'line'} - ({ time, value: close }))} - lineWidth={1.5} - priceScaleId="left" - lineColor={colorChange} - topColor={topColorChange} - bottomColor={bottomColorChange} - crosshairMarkerVisible={false} - ref={handleSeriesReference} - priceLineVisible= {false} - lastPriceAnimation={1} - > - - - {:else} - - - - {/if} - - - - {:else if displayData === 'MAX'} - {#if displayChartType === 'line'} - ({ time, value: close }))} - lineWidth={1.5} - priceScaleId="left" - lineColor={colorChange} - topColor={topColorChange} - bottomColor={bottomColorChange} - crosshairMarkerVisible={false} - ref={handleSeriesReference} - priceLineVisible= {false} - lastPriceAnimation={1} - > - - - {:else} - - - - {/if} - - + + {/if} - -
+ {:else if displayData === '1W'} + {#if displayChartType === 'line'} + ({ time, value: close }))} + lineWidth={1.5} + priceScaleId="left" + lineColor={colorChange} + topColor={topColorChange} + bottomColor={bottomColorChange} + crosshairMarkerVisible={false} + ref={handleSeriesReference} + priceLineVisible= {false} + lastPriceAnimation={1} + > + + + {:else} + + + + {/if} + + {:else if displayData === '1M'} + {#if displayChartType === 'line'} + ({ time, value: close }))} + lineWidth={1.5} + priceScaleId="left" + lineColor={colorChange} + topColor={topColorChange} + bottomColor={bottomColorChange} + crosshairMarkerVisible={false} + ref={handleSeriesReference} + priceLineVisible= {false} + lastPriceAnimation={1} + > + + + {:else} + + + + {/if} + + + {:else if displayData === '6M'} + {#if displayChartType === 'line'} + ({ time, value: close }))} + lineWidth={1.5} + priceScaleId="left" + lineColor={colorChange} + topColor={topColorChange} + bottomColor={bottomColorChange} + crosshairMarkerVisible={false} + ref={handleSeriesReference} + priceLineVisible= {false} + lastPriceAnimation={1} + > + + + {:else} + + + + {/if} + + + + {:else if displayData === '1Y'} + {#if displayChartType === 'line'} + ({ time, value: close }))} + lineWidth={1.5} + priceScaleId="left" + lineColor={colorChange} + topColor={topColorChange} + bottomColor={bottomColorChange} + crosshairMarkerVisible={false} + ref={handleSeriesReference} + priceLineVisible= {false} + lastPriceAnimation={1} + > + + + {:else} + + + + {/if} + + + + {:else if displayData === 'MAX'} + {#if displayChartType === 'line'} + ({ time, value: close }))} + lineWidth={1.5} + priceScaleId="left" + lineColor={colorChange} + topColor={topColorChange} + bottomColor={bottomColorChange} + crosshairMarkerVisible={false} + ref={handleSeriesReference} + priceLineVisible= {false} + lastPriceAnimation={1} + > + + + {:else} + + + + {/if} + + + {/if} +
{/if} @@ -1432,14 +1423,14 @@ function changeChartType() { - - + + - - {#if StockSplits && stockDeck?.at(0)?.stockSplits?.length !== 0} -
- + +
+ {#await import('$lib/components/StockSplits.svelte') then {default: Comp}} + + {/await}
- {/if} - +
@@ -1480,13 +1469,7 @@ function changeChartType() {