Public
Edited
Jan 8, 2024
Insert cell
Insert cell
submission = ({
// area: 457016351.7194517
// 10000
// 457016351
// 25000000000
area: 30000,
zoom: {
warpedMap: 12.4,
submission: 9.4
}
})
Insert cell
computeZoomRatio(submission)
Insert cell
areaRatio = 1 -
Math.min(
1,
Math.max(
(Math.log(submission.area) - Math.log(AREA_MIN)) /
(Math.log(AREA_MAX) - Math.log(AREA_MIN)),
0
)
)
Insert cell
areaRatio2 = logFunction(
1 -
Math.min(
1,
Math.max((submission.area - AREA_MIN) / (AREA_MAX - AREA_MIN), 0)
)
)
Insert cell
maxScore = (MAX_SCORE_MAX - MAX_SCORE_MIN) * areaRatio + MAX_SCORE_MIN
Insert cell
maxScore2 = (MAX_SCORE_MAX - MAX_SCORE_MIN) * areaRatio2 + MAX_SCORE_MIN
Insert cell
function formatScore(score) {
return new Intl.NumberFormat().format(
Math.round(score) * DISPLAY_SCORE_MULTIPLIER
);
}
Insert cell
squaredFunction(0.9)
Insert cell
formatScore(maxScore)
Insert cell
function logFunction(ratio) {
return Math.log1p(ratio);
}
Insert cell
function squaredFunction(ratio) {
return Math.pow(ratio, 2);
}
Insert cell
MAX_ZOOM_DIFFERENCE = 5
Insert cell
MAX_SCORE_MIN = 50
Insert cell
MAX_SCORE_MAX = 100
Insert cell
DISPLAY_SCORE_MULTIPLIER = 100
Insert cell
// Size of city block in square meters
AREA_MIN = 100 * 100
Insert cell
// 10000
// 457016351
// 25000000000
Insert cell
// Size of small country in square meters
AREA_MAX = 25_000 * 1_000 * 1_000
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
TIME_MIN = 5 * 1000
Insert cell
TIME_MAX = 2 * 60 * 1000
Insert cell
time = 9000
Insert cell
squaredFunction(
1 - Math.min(1, Math.max((time - TIME_MIN) / (TIME_MAX - TIME_MIN), 0))
)
Insert cell
function computeZoomRatio(submission) {
const zoomDiff = Math.abs(submission.zoom.warpedMap - submission.zoom.submission)
return 1 - Math.min(1, zoomDiff / MAX_ZOOM_DIFFERENCE)
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more