0
간단한 "플러그 앤 플레이"맵 템플리트를 만들려고합니다. 사용자가 지오이드 및 값이있는 CSV 파일을 넣은 다음 값을 choropleth로 볼 수 있습니다.D3/JS에서 두 개의 데이터 세트 병합
다른 옵션이있는 경우 지금은 두 개의 데이터 세트 (지도 및 값) 더블 루프를 사용하여 병합하지만 궁금 :
이 코드 덩어리가 지리 (fresh_ctss를)로드하는 함수 내에서 유지:
d3.csv("data/communities_pop.csv", function(error, comms)
{
csv = comms.map(function(d)
{
//each d is one line of the csv file represented as a json object
// console.log("Label: " + d.CTLabel)
return {"community": d.community, "population" :d.population,"label": d.tract} ;
})
csv.forEach(function(d, i) {
fresh_ctss.forEach(function(e, j) {
if (d.label === e.properties.geoid) {
e.properties.community = parseInt(d.community)
e.properties.population = parseInt(d.population)
}
})
})