diff --git a/src/lib/components/Feedback.svelte b/src/lib/components/Feedback.svelte index 0db1112e..b90c34f8 100644 --- a/src/lib/components/Feedback.svelte +++ b/src/lib/components/Feedback.svelte @@ -92,7 +92,8 @@ - + + diff --git a/src/lib/components/LayerCake/Bar/AxisX.svelte b/src/lib/components/LayerCake/Bar/AxisX.svelte new file mode 100644 index 00000000..901c8deb --- /dev/null +++ b/src/lib/components/LayerCake/Bar/AxisX.svelte @@ -0,0 +1,119 @@ + + + + + {#each tickVals as tick, i (tick)} + {#if baseline === true} + + {/if} + + + {#if gridlines === true} + + {/if} + {#if tickMarks === true} + + {/if} + {format(tick)} + + {/each} + + + \ No newline at end of file diff --git a/src/lib/components/LayerCake/Bar/AxisY.svelte b/src/lib/components/LayerCake/Bar/AxisY.svelte new file mode 100644 index 00000000..1482131f --- /dev/null +++ b/src/lib/components/LayerCake/Bar/AxisY.svelte @@ -0,0 +1,119 @@ + + + + + {#each tickVals as tick (tick)} + {@const tickValPx = $yScale(tick)} + + {#if gridlines === true} + + {/if} + {#if tickMarks === true} + + {/if} + {format(tick)} + + {/each} + + + \ No newline at end of file diff --git a/src/lib/components/LayerCake/Bar/Bar.svelte b/src/lib/components/LayerCake/Bar/Bar.svelte new file mode 100644 index 00000000..8f2114a7 --- /dev/null +++ b/src/lib/components/LayerCake/Bar/Bar.svelte @@ -0,0 +1,26 @@ + + + + + {#each $data as d, i} + + {/each} + \ No newline at end of file diff --git a/src/routes/home/+page.svelte b/src/routes/home/+page.svelte index 5d98d098..cff8f130 100644 --- a/src/routes/home/+page.svelte +++ b/src/routes/home/+page.svelte @@ -11,20 +11,15 @@ import Activity from "lucide-svelte/icons/activity"; import { abbreviateNumber, formatDate } from '$lib/utils'; - import { numberOfUnreadNotification, screenWidth} from '$lib/store'; - import Lazy from 'svelte-lazy'; + import { numberOfUnreadNotification} from '$lib/store'; - import { Chart } from 'svelte-echarts' + import { LayerCake, Svg } from 'layercake'; + import { scaleBand } from 'd3-scale'; + import Bar from '$lib/components/LayerCake/Bar/Bar.svelte'; + import AxisY from '$lib/components/LayerCake/Bar/AxisY.svelte'; -import { init, use } from 'echarts/core' -import { BarChart } from 'echarts/charts' -import { GridComponent } from 'echarts/components' - - // now with tree-shaking - use([BarChart, GridComponent]) - - export let data; + let isLoaded = false; const quickInfo = data?.getDashboard?.quickInfo; @@ -49,68 +44,15 @@ function latestInfoDate(inputDate) { return differenceInDays <=1; } -const tickerGraphName = data?.getDashboard?.retailTracker?.map(item => item?.symbol) || []; -const tradedList = data?.getDashboard?.retailTracker?.map(item => item?.traded) || []; -const optionsGraph = { - animation: $screenWidth < 640 ? false: true, - grid: { - left: '2%', - right: '3%', - bottom: '6%', - top: '0%', - containLabel: true - }, - xAxis: { - type: 'value', - splitLine: { - show: false, // Disable x-axis grid lines - }, - axisLabel: { - show: false // Hide x-axis labels - }, - axisTick: { - show: false // Hide x-axis ticks - }, - axisLine: { - show: false // Hide x-axis line - } - }, - yAxis: { - type: 'category', - data: tickerGraphName, - inverse: true, - axisTick: { - show: false // Hide x-axis ticks - }, - }, - series: [ - { - data: tradedList, - label: { - show: true, - position: 'inside', - formatter: function(params) { - return abbreviateNumber(params?.value,true); - }, - fontWeight: 600 - }, - type: 'bar', - showBackground: true, - backgroundStyle: { - color: 'rgba(180, 180, 180, 0.2)' - }, - itemStyle: { - color: 'white' // Bar color is white - } - } - ] -}; +const xKey = 'traded'; +const yKey = 'symbol'; let Feedback; onMount( async() => { - Feedback = (await import('$lib/components/Feedback.svelte')).default + Feedback = (await import('$lib/components/Feedback.svelte')).default + isLoaded = true; }) @@ -309,18 +251,32 @@ onMount( async() => { Latest Retail Trader investing behavior to identify market trends. - - - - - - - - - - - - + + {#if data?.getDashboard?.retailTracker?.length !== 0 && isLoaded} + + + + + + + + + {:else} + + + + + + + + {/if} @@ -419,23 +375,11 @@ onMount( async() => {