Public
Edited
Apr 2
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
async function fetchWeatherData(location, startDate, endDate, apiKey) {
const baseUrl =
"https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline";
const url = `${baseUrl}/${encodeURIComponent(
location
)}/${startDate}/${endDate}?unitGroup=us&include=days&key=${apiKey}&contentType=json`;

try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}

const weatherData = await response.json();
console.log(weatherData);
return weatherData;
} catch (error) {
console.error("Error fetching weather data:", error);
}
}
Insert cell
snowfallData = {
// Example usage
const location = "Kirkwood, CA";
const startDate = "2015-01-01";
const endDate = "2025-03-31";
const apiKey = "5BLFRD9G3UQFC693U88ABUX4T"; // Replace with your actual API key

return fetchWeatherData(location, startDate, endDate, apiKey);
}
Insert cell
snowfallData.days
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// y = d3
// .scaleLinear()
// .domain([0, d3.max(series, d => d3.max(d, d => d[1]))])
// .rangeRound([height - margin.bottom, margin.top])
Insert cell
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