arbor
arbor copied to clipboard
Add label to edges
The visualization looks great and I really like the simplicity of specifying the graph. What is really missing for me is the ability to add label to edges.
+1, also to be able to handle events on links would be good too!
I added edge labels to a graph based on halfviz with little difficulty. http://podcrazy.net/_meta/state-transition-map
Just add a label attribute to your edges and add this code to the end of particleSystem.eachEdge() in Renderer.redraw().
var label = edge.data.label ? $.trim(edge.data.label) : '';
if (label != '' && ctx){
mid_x = (tail.x+head.x)/2;
mid_y = (tail.y+head.y)/2;
ctx.save();
ctx.font = "1.1em Arial";
ctx.textAlign = "center";
ctx.lineWidth = 4;
ctx.strokeStyle = 'rgba(255,255,255,1)';
ctx.strokeText(label, mid_x, mid_y);
ctx.fillStyle = "black";
ctx.fillText(label, mid_x, mid_y);
ctx.restore();
}