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);
}