Published
Edited
Feb 1, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
weather = aq.fromCSV(await FileAttachment("weather.csv").text())
Insert cell
{

const width = 280,
height = 180;
// maximum temperature plot
const temp_max = vl.markLine()
.data(weather)
.encode(
vl.x().month("date"),
vl.y().average("temp_max"),
vl.color().fieldN("location")
)
.width(width)
.height(height);

// precipitation plot
const precip = vl.markLine()
.data(weather)
.encode(
vl.x().month("date"),
vl.y().average("precipitation"),
vl.color().fieldN("location")
)
.width(width)
.height(height);

// precipitation plot
const wind = vl.markLine()
.data(weather)
.encode(
vl.x().month("date"),
vl.y().average("wind"),
vl.color().fieldN("location")
)
.width(width)
.height(height);
return vl.hconcat(temp_max, precip, wind)
.data(weather)
.render()
}
Insert cell
{
const width = 280,
height = 180;
const base = vl.markLine()
.data(weather)
.encode(
vl.x().month("date"),
vl.color().fieldN("location")
)
.width(width)
.height(height);
const temp_max = base.encode(vl.y().average("temp_max")),
precip = base.encode(vl.y().average("precipitation")),
wind = base.encode(vl.y().average("wind"));
return vl.hconcat(temp_max, precip, wind).render()
}
Insert cell
{
const width = 280,
height = 180;
return vl.markLine()
.data(weather)
.encode(
vl.x().month("date"),
vl.color().fieldN("location"),
vl.y().average(vl.repeat("column"))
)
.width(width)
.height(height)
.repeat({column: ["temp_max", "precipitation", "wind"]})
.render()
}
Insert cell
{
const width = 120,
height = 120;
return vl.markPoint({filled: true, size: 3, opacity: 0.8})
.data(weather)
.encode(
vl.x().fieldQ(vl.repeat("column")),
vl.y().fieldQ(vl.repeat("row")),
vl.color().fieldN("location")
)
.width(width)
.height(height)
.repeat({
column: ["temp_max", "precipitation", "wind"],
row: ["temp_max", "precipitation", "wind"],
})
.render()
}
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