chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.attr("transform", "translate(360,380)")
.append(() =>
legend({
color: linear,
title: data.title,
tickFormat: ".2f"
})
);
svg.append("g")
.selectAll("path")
.data(jamaica_features.features)
.join("path")
.attr("stroke", "black")
.attr("stroke-linejoin", "round")
.attr("fill", function(d){
var value = data.get(+d.properties.id)[0]
if(value == 0)
return "white"
else
return linear(data.get(+d.properties.id)[0])
})
.attr("d", path)
.append("title")
.text(function(d){
var value = data.get(+d.properties.id)[0]
if(value == 0)
return " Coefficient variation for " + data.get(+d.properties.id)[1]+" is unknown!"
})
return svg.node();
}