Public
Edited
Jul 20, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ports = FileAttachment("data.json").json()
Insert cell
d3.max(ports, x => x.value)
Insert cell
myprocessfunction = x => {
let a = x.toLowerCase();
return a;
}
Insert cell
data = ports.map(x => {
let a = {}
a.x = +x.year;
a.y = x.value;
a.country = myprocessfunction(x.country_of_registration)
return a;
});
Insert cell
filtered = data.filter(d => d.x === 2011 && ["russia", "iran", "india"].includes(d.country) && 100 > d.y > 0);
Insert cell
filtered.sort((a, b) => a.country < b.country).sort((a, b) => a.y < b.y);
Insert cell
data.map(x => x.country);
Insert cell
unique = [...d3.group(data, x=>x.country).keys()]
Insert cell
[...new Set(data.map(x=>x.country))]
Insert cell
[...d3.group(data, x=>x.country).entries()]
// .map(x=> {
// let a = {};
// a.country = x[0];
// a.value = d3.sum(x[1].map(x=> x.y));
// return a;
// })
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