diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/AuctionPriceScatterplot.svelte | 19 | ||||
-rw-r--r-- | src/routes/auctionprices.svelte | 4 |
2 files changed, 18 insertions, 5 deletions
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 @@ <svg viewBox="0 0 100 100" class="item-auction-history"> <defs> - <pattern id="grid-{item._id}" width={gridWidth} height="10" patternUnits="userSpaceOnUse"> - <path d="M {gridWidth} 0 L 0 0 0 10" fill="none" stroke="#fff2" stroke-width="1" /> + <pattern + id="grid-{item._id}" + width={gridWidth} + height={gridHeight} + patternUnits="userSpaceOnUse" + x="0%" + y="100%" + > + <path d="M {gridWidth} 0 L 0 0 0 {gridHeight}" fill="none" stroke="#fff2" stroke-width="1" /> </pattern> </defs> <rect diff --git a/src/routes/auctionprices.svelte b/src/routes/auctionprices.svelte index d07c533..eccaab7 100644 --- a/src/routes/auctionprices.svelte +++ b/src/routes/auctionprices.svelte @@ -40,7 +40,9 @@ } async function fetchItems(itemIds: string[]) { - data = await fetch(`${API_URL}auctionprices?items=${itemIds.join(',')}`).then(r => r.json()) + let url = `${API_URL}auctionprices` + if (query.length > 0) url += `?items=${itemIds.join(',')}` + data = await fetch(url).then(r => r.json()) } let pageHeight = 0 |