From ad02f4a34923bf2819504568351fac23cd2c1dcc Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 18 May 2022 16:25:58 +0000 Subject: improve bad interval calculation --- src/lib/AuctionPriceScatterplot.svelte | 11 ++++++++--- src/lib/api.ts | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/lib') diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index 42fb6f1..d01349c 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -12,8 +12,13 @@ let hoursBetween = (currentTimestamp - earliestTimestamp) / (60 * 60) const gridWidth = 100 / hoursBetween - let heightCoinInterval = Math.ceil(Math.pow(10, Math.floor(Math.log10(maxCoins / 2)))) - + // this code is bad but it works + let heightCoinInterval = Math.ceil(Math.pow(10, Math.floor(Math.log10(maxCoins / 5)))) + if (heightCoinInterval < maxCoins / 20) { + heightCoinInterval *= 5 + } else if (heightCoinInterval < maxCoins / 10) { + heightCoinInterval *= 2 + } const gridHeight = 100 / (maxCoins / heightCoinInterval) function getAuctionCoordinates(auction: SimpleAuctionSchema) { @@ -84,7 +89,7 @@ {#each new Array(Math.floor(maxCoins / heightCoinInterval) + 1) as _, intervalIndex} {shortenBigNumber(heightCoinInterval * intervalIndex)}