From cd9748e59f1dd9ef31afb22195b8d5a1346ec5c3 Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 16 May 2022 00:09:44 -0500 Subject: start adding auctionprices page --- src/lib/APITypes.d.ts | 19 +++++++++++++ src/lib/AuctionPriceScatterplot.svelte | 49 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/lib/AuctionPriceScatterplot.svelte (limited to 'src/lib') diff --git a/src/lib/APITypes.d.ts b/src/lib/APITypes.d.ts index 6402721..6429e8b 100644 --- a/src/lib/APITypes.d.ts +++ b/src/lib/APITypes.d.ts @@ -434,3 +434,22 @@ export interface AccessoryBagUpgrades { list: string[] } } + +export interface SimpleAuctionSchema { + /** The UUID of the auction so we can look it up later. */ + id: string + coins: number + /** + * The timestamp as **seconds** since epoch. It's in seconds instead of ms + * since we don't need to be super exact and so it's shorter. + */ + ts: number + /** Whether the auction was bought or simply expired. */ + success: boolean + bin: boolean +} +export interface ItemAuctionsSchema { + /** The id of the item */ + _id: string + auctions: SimpleAuctionSchema[] +} diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte new file mode 100644 index 0000000..f887725 --- /dev/null +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -0,0 +1,49 @@ + + + + + + + + + + + {#each item.auctions as auction} + {@const timestampPercentage = + (auction.ts - earliestTimestamp) / (currentTimestamp - earliestTimestamp)} + + {/each} + + + + -- cgit From 8ba9c7090c88c04d43ca727b7ed012cf5a6b58c8 Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 16 May 2022 15:36:06 +0000 Subject: start adding really basic tooltip --- src/lib/AuctionPreviewTooltip.svelte | 22 ++++++++++++++++++++++ src/lib/AuctionPriceScatterplot.svelte | 16 ++++++++++++++++ src/lib/utils.ts | 8 +++++++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/lib/AuctionPreviewTooltip.svelte (limited to 'src/lib') diff --git a/src/lib/AuctionPreviewTooltip.svelte b/src/lib/AuctionPreviewTooltip.svelte new file mode 100644 index 0000000..226feee --- /dev/null +++ b/src/lib/AuctionPreviewTooltip.svelte @@ -0,0 +1,22 @@ + + +{#if preview} +
+

uuid: {JSON.stringify(preview)}

+
+{/if} + + diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index f887725..e416163 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -1,7 +1,9 @@ @@ -36,6 +49,9 @@ r="1" stroke-width="4" fill={auction.bin ? '#11b' : '#1b1'} + on:mouseenter={e => showAuctionPreview(e, auction.id)} + on:click={e => showAuctionPreview(e, auction.id)} + on:mouseleave={hideAuctionPreview} /> {/each} diff --git a/src/lib/utils.ts b/src/lib/utils.ts index e34d573..c2e4b86 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -219,4 +219,10 @@ export function skyblockTime(year: number, month = 1, day = 1) { if (month) time += 37200000 * (month - 1) if (day) time += 1200000 * (day - 1) return time -} \ No newline at end of file +} + +export interface PreviewedAuctionData { + pageX: number + pageY: number + uuid: string +} -- cgit From b6d23f4334eae873e7d32a4d5bb5f8b3a1a67ce5 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 17 May 2022 16:20:20 +0000 Subject: improved auction price scatterplot --- src/lib/AuctionPreviewTooltip.svelte | 40 +++++++++++++++++--- src/lib/AuctionPriceScatterplot.svelte | 68 +++++++++++++++++++++------------- src/lib/utils.ts | 4 +- 3 files changed, 80 insertions(+), 32 deletions(-) (limited to 'src/lib') diff --git a/src/lib/AuctionPreviewTooltip.svelte b/src/lib/AuctionPreviewTooltip.svelte index 226feee..223cec2 100644 --- a/src/lib/AuctionPreviewTooltip.svelte +++ b/src/lib/AuctionPreviewTooltip.svelte @@ -1,22 +1,52 @@ -{#if preview} -
-

uuid: {JSON.stringify(preview)}

+ + +{#if lastPreview} + {@const date = new Date(lastPreview.auction.ts * 1000)} +
+

{lastPreview.auction.coins.toLocaleString()} coins

+
{/if} diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index e416163..48a3fa5 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -1,34 +1,47 @@ @@ -38,20 +51,23 @@ - + {#each item.auctions as auction} - {@const timestampPercentage = - (auction.ts - earliestTimestamp) / (currentTimestamp - earliestTimestamp)} + {@const [x, y] = getAuctionCoordinates(auction)} showAuctionPreview(e, auction.id)} - on:click={e => showAuctionPreview(e, auction.id)} - on:mouseleave={hideAuctionPreview} + tabindex="-1" /> {/each} diff --git a/src/lib/utils.ts b/src/lib/utils.ts index c2e4b86..c094db4 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,3 +1,5 @@ +import type { SimpleAuctionSchema } from "./APITypes" + export const colorCodes: { [key: string]: string } = { '0': '#000000', // black '1': '#0000be', // blue @@ -224,5 +226,5 @@ export function skyblockTime(year: number, month = 1, day = 1) { export interface PreviewedAuctionData { pageX: number pageY: number - uuid: string + auction: SimpleAuctionSchema } -- cgit From f9bb90cab81e7c7f8c2a7e932bbf2ddbf7b51f1f Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 17 May 2022 18:50:49 +0000 Subject: auction search and fixes --- src/lib/AuctionPreviewTooltip.svelte | 4 ++-- src/lib/AuctionPriceScatterplot.svelte | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/lib') diff --git a/src/lib/AuctionPreviewTooltip.svelte b/src/lib/AuctionPreviewTooltip.svelte index 223cec2..417f8b3 100644 --- a/src/lib/AuctionPreviewTooltip.svelte +++ b/src/lib/AuctionPreviewTooltip.svelte @@ -5,7 +5,7 @@ import type { PreviewedAuctionData } from './utils' export let preview: PreviewedAuctionData | null - export let lastPreview: PreviewedAuctionData | null + let lastPreview: PreviewedAuctionData | null $: lastPreview = preview ?? lastPreview @@ -36,7 +36,7 @@ #auction-preview-tooltip { position: absolute; border: 1px solid rgba(255, 255, 255, 0.1); - background: var(--theme-lighter-background); + background: rgba(0, 0, 0, 0.1); padding: 0.5em; transition: left 200ms, top 200ms; pointer-events: none; diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index 48a3fa5..1e774d0 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -25,7 +25,11 @@ let nearestDistance = Number.MAX_SAFE_INTEGER let nearestAuction: SimpleAuctionSchema | null = null for (const auction of item.auctions) { - const auctionCoords = getAuctionCoordinates(auction) + const auctionCoordsSvg = getAuctionCoordinates(auction) + const auctionCoords = [ + (auctionCoordsSvg[0] * rect.width) / 100, + (auctionCoordsSvg[1] * rect.height) / 100, + ] const distance = Math.pow(mouseCoords[0] - auctionCoords[0], 2) + Math.pow(mouseCoords[1] - auctionCoords[1], 2) @@ -35,7 +39,8 @@ } } if (nearestAuction) { - const [x, y] = getAuctionCoordinates(nearestAuction) + const [svgX, svgY] = getAuctionCoordinates(nearestAuction) + const [x, y] = [(svgX * rect.width) / 100, (svgY * rect.height) / 100] currentlyPreviewedAuction = { pageX: window.scrollX + rect.left + x, pageY: window.scrollY + rect.top + y, @@ -67,7 +72,7 @@ r="1" stroke-width="4" fill={auction.bin ? '#11b' : '#1b1'} - tabindex="-1" + class:selected-auction={currentlyPreviewedAuction?.auction?.id === auction?.id} /> {/each} @@ -78,4 +83,8 @@ height: 10em; width: 100%; } + + .selected-auction { + stroke: #06e7; + } -- cgit From 7a04672666e9c366e7bbf241ed82efe481dc9492 Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 18 May 2022 01:21:16 +0000 Subject: grid background improvement --- src/lib/AuctionPriceScatterplot.svelte | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index 1e774d0..0532f97 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -9,8 +9,12 @@ let maxCoins: number = item.auctions.reduce((max, auction) => Math.max(max, auction.coins), 0) let currentTimestamp = Math.floor(Date.now() / 1000) let earliestTimestamp = item.auctions.length > 0 ? item.auctions[0].ts : 0 - let minutesBetween = (currentTimestamp - earliestTimestamp) / 360 - let gridWidth = 100 / minutesBetween + let hoursBetween = (currentTimestamp - earliestTimestamp) / (60 * 60) + const gridWidth = 100 / hoursBetween + + let heightCoinInterval = Math.pow(10, Math.floor(Math.log10(maxCoins / 2))) + + const gridHeight = 100 / (maxCoins / heightCoinInterval) function getAuctionCoordinates(auction: SimpleAuctionSchema) { const timestampPercentage = @@ -52,8 +56,15 @@ - - + + Date: Tue, 17 May 2022 20:48:54 -0500 Subject: fixes and improved tooltip --- src/lib/APITypes.d.ts | 2 +- src/lib/AuctionPreviewTooltip.svelte | 20 +++++++++----------- src/lib/AuctionPriceScatterplot.svelte | 4 ++-- src/lib/api.ts | 1 + 4 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/lib') diff --git a/src/lib/APITypes.d.ts b/src/lib/APITypes.d.ts index 6429e8b..95231f7 100644 --- a/src/lib/APITypes.d.ts +++ b/src/lib/APITypes.d.ts @@ -450,6 +450,6 @@ export interface SimpleAuctionSchema { } export interface ItemAuctionsSchema { /** The id of the item */ - _id: string + id: string auctions: SimpleAuctionSchema[] } diff --git a/src/lib/AuctionPreviewTooltip.svelte b/src/lib/AuctionPreviewTooltip.svelte index 417f8b3..a3a73fb 100644 --- a/src/lib/AuctionPreviewTooltip.svelte +++ b/src/lib/AuctionPreviewTooltip.svelte @@ -1,34 +1,32 @@ - + {#if lastPreview} - {@const date = new Date(lastPreview.auction.ts * 1000)}

{lastPreview.auction.coins.toLocaleString()} coins

- +
{/if} diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index 0532f97..cfdbe9b 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -57,7 +57,7 @@ diff --git a/src/lib/api.ts b/src/lib/api.ts index 689a952..1721d01 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -1,2 +1,3 @@ // the trailing slash is required export const API_URL = 'https://skyblock-api.matdoes.dev/' +// export const API_URL = 'http://localhost:8080/' -- cgit From ce97f7eec03a44dd653512656546ade2eb8fa01b Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 17 May 2022 23:20:35 -0500 Subject: Show auctions sold frequency --- src/lib/AuctionPriceScatterplot.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index cfdbe9b..defadcd 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -75,7 +75,7 @@ bind:this={svgEl} /> - {#each item.auctions as auction} + {#each item.auctions as auction (auction.id)} {@const [x, y] = getAuctionCoordinates(auction)} Date: Tue, 17 May 2022 23:27:38 -0500 Subject: rename auctions page & tooltip fade in --- src/lib/AuctionPreviewTooltip.svelte | 1 + 1 file changed, 1 insertion(+) (limited to 'src/lib') diff --git a/src/lib/AuctionPreviewTooltip.svelte b/src/lib/AuctionPreviewTooltip.svelte index a3a73fb..39a2370 100644 --- a/src/lib/AuctionPreviewTooltip.svelte +++ b/src/lib/AuctionPreviewTooltip.svelte @@ -24,6 +24,7 @@ class:hidden={preview === null} style="left: {lastPreview.pageX}px; top: {lastPreview.pageY}px" out:fade={{ duration: 100 }} + in:fade={{ duration: 100 }} >

{lastPreview.auction.coins.toLocaleString()} coins

-- cgit From 409d35b26c4dc395ccf90d48af42a4c5d3c69160 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 17 May 2022 23:38:57 -0500 Subject: remove keyed auctions --- src/lib/AuctionPriceScatterplot.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index defadcd..cfdbe9b 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -75,7 +75,7 @@ bind:this={svgEl} /> - {#each item.auctions as auction (auction.id)} + {#each item.auctions as auction} {@const [x, y] = getAuctionCoordinates(auction)} Date: Wed, 18 May 2022 00:21:08 -0500 Subject: fix NaN warning --- src/lib/AuctionPriceScatterplot.svelte | 73 +++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 33 deletions(-) (limited to 'src/lib') diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index cfdbe9b..f430edd 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -54,40 +54,47 @@ } - - - - - - - - - {#each item.auctions as auction} - {@const [x, y] = getAuctionCoordinates(auction)} - 0} + + + + + + + - {/each} - - + + {#each item.auctions as auction} + {@const [x, y] = getAuctionCoordinates(auction)} + + {/each} + + +{/if} -- cgit