How to use the vis-util.selectiveNotDeepExtend 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 / PhysicsEngine.js View on Github external
setOptions(options) {
    if (options !== undefined) {
      if (options === false) {
        this.options.enabled = false;
        this.physicsEnabled = false;
        this.stopSimulation();
      }
      else if (options === true) {
        this.options.enabled = true;
        this.physicsEnabled = true;
        this.startSimulation();
      }
      else {
        this.physicsEnabled = true;
        util.selectiveNotDeepExtend(['stabilization'], this.options, options);
        util.mergeOptions(this.options, options, 'stabilization');

        if (options.enabled === undefined) {
          this.options.enabled = true;
        }

        if (this.options.enabled === false) {
          this.physicsEnabled = false;
          this.stopSimulation();
        }

        // set the timestep
        this.timestep = this.options.timestep;
      }
    }
    this.init();
github visjs / vis-network / lib / network / modules / components / Node.js View on Github external
if (newOptions !== undefined && newOptions.group !== undefined && group !== newOptions.group) {
      throw new Error("updateGroupOptions: group values in options don't match.");
    }

    var hasGroup = (typeof group === 'number' || (typeof group === 'string' && group != ''));
    if (!hasGroup) return;  // current node has no group, no need to merge

    var groupObj = groupList.get(group);

    // Skip merging of group font options into parent; these are required to be distinct for labels
    // Also skip mergin of color IF it is already defined in the node itself. This is to avoid the color of the
    // group overriding the color set at the node level
    // TODO: It might not be a good idea either to merge the rest of the options, investigate this.
    var skipProperties = ['font'];
    if (newOptions !== undefined && newOptions.color !== undefined && newOptions.color != null) skipProperties.push('color');
    util.selectiveNotDeepExtend(skipProperties, parentOptions, groupObj);

    // the color object needs to be completely defined.
    // Since groups can partially overwrite the colors, we parse it again, just in case.
    parentOptions.color = util.parseColor(parentOptions.color);
  }
github visjs / vis-network / lib / network / modules / components / Node.js View on Github external
static parseOptions(parentOptions, newOptions, allowDeletion = false, globalOptions = {}, groupList) {

    var fields = [
      'color',
      'fixed',
      'shadow'
    ];
    util.selectiveNotDeepExtend(fields, parentOptions, newOptions, allowDeletion);

    Node.checkMass(newOptions);

    // merge the shadow options into the parent.
    util.mergeOptions(parentOptions, newOptions, 'shadow', globalOptions);

    // individual shape newOptions
    if (newOptions.color !== undefined && newOptions.color !== null) {
      let parsedColor = util.parseColor(newOptions.color);
      util.fillIfDefined(parentOptions.color, parsedColor);
    }
    else if (allowDeletion === true && newOptions.color === null) {
      parentOptions.color = util.bridgeObject(globalOptions.color); // set the object back to the global options
    }

    // handle the fixed options
github visjs / vis-network / lib / network / modules / InteractionHandler.js View on Github external
setOptions(options) {
    if (options !== undefined) {
      // extend all but the values in fields
      let fields = ['hideEdgesOnDrag', 'hideEdgesOnZoom', 'hideNodesOnDrag','keyboard','multiselect','selectable','selectConnectedEdges'];
      util.selectiveNotDeepExtend(fields, this.options, options);

      // merge the keyboard options in.
      util.mergeOptions(this.options, options, 'keyboard');

      if (options.tooltip) {
        util.extend(this.options.tooltip, options.tooltip);
        if (options.tooltip.color) {
          this.options.tooltip.color = util.parseColor(options.tooltip.color);
        }
      }
    }

    this.navigationHandler.setOptions(this.options);
  }