{
const svg = d3.select(DOM.svg(width, height))
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom);
var labels = svg.append('g').attr('class', 'labels');
labels.selectAll('.label')
.data(geojson.features)
.enter()
.append('text')
.attr("class", "label")
.attr('transform', function(d) {
return "translate(" + path.centroid(d) + ")";
})
.attr("id", (d => d.properties.nom))
.style('text-anchor', 'middle')
.style('font-size', 10)
.style('fill', 'steelblue')
.style('font-family', 'sans-serif')
.text(d => d.properties.nom);
svg.selectAll("path")
.data(geojson.features)
.enter().append("path")
.attr("d", path)
.attr('fill', 'white')
.attr('stroke', '#333')
.on("mouseover", handleMouseOver)
.on("mouseout", handleMouseOut);
function handleMouseOver(d, i){
d3.select(this)
.style('fill', 'black');
d3.select('#'+d.properties.nom)
.style('font-weight', 'bold')
.style('font-size', 10);
}
function handleMouseOut(d,i){
d3.select(this)
.style('fill', 'white');
d3.select('#'+d.properties.nom)
.style('font-weight', 'normal')
.style('font-size', 8)
}
svg.selectAll('g').raise();
return svg.node();
}