Published
Edited
Jun 29, 2018
3 stars
Also listed in…
3D
Vis.gl
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
deckgl = {
return new deck.DeckGL({
container,
map: mapboxgl,
mapStyle: 'https://free.tilehosting.com/styles/darkmatter/style.json?key=U0iNgiZKlYdwvgs9UPm1',
longitude: 20.66,
latitude: 45.5231,
zoom: 3,
pitch: 40,
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataColumns = dataStr.split('\n')
.filter(d=>d)
.map(d=>d.split(' '))
.filter((d,i)=>i<10)

Insert cell
Insert cell
emigrData = dataColumns.map((d,i)=>{
return Object.assign({
name:coords[i][2],
nameGe:d[0],
male:Number(d[2].replace(',','')),
female:Number(d[3].replace(',',''))
},{
coordinates:coords[i]
})
})
Insert cell
maxMale = Math.max.apply(Array,emigrData.map(d=>d.male))
Insert cell
maxFemale = Math.max.apply(Array,emigrData.map(d=>d.female))
Insert cell
Insert cell
restructuredData = emigrData.map(d=>{
return {
from:{"name":"Georgia",coordinates:[ 43.3569,42.3154]} ,
to:d
};
})
Insert cell
Insert cell
data = restructuredData.map(r=>{
var males = Array.from({length:r.to.male}).map(d=>Object.assign({disp:r.to.male,color:'#80C9FF'},r)) ;
var females = Array.from({length:r.to.female}).map(d=>Object.assign({disp:r.to.female,color:'#FFA7D4'},r));
return males.concat(females)

})
.reduce((a,b)=>a.concat(b))
.map(d=>{
var shuffled = shuffleIt(d.from.coordinates.slice(),1)
var shuffledTo = shuffleIt(d.to.coordinates.slice(),diff(d.disp))
return Object.assign({},
d,
{from:Object.assign({},d.from,{coordinates:shuffled})},
{to:Object.assign({},d.to,{coordinates:shuffledTo})}
)

})
Insert cell
Insert cell
shuffleIt([132.0218982355762, 27.101322670112367],1)
Insert cell
getColor({color:'red'})
Insert cell
function shuffleIt(coords,n){
return [coords[0]+Math.random()*n-n/2,coords[1]+Math.random()*n-n/2]
}
Insert cell
Insert cell
diff = function(n){
return n/maxMale * dispersion
}
Insert cell
function getColor(d){
var color = d3.rgb(d.color);
return [color.r,color.g,color.b]}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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