Browse Source

added gradients for edges

v3_develop
Alex de Mulder 9 years ago
parent
commit
403b0eb438
3 changed files with 27119 additions and 27042 deletions
  1. +27104
    -27035
      dist/vis.js
  2. +13
    -6
      lib/network/Edge.js
  3. +2
    -1
      lib/network/Network.js

+ 27104
- 27035
dist/vis.js
File diff suppressed because it is too large
View File


+ 13
- 6
lib/network/Edge.js View File

@ -79,7 +79,7 @@ Edge.prototype.setProperties = function(properties) {
var fields = ['style','fontSize','fontFace','fontColor','fontFill','fontStrokeWidth','fontStrokeColor','width', var fields = ['style','fontSize','fontFace','fontColor','fontFill','fontStrokeWidth','fontStrokeColor','width',
'widthSelectionMultiplier','hoverWidth','arrowScaleFactor','dash','inheritColor','labelAlignment', 'opacity', 'widthSelectionMultiplier','hoverWidth','arrowScaleFactor','dash','inheritColor','labelAlignment', 'opacity',
'customScalingFunction'
'customScalingFunction','useGradients'
]; ];
util.selectiveDeepExtend(fields, this.options, properties); util.selectiveDeepExtend(fields, this.options, properties);
@ -234,7 +234,7 @@ Edge.prototype.isOverlappingWith = function(obj) {
} }
}; };
Edge.prototype._getColor = function() {
Edge.prototype._getColor = function(ctx) {
var colorObj = this.options.color; var colorObj = this.options.color;
if (this.colorDirty === true) { if (this.colorDirty === true) {
if (this.options.inheritColor == "to") { if (this.options.inheritColor == "to") {
@ -255,6 +255,13 @@ Edge.prototype._getColor = function() {
this.colorDirty = false; this.colorDirty = false;
} }
if (this.options.useGradients == true) {
var grd = ctx.createLinearGradient(this.from.x, this.from.y, this.to.x, this.to.y);
grd.addColorStop(0, this.from.selected ? this.from.options.color.highlight.border : this.from.options.color.border);
grd.addColorStop(1, this.to.selected ? this.to.options.color.highlight.border : this.to.options.color.border);
return grd;
}
if (this.selected == true) {return colorObj.highlight;} if (this.selected == true) {return colorObj.highlight;}
else if (this.hover == true) {return colorObj.hover;} else if (this.hover == true) {return colorObj.hover;}
else {return colorObj.color;} else {return colorObj.color;}
@ -270,7 +277,7 @@ Edge.prototype._getColor = function() {
*/ */
Edge.prototype._drawLine = function(ctx) { Edge.prototype._drawLine = function(ctx) {
// set style // set style
ctx.strokeStyle = this._getColor();
ctx.strokeStyle = this._getColor(ctx);
ctx.lineWidth = this._getLineWidth(); ctx.lineWidth = this._getLineWidth();
if (this.from != this.to) { if (this.from != this.to) {
@ -715,7 +722,7 @@ Edge.prototype._drawLabelText = function(ctx, x, yLine, lines, lineCount, fontSi
*/ */
Edge.prototype._drawDashLine = function(ctx) { Edge.prototype._drawDashLine = function(ctx) {
// set style // set style
ctx.strokeStyle = this._getColor();
ctx.strokeStyle = this._getColor(ctx);
ctx.lineWidth = this._getLineWidth(); ctx.lineWidth = this._getLineWidth();
var via = null; var via = null;
@ -820,7 +827,7 @@ Edge.prototype._pointOnCircle = function (x, y, radius, percentage) {
Edge.prototype._drawArrowCenter = function(ctx) { Edge.prototype._drawArrowCenter = function(ctx) {
var point; var point;
// set style // set style
ctx.strokeStyle = this._getColor();
ctx.strokeStyle = this._getColor(ctx);
ctx.fillStyle = ctx.strokeStyle; ctx.fillStyle = ctx.strokeStyle;
ctx.lineWidth = this._getLineWidth(); ctx.lineWidth = this._getLineWidth();
@ -956,7 +963,7 @@ Edge.prototype._findBorderPosition = function(from,ctx) {
*/ */
Edge.prototype._drawArrow = function(ctx) { Edge.prototype._drawArrow = function(ctx) {
// set style // set style
ctx.strokeStyle = this._getColor();
ctx.strokeStyle = this._getColor(ctx);
ctx.fillStyle = ctx.strokeStyle; ctx.fillStyle = ctx.strokeStyle;
ctx.lineWidth = this._getLineWidth(); ctx.lineWidth = this._getLineWidth();

+ 2
- 1
lib/network/Network.js View File

@ -129,7 +129,8 @@ function Network (container, data, options) {
gap: 5, gap: 5,
altLength: undefined altLength: undefined
}, },
inheritColor: "from" // to, from, false, true (== from)
inheritColor: "from", // to, from, false, true (== from)
useGradients: false
}, },
configurePhysics:false, configurePhysics:false,
physics: { physics: {

Loading…
Cancel
Save