Merge pull request #12 from mikaa123/master
Edge label support in springyui
This commit is contained in:
commit
771dcd24fb
|
@ -16,7 +16,7 @@ var monty = graph.newNode({label: 'Monty'});
|
||||||
var james = graph.newNode({label: 'James'});
|
var james = graph.newNode({label: 'James'});
|
||||||
var bianca = graph.newNode({label: 'Bianca'});
|
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, dennis, {color: '#6A4A3C'});
|
||||||
graph.newEdge(michael, jessica, {color: '#CC333F'});
|
graph.newEdge(michael, jessica, {color: '#CC333F'});
|
||||||
graph.newEdge(jessica, barbara, {color: '#EB6841'});
|
graph.newEdge(jessica, barbara, {color: '#EB6841'});
|
||||||
|
|
14
springyui.js
14
springyui.js
|
@ -218,6 +218,20 @@ jQuery.fn.springy = function(params) {
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
ctx.restore();
|
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) {
|
function drawNode(node, p) {
|
||||||
var s = toScreen(p);
|
var s = toScreen(p);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user