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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more