Unlisted
Edited
Jun 20, 2024
Insert cell
Insert cell
Insert cell
i = 0
Insert cell
Insert cell
name = "test";
Insert cell
xScale = d3.scaleLinear()
.domain(d3.extent(faoData, (d) => d.Value)) // Set domain to 0-1 for relative scale
.range([0, width]); // Adjust width based on your plot dimensions
Insert cell
faoData = faoprojections2050median.filter(function(d) {
if (d.Year === year[i] && d.Item == "Raising of pigs") {
return d;
}
})
Insert cell
FAOProjections2050Median@1.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
data = FileAttachment("population-state-age.csv").csv({typed: true})
Insert cell
{
await Promises.delay(5000);
do {
const newValue = Math.floor(Math.random() * 4);
console.log(newValue);
const faoData = faoprojections2050median.filter(function(d) {
if (d.Year === year[newValue] && d.Item == "Raising of pigs") {
return d;
}
});
yield faoData;
await barchart.update(faoData).end();
await Promises.delay(1300);
} while (true);
}
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