Public
Edited
Oct 25, 2022
Insert cell
Insert cell
d3
Insert cell
rawdata = [{"Country of origin (ISO)":"AFG","Country of asylum":"Austria","Country of asylum (ISO)":"AUT","Percent from AFG":"7.17%","Percent Recognized":"7.07%","Percent Protected":"5.86%","Percent Rejected":"5.61%","Percent Closed":"8.80%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Belgium","Country of asylum (ISO)":"BEL","Percent from AFG":"1.83%","Percent Recognized":"2.24%","Percent Protected":"1.20%","Percent Rejected":"6.15%","Percent Closed":"0.00%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Bulgaria","Country of asylum (ISO)":"BGR","Percent from AFG":"2.29%","Percent Recognized":"0.14%","Percent Protected":"0.11%","Percent Rejected":"0.17%","Percent Closed":"6.47%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Croatia","Country of asylum (ISO)":"HRV","Percent from AFG":"1.22%","Percent Recognized":"0.11%","Percent Protected":"0.00%","Percent Rejected":"0.03%","Percent Closed":"3.47%"},{"Country of origin (ISO)":"AFG","Country of asylum":"France","Country of asylum (ISO)":"FRA","Percent from AFG":"16.16%","Percent Recognized":"15.34%","Percent Protected":"32.71%","Percent Rejected":"28.18%","Percent Closed":"0.47%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Germany","Country of asylum (ISO)":"DEU","Percent from AFG":"20.36%","Percent Recognized":"7.03%","Percent Protected":"32.51%","Percent Rejected":"16.73%","Percent Closed":"24.78%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Greece","Country of asylum (ISO)":"GRC","Percent from AFG":"14.93%","Percent Recognized":"12.42%","Percent Protected":"12.41%","Percent Rejected":"11.76%","Percent Closed":"20.08%"},{"Country of origin (ISO)":"AFG","Country of asylum":"India","Country of asylum (ISO)":"IND","Percent from AFG":"1.67%","Percent Recognized":"4.32%","Percent Protected":"0.00%","Percent Rejected":"0.90%","Percent Closed":"0.95%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Italy","Country of asylum (ISO)":"ITA","Percent from AFG":"3.31%","Percent Recognized":"5.64%","Percent Protected":"7.21%","Percent Rejected":"0.54%","Percent Closed":"0.00%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Netherlands","Country of asylum (ISO)":"NLD","Percent from AFG":"2.21%","Percent Recognized":"6.46%","Percent Protected":"1.06%","Percent Rejected":"0.42%","Percent Closed":"0.27%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Poland","Country of asylum (ISO)":"POL","Percent from AFG":"1.03%","Percent Recognized":"2.07%","Percent Protected":"0.02%","Percent Rejected":"0.27%","Percent Closed":"1.20%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Romania","Country of asylum (ISO)":"ROU","Percent from AFG":"3.27%","Percent Recognized":"0.45%","Percent Protected":"0.05%","Percent Rejected":"4.15%","Percent Closed":"7.37%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Slovenia","Country of asylum (ISO)":"SVN","Percent from AFG":"1.84%","Percent Recognized":"0.01%","Percent Protected":"0.00%","Percent Rejected":"0.05%","Percent Closed":"5.37%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Spain","Country of asylum (ISO)":"ESP","Percent from AFG":"0.57%","Percent Recognized":"1.94%","Percent Protected":"0.13%","Percent Rejected":"0.00%","Percent Closed":"0.00%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Sweden","Country of asylum (ISO)":"SWE","Percent from AFG":"0.51%","Percent Recognized":"0.19%","Percent Protected":"0.02%","Percent Rejected":"2.41%","Percent Closed":"0.26%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Switzerland","Country of asylum (ISO)":"CHE","Percent from AFG":"2.13%","Percent Recognized":"1.23%","Percent Protected":"5.16%","Percent Rejected":"0.26%","Percent Closed":"1.67%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Türkiye","Country of asylum (ISO)":"TUR","Percent from AFG":"10.80%","Percent Recognized":"11.95%","Percent Protected":"0.00%","Percent Rejected":"14.60%","Percent Closed":"15.43%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Tajikistan","Country of asylum (ISO)":"TJK","Percent from AFG":"2.89%","Percent Recognized":"10.12%","Percent Protected":"0.00%","Percent Rejected":"0.31%","Percent Closed":"0.00%"},{"Country of origin (ISO)":"AFG","Country of asylum":"United Kingdom of Great Britain and Northern Ireland","Country of asylum (ISO)":"GBR","Percent from AFG":"0.81%","Percent Recognized":"2.18%","Percent Protected":"0.11%","Percent Rejected":"0.89%","Percent Closed":"0.12%"},{"Country of origin (ISO)":"AFG","Country of asylum":"Other","Country of asylum (ISO)":"OTH","Percent from AFG":"4.99%","Percent Recognized":"9.07%","Percent Protected":"1.45%","Percent Rejected":"6.56%","Percent Closed":"3.31%"}]
Insert cell
Insert cell
function getNodes(array){
let nodes = []

for(let i=0; i<array.length; i++){
let newNode = {}

//newNode.nodeNum = i
newNode.nodeName = array[i]['Country of asylum']
nodes.push(newNode)
}

nodes.push(
{nodeName: "Afghanistan"},
{nodeName: "Recognized"},
{nodeName: "Protected"},
{nodeName: "Rejected"},
{nodeName: "Closed"})

nodes = getUniqueListBy(nodes, 'nodeName')
return nodes
}
Insert cell
nodes = getNodes(rawdata)
Insert cell
function getUniqueListBy(arr, key) {
return [...new Map(arr.map(item => [item[key], item])).values()]
}
Insert cell
Insert cell
linksWave1 = getLinks_wave1(rawdata)
Insert cell
Insert cell
linksRecognized = getLinks_Rec(rawdata)
Insert cell
Insert cell
linksProtected = getLinks_Pro(rawdata)
Insert cell
Insert cell
linksRejected = getLinks_Rej(rawdata)
Insert cell
Insert cell
linksClosed = getLinks_Clo(rawdata)
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