Adding edge label support in springyui
This commit is contained in:
parent
da536e5a0f
commit
bbfcf99b72
|
@ -16,7 +16,7 @@ var monty = graph.newNode({label: 'Monty'});
|
|||
var james = graph.newNode({label: 'James'});
|
||||
var bianca = graph.newNode({label: 'Bianca'});
|
||||
|
||||
graph.newEdge(dennis, michael, {color: '#00A0B0'});
|
||||
graph.newEdge(dennis, michael, {color: '#00A0B0', label: 'Foo bar'});
|
||||
graph.newEdge(michael, dennis, {color: '#6A4A3C'});
|
||||
graph.newEdge(michael, jessica, {color: '#CC333F'});
|
||||
graph.newEdge(jessica, barbara, {color: '#EB6841'});
|
||||
|
|
|
@ -218,6 +218,15 @@ jQuery.fn.springy = function(params) {
|
|||
ctx.fill();
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// label
|
||||
ctx.textAlign = "center";
|
||||
ctx.textBaseline = "top";
|
||||
ctx.font = "10px Helvetica, sans-serif";
|
||||
ctx.fillStyle = "#5BA6EC";
|
||||
var text = typeof(edge.data.label) !== 'undefined' ? edge.data.label : '';
|
||||
ctx.fillText(text, (x1+x2)/2, (y1+y2)/2);
|
||||
ctx.restore();
|
||||
},
|
||||
function drawNode(node, p) {
|
||||
var s = toScreen(p);
|
||||
|
|
Loading…
Reference in New Issue
Block a user