function render(source) {
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, width, height])
.style("width", "100%")
.style("height", "auto");
var path = d3.geoPath().projection(projection);
svg
.append("defs")
.append("pattern")
.attr("id", "diagonalHatch")
.attr("patternUnits", "userSpaceOnUse")
.attr("width", 4)
.attr("height", 4)
.append("path")
.attr("d", "M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2")
.attr("stroke", "#000000")
.attr("stroke-width", 1);
svg
.selectAll("path")
.data(countries.features)
.enter()
.append("path")
.attr("d", path)
.style("fill", (d, i) => {
alert(d);
let unreach = _.find(source, {
two: d.properties.ISO2,
reachable: false
});
if (unreach) return "url(#diagonalHatch)";
let match = _.find(source, {
two: d.properties.ISO2,
available: true
});
return match ? "#d0ff8a" : "#ffbe6f";
})
.style("stroke", "#dc8add")
.attr("stroke-width", 0.5);
return svg.node();
}