import { aq, op } from "@uwdata/arquero"
= "https://d33173dkfxwa5x.cloudfront.net/www/"
bucket_base
= FileAttachment FA
= null
mutable myLocation = "default"
mutable geolocateStatus
= {
getLocation yield null
yield navigator.geolocation.getCurrentPosition(
=> {
pos = {
mutable myLocation lat: pos.coords.latitude,
lon: pos.coords.longitude
}= "granted"
mutable geolocateStatus ,
}=> {
e console.log("Geolocation error", e),
= "error"
mutable geolocateStatus ,
}
{enableHighAccuracy: false
}) }
Is it hot in right now?
= ({
answers "Hell no!": {color: "white", fill1: "#5287d1", fill2: "#2166ac" },
"No!": {color: "white", fill1: "#a2cdeb", fill2: "#67a9cf" },
"Nope": {color: "#333333", fill1: "#f5f8fa", fill2: "#d1e5f0" },
"Not really": {color: "#333333", fill1: "#f7f7f7", fill2: "#ebebeb" },
"Yup": {color: "#333333", fill1: "#fddcca", fill2: "#f7cfb7" },
"Yeah!": {color: "white", fill1: "#de7b49", fill2: "#fc946a" },
"Hell yeah!": {color: "white", fill1: "#d1231d", fill2: "#b2182b" }
})
html`
<div class="answer-icon-and-label">
<span class="answer-icon" style="background-color: ${answers[statsPlace.isit_answer].fill2};">
</span>
<span>${statsPlace.isit_answer}</span>
</div>`
md`${statsPlace.isit_comment}`
Here’s how today compares…
= import("https://cdn.skypack.dev/date-fns@3.3.1?min")
datefns = new Date(Date.parse(statsPlace.isit_maximum_dt || null))
tmaxWhen = new Date(Date.parse(statsPlace.isit_minimum_dt || null))
tminWhen
= isFinite(tmaxWhen) ?
tmaxWhenFriendly .formatRelative(tmaxWhen, new Date()) : ""
datefns= isFinite(tminWhen) ?
tminWhenFriendly .formatRelative(tminWhen, new Date()) : ""
datefns
= statsPlace.isit_average.toFixed(1) + "%" percentRating
md`${statsPlace.isit_minimum} °C `
md`${tminWhenFriendly}`
md`${statsPlace.isit_maximum} °C `
md`${tmaxWhenFriendly}`
html`
<div class="answer-icon-and-label">
<span class="answer-icon" style="background-color: ${answers[statsPlace.isit_answer].fill2};"></span>
<span>${statsPlace.isit_current.toFixed(1)} °C</span>
</div>`
md`Average so far<br>hotter than **${percentRating}** of days for this time of year.`
This is the distribution of temperatures typical for this time of year, which we’ve defined as a seven day window either side of today. Just like a bell curve, the plot is higher at more common temperatures and lower at rare temperatures.
… and the rest of the year.
We’ve compared every day this year at to similar times of year in the past. Red days were hot compared to records; blue days were cold.
Here’s how the rest of Australia looks today so far.
= (new Date()).getUTCHours()
nowHour >= 10 && nowHour <= 22 ?
nowHour md`Some places may still be cooling off as the night continues.` :
md`Some places may still be heating up as the day continues.`
= statsAll.filter(d => (!d.max_stale) && (!d.min_stale))
currentStats = statsAll.filter(d => d.max_stale || d.min_stale) staleStats
// breaking out the pointer layer for readability
// (and in case we decide to customise it later)
= Plot.pointer({
tipTemplate x: "lon",
y: "lat",
channels: {
place: {
label: "",
value: d => d.isit_label,
,
}label: {
label: "",
value: d => d.isit_comment
,
}separator: {
label: "",
value: d => ""
,
}isit_maximum: {
label: "Max:",
value: d => d.isit_maximum + "°C"
,
}isit_minimum: {
label: "Min:",
value: d => d.isit_minimum + "°C"
},
}fontSize: 20,
fontFamily: "Roboto Condensed",
format: {
x: null,
y: null
,
}lineWidth: 20,
lineHeight: 1.25,
pointerSize: 0,
fillOpacity: 0.8,
strokeOpacity: 0
})