安装引入vis
- npm安装vis
npm install vis
- 引入vis
import { DataSet, Network } from 'vis';
vis使用示例
methods:{
globalTrace () {
var nodes = new DataSet([
{id: 1, label: 'Node 1'},
{id: 2, label: 'Node 2'},
{id: 3, label: 'Node 3'},
{id: 4, label: 'Node 4'},
{id: 5, label: 'Node 5'}
]);
var edges = new DataSet([
{from: 1, to: 3},
{from: 1, to: 2},
{from: 2, to: 4},
{from: 2, to: 5}
]);
var container = document.querySelector('#global_trace_content');
var data = {
nodes: nodes,
edges: edges
};
var options = {
nodes: {
shape: "box",
fixed:true,
font: {
color: "white",
size: 30
},
scaling: {
min: 16,
max: 32
},
},
edges: {
color: {
color: "rgb(97, 168, 224)",
highlight: "rgb(97, 168, 224)",
hover: "green",
inherit: "from",
opacity: 1.0
},
font: {
align: "top",
},
smooth: true,
arrows: {to : true },
},
layout: {
hierarchical: {
direction: "LR",
sortMethod: "directed",
levelSeparation:400
},
},
interaction: {
navigationButtons: true,
selectConnectedEdges: false,
},
};
this.network = new Network(container, data, options);
this.network.on("click",e=> this.showDetail(e));
this.network.on("doubleClick",e=> this.enterService(e))
},
},
mounted(){
this.globalTrace()
}
vis官方文档
使用文档
官方示例