Published
Edited
Apr 26, 2021
Comments locked
2 stars
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
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
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
joined_data3 = {
let merged = [];
let arr1 = self_iso_data;
let arr2 = casespercapita;
for (let i = 0; i < arr1.length; i++) {
merged.push({
...arr1[i],
...arr2.find(itmInner => itmInner["name"] === arr1[i]["X.1"])
});
}
for (let i = 0; i < merged.length; i++) {
merged[i]["y"] = merged[i]["y"] * 1000;
}
let slice1 = merged.slice(1, 5);
let slice2 = merged.slice(15, 20);
merged = slice1.concat(slice2);
return merged;
}
Insert cell
casespercapita = {
let merged = [];
for (let [key, value] of confirmed_cases) {
if (value !== 0) {
merged.push({
name: key,
y: value / population.get(key)
});
}
}
return merged;
}
Insert cell
Insert cell
Insert cell
Insert cell
sliced = {
let s1 = self_iso_data.slice(1, 4);
let s2 = self_iso_data.slice(21, 25);
return s1.concat(s2);
}
Insert cell
Insert cell
Insert cell
Insert cell
y = d3
.scaleLinear()
.domain([0, d3.max(joined_data3, d => d3.max(["Yes"], key => d[key]))])
.nice()
.rangeRound([height - margin.bottom, margin.top])
Insert cell
Insert cell
Insert cell
x1 = d3
.scaleBand()
.domain(["Yes", "y"])
.rangeRound([0, x0.bandwidth()])
.padding(0.05)
Insert cell
yAxis3 = g =>
g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y).ticks(null, "s"))
.call(g => g.select(".domain").remove())
.call(g =>
g
.select(".tick:last-of-type text")
.clone()
.attr("x", 3)
.attr("text-anchor", "start")
.attr("font-weight", "bold")
.text(joined_data.y)
)
Insert cell
Insert cell
Insert cell
xAxis3 = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x0).tickSizeOuter(0))
.call(g => g.select(".domain").remove())
Insert cell
Insert cell
color = d3
.scaleOrdinal()
.range([
"#98abc5",
"#8a89a6",
"#7b6888",
"#6b486b",
"#a05d56",
"#d0743c",
"#ff8c00"
])
Insert cell
x0 = d3.scaleBand()
.domain(joined_data3.map(d => d[groupKey]))
.rangeRound([margin.left, width - margin.right])
.paddingInner(0.1)
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