How to use the vis-util.randomUUID 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 / ManipulationSystem.js View on Github external
_getNewTargetNode(x,y) {
    let controlNodeStyle = util.deepExtend({}, this.options.controlNodeStyle);

    controlNodeStyle.id = 'targetNode' + util.randomUUID();
    controlNodeStyle.hidden = false;
    controlNodeStyle.physics = false;
    controlNodeStyle.x = x;
    controlNodeStyle.y = y;

    // we have to define the bounding box in order for the nodes to be drawn immediately
    let node = this.body.functions.createNode(controlNodeStyle);
    node.shape.boundingBox = {left: x, right:x, top:y, bottom:y};

    return node;
  }
github visjs / vis-network / lib / network / modules / Clustering.js View on Github external
// these cluster edges will be removed on creation of the cluster.
          if (edgeId.substr(0, 12) !== "clusterEdge:") {
            let clonedOptions = NetworkUtil.cloneOptions(childEdgesObj[edgeId], 'edge');
            childEdgesOptions.push(clonedOptions);
          }
        }
      }

      clusterNodeProperties = options.processProperties(clusterNodeProperties, childNodesOptions, childEdgesOptions);
      if (!clusterNodeProperties) {
        throw new Error("The processProperties function does not return properties!");
      }
    }

    // check if we have an unique id;
    if (clusterNodeProperties.id === undefined) {clusterNodeProperties.id = 'cluster:' + util.randomUUID();}
    let clusterId = clusterNodeProperties.id;

    if (clusterNodeProperties.label === undefined) {
      clusterNodeProperties.label = 'cluster';
    }


    // give the clusterNode a position if it does not have one.
    let pos = undefined;
    if (clusterNodeProperties.x === undefined) {
      pos = this._getClusterPosition(childNodesObj);
      clusterNodeProperties.x = pos.x;
    }
    if (clusterNodeProperties.y === undefined) {
      if (pos === undefined) {pos = this._getClusterPosition(childNodesObj);}
      clusterNodeProperties.y = pos.y;
github visjs / vis-network / lib / network / modules / ManipulationSystem.js View on Github external
_performAddNode(clickData) {
    let defaultData = {
      id: util.randomUUID(),
      x: clickData.pointer.canvas.x,
      y: clickData.pointer.canvas.y,
      label: 'new'
    };

    if (typeof this.options.addNode === 'function') {
      if (this.options.addNode.length === 2) {
        this.options.addNode(defaultData, (finalizedData) => {
          if (finalizedData !== null && finalizedData !== undefined && this.inMode === 'addNode') { // if for whatever reason the mode has changes (due to dataset change) disregard the callback
            this.body.data.nodes.getDataSet().add(finalizedData);
          }
          this.showManipulatorToolbar();
        });
      }
      else {
        this.showManipulatorToolbar();
github visjs / vis-network / lib / network / modules / Clustering.js View on Github external
_createClusteredEdge(fromId, toId, baseEdge, clusterEdgeProperties, extraOptions) {
    // copy the options of the edge we will replace
    let clonedOptions = NetworkUtil.cloneOptions(baseEdge, 'edge');
    // make sure the properties of clusterEdges are superimposed on it
    util.deepExtend(clonedOptions, clusterEdgeProperties);

    // set up the edge
    clonedOptions.from = fromId;
    clonedOptions.to   = toId;
    clonedOptions.id   = 'clusterEdge:' + util.randomUUID();

    // apply the edge specific options to it if specified
    if (extraOptions !== undefined) {
      util.deepExtend(clonedOptions, extraOptions);
    }

    let newEdge = this.body.functions.createEdge(clonedOptions);
    newEdge.clusteringEdgeReplacingIds = [baseEdge.id];
    newEdge.connect();

    // Register the new edge
    this.body.edges[newEdge.id] = newEdge;

    return newEdge;
  }
github Thomaash / me / src / components / Vis.vue View on Github external
for (let i = 0; i < ports; ++i) {
                const port = {
                  id: visUtil.randomUUID(),
                  label: `eth${i}`,
                  group: 'port',
                  ...coords[i]
                }
                items.push({
                  id: port.id,
                  hostname: port.label,
                  type: 'port',
                  ...coords[i]
                })

                const edge = {
                  id: visUtil.randomUUID(),
                  from: edited.id,
                  to: port.id
                }
                items.push({
                  id: edge.id,
                  type: 'association',
                  from: edge.from,
                  to: edge.to
                })
              }
            }

            this.commit('replaceItems', items)
          },
          editNode: async (node, callback) => {