viewof countrySelected = {
let svg = d3.select(DOM.svg(width, height));
let value = null;
let active = d3.select(null);
var centered;
let g = svg.append("g");
var countries = topojson.feature(world_topo110, world_topo110.objects.ne_110m_admin_0_countries).features
var title = svg.append("text")
.attr("x", width / 2 -500)
.attr("y", height * 3 / 5 -10);
var flag = svg.append("image")
.attr("width", 150)
.attr("height", 75)
.attr("x", width / 2 -500)
.attr("y", height * 3 / 5 + 3)
.attr("preserveAspectRatio", "none")
const outline = svg.append("path")
.attr("stroke", "green")
.attr("stroke-width", "0.1px")
.attr("stroke-linejoin", "round")
.attr("fill", "green")
.attr("pointer-events", "none");
const outlineClick = svg.append("path")
.attr("fill", "red")
.attr("stroke","red")
.attr("stroke-width", "0.1px")
.attr("stroke-linejoin", "round")
.attr("pointer-events","none")
svg.selectAll(".country")
.data(countries)
.enter().insert("path", ".graticule")
.attr("class", function(d) { return "country " + "code" + d.id; })
.attr("d", geoPath)
.attr("opacity","0.5")
.style("fill", "black")
.on("click", d => {
const node = svg.node();
node.value = value = value === d.properties.ADMIN ? null : d.properties.ADMIN;
node.dispatchEvent(new CustomEvent("input"));
outlineClick.attr("d", value ? geoPath(d) : null);
title.text(d.properties.ADMIN);
let forGraph = rerun_sorted.filter(p => p.name == d.properties.ADMIN)[0].name
let forGraph_url = rerun_sorted.filter(p => p.name == d.properties.ADMIN)[0].url
console.log(forGraph_url)
flag.attr("xlink:href", forGraph_url);
});
function clicked(d) {
var x, y, k;
if (d && centered !== d) {
var centroid = geoPath.centroid(d);
x = centroid[0];
y = centroid[1];
k = 4;
centered = d;
} else {
x = width / 2;
y = height / 2;
k = 1;
centered = null;
}
}
;
svg.append("g");
return Object.assign(svg.node(), {value: null});
}