From e17136a88d7e06f9bb032d45a01484f533ab9d9b Mon Sep 17 00:00:00 2001 From: wimrijnders Date: Sun, 30 Apr 2017 15:42:02 +0200 Subject: [PATCH] Fix placement label for dot shape (#3018) --- lib/network/modules/components/nodes/util/ShapeBase.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/network/modules/components/nodes/util/ShapeBase.js b/lib/network/modules/components/nodes/util/ShapeBase.js index c11dd4c8..646e36b5 100644 --- a/lib/network/modules/components/nodes/util/ShapeBase.js +++ b/lib/network/modules/components/nodes/util/ShapeBase.js @@ -47,7 +47,9 @@ class ShapeBase extends NodeBase { ctx.restore(); if (this.options.label !== undefined) { - let yLabel = y + 0.5 * this.height + 3; // the + 3 is to offset it a bit below the node. + // Need to call following here in order to ensure value for `this.labelModule.size.height` + this.labelModule.calculateLabelSize(ctx, selected, hover, x, y, 'hanging') + let yLabel = y + 0.5 * this.height + 0.5 * this.labelModule.size.height; this.labelModule.draw(ctx, x, yLabel, selected, hover, 'hanging'); } @@ -63,7 +65,7 @@ class ShapeBase extends NodeBase { if (this.options.label !== undefined && this.labelModule.size.width > 0) { this.boundingBox.left = Math.min(this.boundingBox.left, this.labelModule.size.left); this.boundingBox.right = Math.max(this.boundingBox.right, this.labelModule.size.left + this.labelModule.size.width); - this.boundingBox.bottom = Math.max(this.boundingBox.bottom, this.boundingBox.bottom + this.labelModule.size.height + 3); + this.boundingBox.bottom = Math.max(this.boundingBox.bottom, this.boundingBox.bottom + this.labelModule.size.height); } }