chart= {
const svg= d3.create("svg")
.attr("viewBox", ([0, 0, width , height + 80]));
const grouping= svg.append("g");
grouping.append("path")
.join("path")
.attr("transform", `translate(${ margin.left }, ${ margin.height - 20})`)
.attr("d", path(land))
.attr("fill", "#E8E8E8")
.attr("stroke", "#000")
.attr("stroke-width", 0.25);
grouping.append("path")
.join("path")
.attr("d", path(borders))
.attr("fill", "none")
.attr("stroke", "black")
.attr("stroke-width", 0.15);
grouping.append("path")
.join("path")
.attr("d", path(graticule))
.attr("stroke", "#ccc")
.attr("fill", "none")
.attr("stroke-width", 0.75);
const colorBar = svg.append("g")
.attr("transform", `translate( ${width - 950}, ${ height})`);
var segmentWidth = 40;
var segmentHeight = 20;
var segments = 18;
var segmentColors = [];
for (var i = -9; i <= 9; i++) {
segmentColors.push(colorScale(i));
}
colorBar.selectAll("rect")
.data(segmentColors)
.enter()
.append("rect")
.attr("x", function(d, i) {
return i * segmentWidth;
})
.attr("y", 0)
.attr("width", segmentWidth)
.attr("height", segmentHeight)
.attr("fill", function(d) {
return d;
});
colorBar.selectAll("text")
.data(segmentColors)
.enter()
.append("text")
.attr("x", function(d, i) {
return i * segmentWidth;
})
.attr("y", segmentHeight + 15)
.text(function(d, i) {
var value = i - 9;
return value;
})
svg.selectAll("circle")
.data(select_data.slice(0, maxNum))
.join('circle')
.attr('cx', d => projection([ d.x, d.y])[0])
.attr('cy', d => projection([ d.x, d.y])[1])
.attr('fill', d=> colorXco2( d.mean_xco2_anomaly))
.attr('r', 0.35)
.transition()
return svg.node();
}