How to add text to arbor?

251 views Asked by At

I am really new to jquery and arbour. Can anyone tell me really simply what the code is to add text to a node in arbor, and where I put the code? For example if had this;

sys.addEdge('a','b', {length:.75, pointSize:3, label:"hello"})
    sys.addEdge('a','c')
    sys.addEdge('a','d')
    sys.addEdge('a','e')
    sys.addEdge('a','g')
    sys.addEdge('g','h')
    sys.addNode('f', {alone:true, mass:.25})

thanks :)

2

There are 2 answers

0
mini.1601 On

You have just specified the edges of the graph and not the nodes. You need to specify the nodes and add their names in the label property like:

var dog = sys.addNode('dog',{'color':'green','shape':'dot','label':'dog'});
var cat = sys.addNode('cat',{'color':'blue','shape':'dot','label':'cat'});

Here, the label stores the name of the node to be displayed on the graph.

1
pradip_PRP On

try this

var ctx = canvas.getContext("2d");
var label = node.data.title
                    if (!(label || "").match(/^[ \t]*$/)) {
                        pt.x = Math.floor(pt.x)
                        pt.y = Math.floor(pt.y)
                    } else {
                        label = null
                    }


// draw the text
                    if (label) {
                        ctx.font = "bold 11px Arial"
                        ctx.textAlign = "center"
                        ctx.fillStyle = node.data.fontcolor;
                        ctx.fillText(label || "", pt.x, pt.y + 4)
                    }