aboutsummaryrefslogtreecommitdiff
path: root/src/lib/AuctionPriceScatterplot.svelte
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-18 16:25:58 +0000
committermat <github@matdoes.dev>2022-05-18 16:25:58 +0000
commitad02f4a34923bf2819504568351fac23cd2c1dcc (patch)
treeb820301910bed6429509136110d11c341ee577e6 /src/lib/AuctionPriceScatterplot.svelte
parent96ba69c37b55b5fc056db997b68b92a208ace66d (diff)
downloadskyblock-stats-ad02f4a34923bf2819504568351fac23cd2c1dcc.tar.gz
skyblock-stats-ad02f4a34923bf2819504568351fac23cd2c1dcc.tar.bz2
skyblock-stats-ad02f4a34923bf2819504568351fac23cd2c1dcc.zip
improve bad interval calculation
Diffstat (limited to 'src/lib/AuctionPriceScatterplot.svelte')
-rw-r--r--src/lib/AuctionPriceScatterplot.svelte11
1 files changed, 8 insertions, 3 deletions
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}
<text
x="-1"
- y={Math.max(5, 100 - intervalIndex * gridHeight + 2)}
+ y={Math.min(Math.max(5, 100 - intervalIndex * gridHeight + 2), 100)}
fill="var(--theme-darker-text)"
font-size="6px"
text-anchor="end">{shortenBigNumber(heightCoinInterval * intervalIndex)}</text