chart = {
let svg = d3.select(DOM.svg(width, height));
let value = null;
let g = svg.append("g");
var zoom = d3.zoom().on("zoom", zoomed);
svg
.call(zoom);
const context = DOM.context2d(width, height);
const path = d3.geoPath(projection, context);
var countries = topojson.feature(world, world.objects.ne_110m_admin_0_countries).features
const outlineClick = svg.append("path")
.attr("fill", "red")
.attr("stroke","red")
.attr("stroke-width", "0.1px")
.attr("stroke-linejoin", "round")
.attr("pointer-events","none")
function render() {
context.clearRect(0, 0, width, height);
context.beginPath(), path(sphere), context.fillStyle = "#fff", context.fill();
context.beginPath(), path(land), context.fillStyle = "#000", context.fill();
context.beginPath(), path(land), context.strokeStyle = "#f00000", context.stroke();
context.beginPath(), path(sphere), context.stroke();
}
function zoomed() {
g.style("stroke-width", 1.5 / d3.event.transform.k + "px");
g.attr("transform", d3.event.transform);
}
svg.selectAll(".country")
.data(countries)
.enter().insert("path", ".graticule")
.attr("class", function(d) { return "country " + "code" + d.id; })
.attr("d", path)
.attr("opacity","0.5")
.style("fill", "yellow")
.on("mouseover", d => {
console.log("moused over country");
const node = svg.node();
node.value = value = value === d.properties.ADMIN ? null : d.properties.ADMIN;
node.dispatchEvent(new CustomEvent("input"));
outlineClick.attr("d", value ? path(d) : null);
})
return d3.select(context.canvas)
.call(drag(projection).on("drag.render", render))
.call(render)
.node();
}