<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>vis network</title>
<script
type="text/javascript"
src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"
></script>
<style>
#mynetwork {
width: 600px;
height: 300px;
background-color: aqua;
}
</style>
</head>
<body>
<div id="mynetwork"></div>
<script type="text/javascript">
// 创建nodes数组
var nodes = new vis.DataSet([
{
id:1,
label:'皇上'
},
{
id:2,
label:'皇后'
},
{
id:3,
label:'贵妃'
},
{
id:5,
label:'小人'
},
]);
// 创建edges数组
var edges = new vis.DataSet([
{
from:1,to:2
},
{
from:1,to:3
},
{
from:2,to:1
},
{
from:3,to:1
},
{
from:5,to:3
}
]);
// 获取容器元素
var container = document.querySelector('div#mynetwork');
// 定义data对象
var data = {
nodes:nodes,
edges:edges
}
// 定义options对象
var options = {};
// 最重要的一步
var network = new vis.Network(container,data,options)
</script>
</body>
</html>
效果图:
学习链接:
vis.js
Vis Network Examples
VIS.JS文档
https://www.oschina.net/p/visjs
https://unpkg.com/vis-network/standalone/umd/vis-network.min.js
#:在vue中使用vis,首先要安装模块:npm install vis-network
?
|