diagrama = {
const width = 1000;
const height = 1000;
const svg = d3.select(DOM.svg(width, height));
const data = [
{ name: 'Experiencias Profesionales', cx: 300, cy: 500, r: 250, color: '#ff9999' },
{ name: 'Intereses Personales', cx: 700, cy: 500, r: 250, color: '#99ccff' },
{ name: 'Situación Actual', cx: 500, cy: 300, r: 250, color: '#99ff99' },
{ name: 'Objetivos Futuros', cx: 500, cy: 700, r: 250, color: '#ffcc99' }
];
const tooltip = d3.select("body")
.append("div")
.style("position", "absolute")
.style("visibility", "hidden")
.style("background", "white")
.style("border", "1px solid #ccc")
.style("padding", "5px")
.style("border-radius", "5px")
.style("font-size", "12px");
svg.selectAll("circle")
.data(data)
.enter()
.append("circle")
.attr("cx", d => d.cx)
.attr("cy", d => d.cy)
.attr("r", d => d.r)
.style("fill", d => d.color)
.style("fill-opacity", 0.5)
.on("mouseover", function(event, d) {
tooltip.style("visibility", "visible").text(d.name);
d3.select(this).style("fill-opacity", 0.7);
})
.on("mousemove", function(event) {
tooltip.style("top", (event.pageY - 10) + "px").style("left", (event.pageX + 10) + "px");
})
.on("mouseout", function() {
tooltip.style("visibility", "hidden");
d3.select(this).style("fill-opacity", 0.5);
});
svg.selectAll("text")
.data(data)
.enter()
.append("text")
.attr("x", d => d.cx - 30)
.attr("y", d => d.cy + 30)
.attr("dy", ".35em")
.text(d => d.name)
.attr("text-anchor", "middle")
.style("fill", "#000")
.style("font-size", "14px");
svg.append("text")
.attr("x", 400)
.attr("y", 500)
.text("Posibilidades y limitaciones")
.attr("text-anchor", "middle")
.style("fill", "#000")
.style("font-size", "10px")
.call(wrap, 60);
svg.append("text")
.attr("x", 600)
.attr("y", 400)
.text("Lo que amas")
.attr("text-anchor", "middle")
.style("fill", "#000")
.style("font-size", "10px")
.call(wrap, 60);
svg.append("text")
.attr("x", 500)
.attr("y", 600)
.text("Recursos disponibles")
.attr("text-anchor", "middle")
.style("fill", "#000")
.style("font-size", "10px")
.call(wrap, 60);
svg.append("text")
.attr("x", 500)
.attr("y", 400)
.text("Impacto potencial")
.attr("text-anchor", "middle")
.style("fill", "#000")
.style("font-size", "10px")
.call(wrap, 60);
svg.append("text")
.attr("x", 500)
.attr("y", 500)
.text("Problema de Investigación")
.attr("text-anchor", "middle")
.style("fill", "#000")
.style("font-weight", "bold")
.style("font-size", "16px");
function wrap(text, width) {
text.each(function() {
var text = d3.select(this),
words = text.text().split(/\s+/).reverse(),
word,
line = [],
lineNumber = 0,
lineHeight = 1.1,
y = text.attr("y"),
dy = 0,
tspan = text.text(null).append("tspan").attr("x", text.attr("x")).attr("y", y).attr("dy", dy + "em");
while (word = words.pop()) {
line.push(word);
tspan.text(line.join(" "));
if (tspan.node().getComputedTextLength() > width) {
line.pop();
tspan.text(line.join(" "));
line = [word];
tspan = text.append("tspan").attr("x", text.attr("x")).attr("y", y).attr("dy", ++lineNumber * lineHeight + dy + "em").text(word);
}
}
});
}
return svg.node();
}