diff --git a/HISTORY.md b/HISTORY.md index 7e4e0fd8..5f00f0a8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -20,6 +20,7 @@ http://visjs.org - Added condition to Repulsion similar to BarnesHut to ensure nodes do not overlap. - Added labelAlignment option to edges. Thanks @T-rav! - Close active sessions in dataManipulation when calling setData(). +- Fixed alignment issue with edgelabels ### Timeline diff --git a/dist/vis.js b/dist/vis.js index 4f7680ae..afecc82a 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -28196,6 +28196,7 @@ return /******/ (function(modules) { // webpackBootstrap x = 0; yLine = 0; } + this._drawLabelRect(ctx); this._drawLabelText(ctx,x,yLine, lines, lineCount, fontSize); @@ -28244,7 +28245,6 @@ return /******/ (function(modules) { // webpackBootstrap ctx.fillRect(-this.labelDimensions.width * 0.5, lineMargin, this.labelDimensions.width, this.labelDimensions.height); } else { - ctx.fillStyle = this.options.fontFill; ctx.fillRect(this.labelDimensions.left, this.labelDimensions.top, this.labelDimensions.width, this.labelDimensions.height); } } @@ -28280,6 +28280,9 @@ return /******/ (function(modules) { // webpackBootstrap ctx.textBaseline = "middle"; } } + else { + ctx.textBaseline = "middle"; + } // check for strokeWidth if (this.options.fontStrokeWidth > 0){ diff --git a/lib/network/Edge.js b/lib/network/Edge.js index 4b2da4a3..4991fe1c 100644 --- a/lib/network/Edge.js +++ b/lib/network/Edge.js @@ -591,6 +591,7 @@ Edge.prototype._label = function (ctx, text, x, y) { x = 0; yLine = 0; } + this._drawLabelRect(ctx); this._drawLabelText(ctx,x,yLine, lines, lineCount, fontSize); @@ -639,7 +640,6 @@ Edge.prototype._drawLabelRect = function(ctx) { ctx.fillRect(-this.labelDimensions.width * 0.5, lineMargin, this.labelDimensions.width, this.labelDimensions.height); } else { - ctx.fillStyle = this.options.fontFill; ctx.fillRect(this.labelDimensions.left, this.labelDimensions.top, this.labelDimensions.width, this.labelDimensions.height); } } @@ -675,6 +675,9 @@ Edge.prototype._drawLabelText = function(ctx, x, yLine, lines, lineCount, fontSi ctx.textBaseline = "middle"; } } + else { + ctx.textBaseline = "middle"; + } // check for strokeWidth if (this.options.fontStrokeWidth > 0){