arbor icon indicating copy to clipboard operation
arbor copied to clipboard

Add label to edges

Open chilang opened this issue 13 years ago • 2 comments

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.

chilang avatar Jan 17 '11 22:01 chilang

+1, also to be able to handle events on links would be good too!

yee379 avatar Apr 17 '11 08:04 yee379

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();
      }

kevburnsjr avatar Jul 06 '11 07:07 kevburnsjr