Hi,
I've added labels inside a custom switch node I wrote. The problem is that when I edit de node the redraw function does not call an annonymous function to get the new labels texts.
I'm new to the enter(),append(),exit() paradigm, so I'm a bit lost!
Here is my code:
var output_group = d._ports.enter().append("g").attr("class","port_output");
output_group.append("rect").attr("class","port").attr("rx",3).attr("ry",3).attr("width",10).attr("height",10)
.on("mousedown",(function(){var node = d; return function(d,i){portMouseDown(node,PORT_TYPE_OUTPUT,i);}})() )
.on("touchstart",(function(){var node = d; return function(d,i){portMouseDown(node,PORT_TYPE_OUTPUT,i);}})() )
.on("mouseup",(function(){var node = d; return function(d,i){portMouseUp(node,PORT_TYPE_OUTPUT,i);}})() )
.on("touchend",(function(){var node = d; return function(d,i){portMouseUp(node,PORT_TYPE_OUTPUT,i);}})() )
.on("mouseover",(function(){var node = d; return function(d,i){portMouseOver(d3.select(this),node,PORT_TYPE_OUTPUT,i);}})())
.on("mouseout",(function(){var node = d; return function(d,i) {portMouseOut(d3.select(this),node,PORT_TYPE_OUTPUT,i);}})());`
// NxC Add label nos outputs
if(d.type == "Pergunta") {
output_group.append("svg:text").attr("class", "outport_label").attr("x", -8).attr("y", 5)
.style("font-size","10px").style("stroke", "#000").style("stroke-width", "0")
.text(function(idx) {
return d.rules[idx].v;
});
}
The function in bold only gets called on the 1st redraw() call, not on the next ones.
Any ideas?
Thanks!