From f6655c001482f8ac25683c344c08567c604f6e9e Mon Sep 17 00:00:00 2001 From: jos Date: Fri, 10 Oct 2014 10:50:43 +0200 Subject: [PATCH] Fix in positioning of text label of node --- lib/network/Node.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/network/Node.js b/lib/network/Node.js index a1fe8704..e70ec7e1 100644 --- a/lib/network/Node.js +++ b/lib/network/Node.js @@ -878,7 +878,7 @@ Node.prototype._label = function (ctx, text, x, y, align, baseline, labelUnderNo var lines = text.split('\n'); var lineCount = lines.length; - var fontSize = (Number(this.options.fontSize) + 4); + var fontSize = (Number(this.options.fontSize) + 4); // TODO: why is this +4 ? var yLine = y + (1 - lineCount) / 2 * fontSize; if (labelUnderNode == true) { yLine = y + (1 - lineCount) / (2 * fontSize); @@ -893,7 +893,7 @@ Node.prototype._label = function (ctx, text, x, y, align, baseline, labelUnderNo var height = this.options.fontSize * lineCount; var left = x - width / 2; var top = y - height / 2; - if (ctx.textBaseline == "top") { + if (baseline == "top") { top += 0.5 * fontSize; } this.labelDimensions = {top:top,left:left,width:width,height:height,yLine:yLine};