femaleSendersChart = {
const width = 800;
const height = 600;
const femaleNodes = nodes.filter(d => d.gender === "female");
const femaleLinks = links.filter(d =>
femaleNodes.some(node => node.id === d.source.id)
);
const femaleSvg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.attr("width", width)
.attr("height", height)
.call(
d3.zoom()
.scaleExtent([0.05, 5000000000])
.on("zoom", (event) => {
femaleG.attr("transform", event.transform);
})
);
const femaleG = femaleSvg.append("g");
const femaleWeightScale = d3.scaleLog()
.domain(d3.extent(femaleLinks, d => d.weight))
.range([0.5, 5]);
const femaleSimulation = d3.forceSimulation(femaleNodes)
.force("link", d3.forceLink(femaleLinks).id(d => d.id).distance(100))
.force("charge", d3.forceManyBody().strength(-300))
.force("center", d3.forceCenter(width / 2, height / 2));
// Add arrow markers
femaleSvg.append("defs").append("marker")
.attr("id", "female-arrow")
.attr("viewBox", "0 -5 10 10")
.attr("refX", 15)
.attr("refY", 0)
.attr("markerWidth", 5)
.attr("markerHeight", 5)
.attr("orient", "auto")
.append("path")
.attr("d", "M0,-5L10,0L0,5")
.attr("fill", "#999");
// Add links
const femaleLink = femaleG.append("g")
.attr("stroke", "#999")
.attr("stroke-opacity", 0.6)
.selectAll("line")
.data(femaleLinks)
.join("line")
.attr("stroke-width", d => femaleWeightScale(d.weight))
.attr("marker-end", "url(#female-arrow)"); // Add arrows
// Add nodes (only female)
const femaleNode = femaleG.append("g")
.attr("stroke", "#fff")
.attr("stroke-width", 1.5)
.selectAll("circle")
.data(femaleNodes)
.join("circle")
.attr("r", 5)
.attr("fill", "#ADD8E6") // Light Blue for female
.call(d3.drag()
.on("start", (event, d) => {
if (!event.active) femaleSimulation.alphaTarget(0.3).restart();
d.fx = d.x;
d.fy = d.y;
})
.on("drag", (event, d) => {
d.fx = event.x;
d.fy = event.y;
})
.on("end", (event, d) => {
if (!event.active) femaleSimulation.alphaTarget(0);
d.fx = null;
d.fy = null;
})
);
// Titles for hover
femaleNode.append("title")
.text(d => d.id);
// Update positions dynamically
femaleSimulation.on("tick", () => {
femaleLink
.attr("x1", d => d.source.x)
.attr("y1", d => d.source.y)
.attr("x2", d => d.target.x)
.attr("y2", d => d.target.y);
femaleNode
.attr("cx", d => d.x)
.attr("cy", d => d.y);
});
return femaleSvg.node();
}