From 9587e9a79c19ba92c54732337f47beb6c349ed2c Mon Sep 17 00:00:00 2001 From: Javier Rey Date: Sat, 12 Apr 2014 21:51:02 -0300 Subject: [PATCH] Edges fontFill customization --- docs/graph.html | 8 ++++++++ src/graph/Edge.js | 4 +++- src/graph/Graph.js | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/graph.html b/docs/graph.html index 97766870..eeae6c8d 100644 --- a/docs/graph.html +++ b/docs/graph.html @@ -573,6 +573,14 @@ var edges = [ Only applicable when property label is defined. + + fontFill + string + no + Font fill for the background color of the text label of the edge. + Only applicable when property label is defined. + + from Number | String diff --git a/src/graph/Edge.js b/src/graph/Edge.js index e92e9d7e..66065162 100644 --- a/src/graph/Edge.js +++ b/src/graph/Edge.js @@ -81,10 +81,12 @@ Edge.prototype.setProperties = function(properties, constants) { this.fontSize = constants.edges.fontSize; this.fontFace = constants.edges.fontFace; this.fontColor = constants.edges.fontColor; + this.fontFill = constants.edges.fontFill; if (properties.fontColor !== undefined) {this.fontColor = properties.fontColor;} if (properties.fontSize !== undefined) {this.fontSize = properties.fontSize;} if (properties.fontFace !== undefined) {this.fontFace = properties.fontFace;} + if (properties.fontFill !== undefined) {this.fontFill = properties.fontFill;} } if (properties.title !== undefined) {this.title = properties.title;} @@ -348,7 +350,7 @@ Edge.prototype._label = function (ctx, text, x, y) { // TODO: cache the calculated size ctx.font = ((this.from.selected || this.to.selected) ? "bold " : "") + this.fontSize + "px " + this.fontFace; - ctx.fillStyle = 'white'; + ctx.fillStyle = this.fontFill; var width = ctx.measureText(text).width; var height = this.fontSize; var left = x - width / 2; diff --git a/src/graph/Graph.js b/src/graph/Graph.js index 3a330fd4..bfc23618 100644 --- a/src/graph/Graph.js +++ b/src/graph/Graph.js @@ -72,6 +72,7 @@ function Graph (container, data, options) { fontColor: '#343434', fontSize: 14, // px fontFace: 'arial', + fontFill: 'white', dash: { length: 10, gap: 5,