Public
Edited
Jan 18
Paused
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
yearlyOcean.map((d) => d.Year)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3.max([
d3.max(yearlyLand, (d) => d.Anomaly),
d3.max(yearlyOcean, (d) => d.Anomaly)
])
Insert cell
Insert cell
d3.min([
d3.min(yearlyLand, (d) => d.Anomaly),
d3.min(yearlyOcean, (d) => d.Anomaly)
])
Insert cell
d3.min(yearlyLand, (d) => d.Anomaly)
Insert cell
(laextent[1] - laextent[0]) / (ocextent[1] - ocextent[0])
Insert cell
Insert cell
ocextent = d3.extent(yearlyOcean, (d) => d.Anomaly)
Insert cell
Insert cell
Insert cell
yearAxis = (g, H) => {
g.attr("class", "arc_label").attr(
"transform",
`translate(0, ${H - margin.bottom + 20})`
);

g.append("text")
.attr("class", "subheader")
.attr("x", margin.right)
.attr("text-anchor", "start")
.text(d3.min(yearlyLand, (d) => d.Year));

g.append("text")
.attr("class", "subheader")
.attr("x", width - margin.left)
.attr("text-anchor", "end")
.text(d3.max(yearlyLand, (d) => d.Year));
}
Insert cell
Insert cell
height = (width * 2) / 3.3
Insert cell
Insert cell
yearlyOcean = cleancsv(dirtyocean, 4)
Insert cell
dirtyland = d3.text(
"https://www.ncei.noaa.gov/access/monitoring/climate-at-a-glance/global/time-series/globe/land/ann/2/1850-2023/data.csv?trend=true&trend_base=10&begtrendyear=1982&endtrendyear=2022"
)
Insert cell
yearlyLand = cleancsv(dirtyland, 4)
Insert cell
function cleancsv(dirtycsv, rowcount) {
const rows = d3.csvParseRows(dirtycsv),
comments = rows
.splice(0, rowcount) // <= 2 is the number of lines to consider as comments
.flat()
.join(" "),
columns = rows.splice(0, 1).flat();
return Object.assign(
rows.map((row) =>
Object.fromEntries(columns.map((name, i) => [name, Number(row[i])]))
),
{ columns, comments }
);
}
Insert cell
Insert cell
Insert cell
colors = ({
background: "#f9f6e9", //"white", //"#FAEFD1",
textcolor: "#042c44",
hot: "#f4352c",
cold: "#042c44",
lighthot: "#fdeae9",
lightcold: "#e5e9ec"
})
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