🍪🍰 Checkpoint

./public/index.js:1954897/59330
This commit is contained in:
Glitch (glitch-hello-node) committed 2021-11-14 16:37:38 +00:00
1 parent 68da9a962d
commit 3869d19029
2 files changed
+18 -12

No files matched your search

+5 -12
View File
@@ -35,8 +35,8 @@ const map = L.map('map', {
maxZoom: 18
}).setView([32.98613, -96.75042], 18)
const INTERVAL = 10 * 60 * 1000
const STEP = 2 * 60 * 1000
const INTERVAL = 10 * 60 * 1000 + STEP
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
maxZoom: 18,
@@ -89,7 +89,7 @@ async function drawRegions() {
const red = new Color(255, 0, 0)
const green = new Color(0, 255, 0)
console.log({current, max, min})
const color = red.interpolate(green, current / (max - min))
const color = red.interpolate(green, -current / (max - min))
buildings.ECSW.poly.setStyle({ color: color.asRgbCss() })
console.log({avg, current, delta, color})
@@ -144,18 +144,11 @@ async function displayCard(id) {
const current = data[data.length - 1]?.count ?? NaN
const avg = data.reduce((acc, v) => acc + v.count, 0) / data.length
const delta = current - avg
// const min = Math.min(...data.map(d => d.count))
// const max = Math.max(...data.map(d => d.count))
const busy = delta < 0
const busy = 0 < delta
// const red = new Color(255, 0, 0)
// const green = new Color(0, 255, 0)
// const color = red.interpolate(green, current / (max - min))
console.log({busy, avg, current, delta})
console.log(delta)
const msg = Number.isNaN(delta)
? "No data..."
const msg = Number.isNaN(delta) ? "No data..."
: (busy ? "Busier than usual": "Not as busy :)")
card.innerHTML = `