0
코드가 현재 정상적으로 작동하지만 clicky
함수를 사용하여 콘솔에 전송 된 객체에 이름을 지정하고 싶습니다. 콘솔은 Object {type: "MultiPolygon", coordinates: Array[1]}
을 반환하며 나중에 생성 된 동일한 이름으로 CSV 파일을 가져올 때 참조 할 수 있도록 변수 이름에 할당하려고합니다. 어떻게해야합니까?D3.js의 배열 객체에 변수 이름 지정
var northcentral = {
"47": 1, "37": 1, "45": 1, "13": 1
};
var northcentral_c = {
"25": 1, "09": 1, "44": 1, "50": 1, "33": 1, "23" :1
};
var svg = d3.select("svg");
var path = d3.geoPath();
var nc = [];
Array.prototype.push.apply(nc,us.objects.states.geometries.filter(function(d) { return d.id in northcentral; }))
Array.prototype.push.apply(nc,us.objects.counties.geometries.filter(function(d) { return d.id in northcentral_c; }))
svg.append("path")
.datum(topojson.merge(us, nc))
.attr("class", "state northcentral")
.attr("d", path)
.on("click", clicky);
function clicky(d){
console.log(d);
}