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 // label
ctx.textAlign = "center";
ctx.textBaseline = "top"; if (text = typeof(edge.data.label) !== 'undefined') {
ctx.font = "10px Helvetica, sans-serif"; ctx.save();
ctx.fillStyle = "#5BA6EC"; ctx.textAlign = "center";
var text = typeof(edge.data.label) !== 'undefined' ? edge.data.label : ''; ctx.textBaseline = "top";
ctx.fillText(text, (x1+x2)/2, (y1+y2)/2); ctx.font = "10px Helvetica, sans-serif";
ctx.restore(); 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);