Merge pull request #12 from mikaa123/master

Edge label support in springyui
This commit is contained in:
Dennis Hotson 2012-03-23 18:02:23 -07:00
commit 771dcd24fb
2 changed files with 15 additions and 1 deletions

View File

@ -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'});

View File

@ -218,6 +218,20 @@ jQuery.fn.springy = function(params) {
ctx.fill();
ctx.restore();
}
// label
if (typeof(edge.data.label) !== 'undefined') {
text = edge.data.label
ctx.save();
ctx.textAlign = "center";
ctx.textBaseline = "top";
ctx.font = "10px Helvetica, sans-serif";
ctx.fillStyle = "#5BA6EC";
ctx.fillText(text, (x1+x2)/2, (y1+y2)/2);
ctx.restore();
}
},
function drawNode(node, p) {
var s = toScreen(p);