chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round");
svg.append("path")
.datum(siroedd_cymru_mesh)
.attr("fill", "none")
.attr("stroke", "#ccc")
.attr("d", path);
const sir = svg.append("g")
.attr("stroke", "#000")
.selectAll("path")
.data(topojson.feature(siroedd_cymru,siroedd_cymru.objects.siroedd_cymru).features.filter(d => data.has(d.properties.CTYUA21CD)))
.join("path")
.attr("vector-effect", "non-scaling-stroke")
.attr("d", path)
.attr("fill", d => color(data.get(d.properties.CTYUA21CD).siaradwyr))
.attr("transform", d => transform(d));
sir.append("title")
.text(d => `${d.properties.CTYUA21NMW}
${format(data.get(d.properties.CTYUA21NMW))}`);
return Object.assign(svg.node(), {
update(year) {
sir.transition()
.duration(750)
.attr("fill", d => color(data.get(d.properties.CTYUA21NMW)))
.attr("transform", d => transform(d,year));
}});
};