How to use the vis-util.overrideOpacity function in vis-util

To help you get started, we’ve selected a few vis-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github visjs / vis-network / lib / network / modules / components / edges / util / EdgeBase.js View on Github external
fromColor = this.from.options.color.border;
        }
        grd.addColorStop(0, fromColor);
        grd.addColorStop(1, toColor);

        // -------------------- this returns -------------------- //
        return grd;
      }

      if (values.inheritsColor === "to") {
        return util.overrideOpacity(this.to.options.color.border, values.opacity);
      } else { // "from"
        return util.overrideOpacity(this.from.options.color.border, values.opacity);
      }
    } else {
      return util.overrideOpacity(values.color, values.opacity);
    }
  }
github visjs / vis-network / lib / network / modules / components / edges / util / EdgeBase.js View on Github external
getColor(ctx, values, selected, hover) {  // eslint-disable-line no-unused-vars
    if (values.inheritsColor !== false) {
      // when this is a loop edge, just use the 'from' method
      if ((values.inheritsColor === 'both') && (this.from.id !== this.to.id)) {
        let grd = ctx.createLinearGradient(this.from.x, this.from.y, this.to.x, this.to.y);
        let fromColor, toColor;
        fromColor = this.from.options.color.highlight.border;
        toColor = this.to.options.color.highlight.border;

        if ((this.from.selected === false) && (this.to.selected === false)) {
          fromColor = util.overrideOpacity(this.from.options.color.border, values.opacity);
          toColor = util.overrideOpacity(this.to.options.color.border, values.opacity);
        }
        else if ((this.from.selected === true) && (this.to.selected === false)) {
          toColor = this.to.options.color.border;
        }
        else if ((this.from.selected === false) && (this.to.selected === true)) {
          fromColor = this.from.options.color.border;
        }
        grd.addColorStop(0, fromColor);
        grd.addColorStop(1, toColor);

        // -------------------- this returns -------------------- //
        return grd;
      }

      if (values.inheritsColor === "to") {
        return util.overrideOpacity(this.to.options.color.border, values.opacity);
github visjs / vis-network / lib / network / modules / components / edges / util / EdgeBase.js View on Github external
}
        else if ((this.from.selected === true) && (this.to.selected === false)) {
          toColor = this.to.options.color.border;
        }
        else if ((this.from.selected === false) && (this.to.selected === true)) {
          fromColor = this.from.options.color.border;
        }
        grd.addColorStop(0, fromColor);
        grd.addColorStop(1, toColor);

        // -------------------- this returns -------------------- //
        return grd;
      }

      if (values.inheritsColor === "to") {
        return util.overrideOpacity(this.to.options.color.border, values.opacity);
      } else { // "from"
        return util.overrideOpacity(this.from.options.color.border, values.opacity);
      }
    } else {
      return util.overrideOpacity(values.color, values.opacity);
    }
  }
github visjs / vis-network / lib / network / modules / components / shared / Label.js View on Github external
_getColor(color, viewFontSize, initialStrokeColor) {
    let fontColor = color || '#000000';
    let strokeColor = initialStrokeColor || '#ffffff';
    if (viewFontSize <= this.elementOptions.scaling.label.drawThreshold) {
      let opacity = Math.max(0, Math.min(1, 1 - (this.elementOptions.scaling.label.drawThreshold - viewFontSize)));
      fontColor = util.overrideOpacity(fontColor, opacity);
      strokeColor = util.overrideOpacity(strokeColor, opacity);
    }
    return [fontColor, strokeColor];
  }
github visjs / vis-network / lib / network / modules / components / shared / Label.js View on Github external
_getColor(color, viewFontSize, initialStrokeColor) {
    let fontColor = color || '#000000';
    let strokeColor = initialStrokeColor || '#ffffff';
    if (viewFontSize <= this.elementOptions.scaling.label.drawThreshold) {
      let opacity = Math.max(0, Math.min(1, 1 - (this.elementOptions.scaling.label.drawThreshold - viewFontSize)));
      fontColor = util.overrideOpacity(fontColor, opacity);
      strokeColor = util.overrideOpacity(strokeColor, opacity);
    }
    return [fontColor, strokeColor];
  }