Public
Edited
Dec 18, 2023
2 forks
Importers
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
dataSim2 = ({
iterations: d3.range(78).map((d, i) => {
return {
label: "Year " + (2023 + i) + ""
};
}),
values: dataCombined2.map((d) => {
const result = {
name: d.gname,
history: [d.pvalue]
};

d3.range(78 - 1).forEach((_) => {
const perc = 1 + d.gvalue / 100;
const last = result.history[result.history.length - 1];
console.log(perc, last);
result.history.push(last * perc);
});

return result;
})
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataGDP = load(
"https://cadasa.github.io/API_NY.GDP.MKTP.CD_DS2_en_csv_v2_6011335.csv"
)
Insert cell
dataGDPLastYear2 = dataGDP
.map((d) => {
return {
name: d["Country Name"],
value: +d["2022"],
history: d3.range(1960, 2023).map((v) => +d[v]),
filtered: d3
.range(1960, 2023)
.map((v) => +d[v])
.filter((d) => d)
};
})
.filter((d) => d.history.length != d.filtered.lenth)
Insert cell
dataGDPLastYear = dataGDP
.map((d) => {
return {
name: d["Country Name"],
value: +d["2022"],
history: d3.range(1995, 2023).map((v) => +d[v]),
filtered: d3
.range(1995, 2023)
.map((v) => +d[v])
.filter((d) => d)
};
})
.filter((d) => d.history.length != d.filtered.lenth)
Insert cell
dataGrowth = load(
"https://cadasa.github.io/API_NY.GDP.MKTP.KD.ZG_DS2_en_csv_v2_5994650.csv"
)
Insert cell
dataGrowthAveraged = dataGrowth.map((d) => ({
name: d["Country Name"],
value: d3.mean([+d["2022"], +d["2021"], +d["2020"], +d["2019"], +d["2018"]])
}))
Insert cell
Insert cell
dataGrowthAveragedSorted2 = dataGrowthAveraged2
.slice()
.sort((a, b) => (a.value < b.value ? 1 : -1))
Insert cell
dataGrowthAveraged2 = dataGrowth.map((d) => ({
name: d["Country Name"],
value: d3.mean([+d["2022"], +d["2021"]])
}))
Insert cell
dataGrowthAveragedSorted2.filter((d) => d.name === "Viet Nam")
Insert cell
Insert cell
dataCombined = dataGrowthAveraged.map((d,i)=>({gname:d.name,gvalue:d.value,
pname:dataGDPLastYear[i].name,
pvalue:dataGDPLastYear[i].value,
history:dataGDPLastYear[i].history}))
Insert cell
dataCombined2 = dataGrowthAveraged.map((d, i) => ({
gname: d.name,
gvalue: d.value,
pname: dataGDPLastYear2[i].name,
pvalue: dataGDPLastYear2[i].value,
history: dataGDPLastYear2[i].history
}))
Insert cell
Insert cell
dataCombinedSorted = dataCombined
.slice()
.filter(d=>!filteredGroups.includes(d.gname))
.filter(d=>d.gname.indexOf('IBRD')==-1)
.sort((a,b)=>a.pvalue<b.pvalue?1:-1)
.filter(d=>d.pvalue)
.filter(d=>d.gvalue<10)
Insert cell
dataCombinedSortedPast = dataCombinedSorted.slice().sort((a,b)=>a.history[0]<b.history[0]?1:-1)
Insert cell
Insert cell
Insert cell
d3 = require('d3@v5')
Insert cell
import {load} from "@bumbeishvili/fetcher"
Insert cell
import {text} from "@jashkenas/inputs"
Insert cell
import {comments} from "@bumbeishvili/utils"
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