これがbl.ocksの私のd3.jsマップですhttp://bl.ocks.org/textplusdata/f64f54dd8c1a0b632ed5
未加工のバージョンでは、矢印キーまたは自動再生を使用して年データを循環させ、時間の経過に伴う変化を表示できます。
私の質問はこれです。年によって異なる世界の json ファイルを読み込むにはどうすればよいですか? 1991 年以前は旧ソ連が存在していましたが、データには現れていません。
私はすでに 2 つの json をアップロードしています。1 つは古いソビエト連邦を含み、もう 1 つは含まないものです。
// The map
var maptype;
if ( parseInt(year) < 1991) maptype = world_countriesold;
if ( parseInt(year) > 1991) maptype = world_countries;
var countries = d3.select("g#countries").empty() ?
chart.append("g").attr("id", "countries") : d3.select("g#countries"),
country = countries
.selectAll("path")
.data(maptype.features);
country
.enter()
.append("path")
.classed("country", true)
// changed { return d.id; } to { return d.ISO1AL3; } to look up 3-letter country code in c-shapes json
.attr("id", function(d,i) { return d.id; })
// changed { return d.properties.name; } to { return d.properties.CNTRY_NAME; } to return correct field in c-shapes json
.attr("title", function(d,i) { return d.properties.name; })
.attr("d", path);
「if」ステートメントを間違った場所に置いただけだと思いますが、トリガーを強制する方法がわかりません...