當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vis.Network類代碼示例

本文整理匯總了TypeScript中vis.Network的典型用法代碼示例。如果您正苦於以下問題:TypeScript Network類的具體用法?TypeScript Network怎麽用?TypeScript Network使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Network類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: drawGraph


//.........這裏部分代碼省略.........
          highlight: {
            background: "#07f968",
            border: "#3c3c3c"
          }
        },
        borderWidth: 2,
        borderWidthSelected: 2,
      }
    },

    nodes: {
      borderWidth: 8,
      borderWidthSelected: 8,
      color: {
        border: "#39c0ba",
        background: "#FFF",
        highlight: {
          border: "#FF0",
          background: "#FFF"
        },
        hover: {
          border: "#F00",
          background: "#FFF"
        },
      },
      shadow: true,
    },

    physics: {
      enabled: false,
    },
  };

  network = new vis.Network(container, bsData, options);

  getAllCommits(function(commits) {
    processGraph(commits);
  });

  network.on("stabilizationIterationsDone", function () {
    network.setOptions( { physics: false } );
  });

  network.on("doubleClick", function(callback) {
    if (callback.nodes[0] === undefined) {
      return;
    } else {
      let nodeId: number = callback.nodes[0];
    }

    let moveOptions = {
      offset: {x: 0, y: 0},
      scale: 1,
      animation: {
        duration: 1000,
        easingFunction: "easeInOutQuad",
      }
    };

    network.focus(callback.nodes[0], moveOptions);
  }, false);

  let flag = "basic";

  network.on("zoom", function(callback) {
    let moveOptions = {
開發者ID:ElliotWhiley,項目名稱:VisualGit,代碼行數:67,代碼來源:graphSetup.ts

示例2:

        this.diagram.on('oncontext', (({event, pointer}: {event: MouseEvent, pointer: {[key: string]: any}}) => {
            event.preventDefault();
            const { x, y } = pointer.DOM;
            const nodeId = this.diagram.getNodeAt({x, y}) as string;
            const edgeId = this.diagram.getEdgeAt({x, y}) as string;

            if (nodeId || NodeGroup.isGroupKey(edgeId)) {
                return;
            }

            edgeId ? (
                this.outContextClickLink.emit({
                    key: edgeId,
                    coord: {
                        coordX: x,
                        coordY: y
                    }
                })
            ) : (
                this.outContextClickBackground.emit({
                    coordX: x,
                    coordY: y
                })
            );
        }));
開發者ID:young891221,項目名稱:pinpoint,代碼行數:25,代碼來源:server-map-diagram-with-visjs.class.ts

示例3: setEvent

    private setEvent(): void {
        this.diagram.on('afterDrawing', () => {
            if (!this.serverMapData) {
                return;
            }

            this.outRenderCompleted.emit();
        });
        this.diagram.on('click', (({nodes, edges}: {nodes: string[], edges: string[]}) => {
            const isNodeClicked = nodes.length !== 0;
            const isEdgeClicked = !isNodeClicked && edges.length !== 0;
            const isBackgroundClicked = !(isNodeClicked || isEdgeClicked);

            if (isNodeClicked) {
                const nodeId = nodes[0];
                const nodeData = this.getNodeData(nodeId);

                this.outClickNode.emit(nodeData);
            } else if (isEdgeClicked) {
                const edgeId = edges[0];
                const linkData = this.getLinkData(edgeId);

                this.outClickLink.emit(linkData);
            } else if (isBackgroundClicked) {
                this.outClickBackground.emit();
            }
        }));
        this.diagram.on('hoverNode', () => this.changeCursor('pointer'));
        this.diagram.on('hoverEdge', () => this.changeCursor('pointer'));
        this.diagram.on('blurNode', () => this.changeCursor('default'));
        this.diagram.on('blurEdge', () => this.changeCursor('default'));
        this.diagram.on('oncontext', (({event, pointer}: {event: MouseEvent, pointer: {[key: string]: any}}) => {
            event.preventDefault();
            const { x, y } = pointer.DOM;
            const nodeId = this.diagram.getNodeAt({x, y}) as string;
            const edgeId = this.diagram.getEdgeAt({x, y}) as string;

            if (nodeId || NodeGroup.isGroupKey(edgeId)) {
                return;
            }

            edgeId ? (
                this.outContextClickLink.emit({
                    key: edgeId,
                    coord: {
                        coordX: x,
                        coordY: y
                    }
                })
            ) : (
                this.outContextClickBackground.emit({
                    coordX: x,
                    coordY: y
                })
            );
        }));
    }
開發者ID:young891221,項目名稱:pinpoint,代碼行數:57,代碼來源:server-map-diagram-with-visjs.class.ts

示例4: selectNodeBySearch

    selectNodeBySearch(selectedAppKey: string): void {
        let selectedNodeId = selectedAppKey;
        const isMergedNode = !this.isNodeInDiagram(selectedAppKey);

        if (isMergedNode) {
            const groupKey = selectedAppKey.split('^')[1];
            const selectedMergedNode = this.serverMapData.getNodeList().find(({key}: {key: string}) => {
                return NodeGroup.isGroupKey(key) && key.includes(groupKey);
            });

            selectedNodeId = selectedMergedNode.key;
        }

        this.diagram.focus(selectedNodeId);
        this.setNodeClicked(selectedNodeId);
    }
開發者ID:young891221,項目名稱:pinpoint,代碼行數:16,代碼來源:server-map-diagram-with-visjs.class.ts

示例5: clear

 clear(): void {
     this.diagram.destroy();
 }
開發者ID:young891221,項目名稱:pinpoint,代碼行數:3,代碼來源:server-map-diagram-with-visjs.class.ts

示例6: setNodeClicked

 private setNodeClicked(key: string): void {
     this.diagram.selectNodes([key]);
     this.outClickNode.emit(this.getNodeData(key));
 }
開發者ID:young891221,項目名稱:pinpoint,代碼行數:4,代碼來源:server-map-diagram-with-visjs.class.ts

示例7: isNodeInDiagram

 private isNodeInDiagram(key: string): boolean {
     return this.diagram.findNode(key).length !== 0;
 }
開發者ID:young891221,項目名稱:pinpoint,代碼行數:3,代碼來源:server-map-diagram-with-visjs.class.ts


注:本文中的vis.Network類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。