aboutsummaryrefslogtreecommitdiff
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
parent96ba69c37b55b5fc056db997b68b92a208ace66d (diff)
downloadskyblock-stats-ad02f4a34923bf2819504568351fac23cd2c1dcc.tar.gz
skyblock-stats-ad02f4a34923bf2819504568351fac23cd2c1dcc.tar.bz2
skyblock-stats-ad02f4a34923bf2819504568351fac23cd2c1dcc.zip
improve bad interval calculation
-rw-r--r--src/lib/AuctionPriceScatterplot.svelte11
-rw-r--r--src/lib/api.ts4
2 files changed, 10 insertions, 5 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
diff --git a/src/lib/api.ts b/src/lib/api.ts
index 77d6334..9152370 100644
--- a/src/lib/api.ts
+++ b/src/lib/api.ts
@@ -1,4 +1,4 @@
// the trailing slash is required
-// export const API_URL = 'https://skyblock-api.matdoes.dev/'
+export const API_URL = 'https://skyblock-api.matdoes.dev/'
// export const API_URL = 'http://localhost:8080/'
-export const API_URL = 'https://8080-skyblocksta-skyblockapi-gef4h4mxokc.ws-us45.gitpod.io/'
+// export const API_URL = 'https://8080-skyblocksta-skyblockapi-gef4h4mxokc.ws-us45.gitpod.io/'