Refactoring edge labels' code

This commit is contained in:
Michael Sokol 2012-03-23 12:13:24 +01:00
parent bbfcf99b72
commit cd89680700

View File

@ -220,13 +220,17 @@ jQuery.fn.springy = function(params) {
}
// 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();
if (text = typeof(edge.data.label) !== 'undefined') {
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);