graphe_animation = {
const div = d3.create("div")
const select = div.append("select").style("position", "absolute").style("top", 0 + "px")
select.append("option").attr("value", "effectif").text("Effectif")
select.append("option").attr("value", "pourcentage").text("Pourcentage")
const svg = div.append("svg")
.attr("viewBox", [-width / 2, -height / 2, width, height]);
const angles = calcul_angle(data);
svg.append("g")
.attr("stroke", "white")
.selectAll("path")
.data(angles)
.join("path")
.attr("fill", d => color(d.data.name))
.attr("d", arc)
let texte = svg.append("g")
.attr("font-family", "sans-serif")
.attr("font-size", 12)
.attr("text-anchor", "middle")
select.on("update", function(){
let variable = d3.select(this).property('value')
let valeur = 0
if(variable == "effectif"){
valeur = angles.data.value.toLocaleString()
} else if(variable == "pourcentage") {
const effectif_total = d3.sum(data.map(d => d.value))
valeur = (angles.data.value/effectif_total).toLocaleString()
}
texte.selectAll("text")
.data(angles)
.join("text")
.attr("transform", d => `translate(${arcLabel.centroid(d)})`)
.call(text => text.append("tspan")
.attr("y", "-0.4em")
.attr("font-weight", "bold")
.text(d => d.data.name))
.call(text => text.filter(d => (d.endAngle - d.startAngle) > 0.25).append("tspan")
.attr("x", 0)
.attr("y", "0.7em")
.attr("fill-opacity", 0.7)
.text(d => valeur))
})
return div.node()
}