Published
Edited
Aug 19, 2021
Insert cell
Insert cell
fetch("https://api.weather.gov/gridpoints/OKX/33,37/forecast").then(response => response.json())
Insert cell
Insert cell
Insert cell
Insert cell
weatherStation = {
const [lng, lat] = coordinates;
return (await fetch(`https://api.weather.gov/points/${[lat, lng]}`)).json()
}
Insert cell
localForecast = (await fetch(weatherStation.properties.forecast)).json()
Insert cell
Insert cell
forecast = table(
localForecast.properties.periods
.slice(0, 7)
.map(({ name, temperature, icon, detailedForecast, shortForecast }) => ({
Day: md`**${name}**`,
Temp: md`**${temperature} °F**`,
Icon: html`<img width=70 src="${icon}" />`,
Forecast: detailedForecast
}))
)
Insert cell
domain = {
const temps = localForecast.properties.periods.map(d => d.temperature);
const high = Math.max.apply(Math, temps);
const low = Math.min.apply(Math, temps);
return {domain: [Math.min(low, 0), Math.max(high, 90)]};
}
Insert cell
Insert cell
Insert cell
caretImage = Object.assign(await FileAttachment("image@1.png").image(), {width: 18})
Insert cell
Insert cell
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