最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

vue 集成 vis-network 实现网络拓扑图的方法

来源:懂视网 责编:小采 时间:2020-11-27 21:52:38
文档

vue 集成 vis-network 实现网络拓扑图的方法

vue 集成 vis-network 实现网络拓扑图的方法:vis.js 网站 https://visjs.org/ vs code 下安装命令 npm install vis-network 在vue 下引入 vis-network组件 const vis = require(vis-network/dist/vis-network.min.js); require(vis-network/d
推荐度:
导读vue 集成 vis-network 实现网络拓扑图的方法:vis.js 网站 https://visjs.org/ vs code 下安装命令 npm install vis-network 在vue 下引入 vis-network组件 const vis = require(vis-network/dist/vis-network.min.js); require(vis-network/d

vis.js  网站

https://visjs.org/

vs  code 下安装命令

npm install vis-network

在vue  下引入 vis-network组件

const vis = require("vis-network/dist/vis-network.min.js");
require("vis-network/dist/vis-network.min.css");

例子代码使用

let DIR = "/jtopo/";
let nodes = [
{ id: 1, shape: "circularImage", image: DIR + "server.png" },
{ id: 2, shape: "circularImage", image: DIR + "server.png" },
{ id: 3, shape: "circularImage", image: DIR + "server.png" },
{
id: 4,
shape: "circularImage",
image: DIR + "gather.png",
label: "pictures by this guy!"
},
{ id: 5, shape: "circularImage", image: DIR + "wanjet.png" },
{ id: 6, shape: "circularImage", image: DIR + "center.png" },
{ id: 7, shape: "circularImage", image: DIR + "cloud.png" },
{ id: 8, shape: "circularImage", image: DIR + "center.png" },
{ id: 9, shape: "circularImage", image: DIR + "wanjet.png" },
{ id: 10, shape: "circularImage", image: DIR + "gather.png" }
// { id: 11, shape: "circularImage", image: DIR + "11.png" },
// { id: 12, shape: "circularImage", image: DIR + "12.png" },
// { id: 13, shape: "circularImage", image: DIR + "13.png" },
// { id: 14, shape: "circularImage", image: DIR + "14.png" },
// {
// id: 15,
// shape: "circularImage",
// image: DIR + "missing.png",
// brokenImage: DIR + "missingBrokenImage.png",
// label: "when images\nfail\nto load"
// },
// {
// id: 16,
// shape: "circularImage",
// image: DIR + "anotherMissing.png",
// brokenImage: DIR + "9.png",
// label: "fallback image in action"
// }
];
let edges = [
{ from: 1, to: 4 },
{ from: 2, to: 4 },
{ from: 3, to: 4 },
{ from: 4, to: 5 },
{ from: 5, to: 6 },
{ from: 6, to: 7 },
{ from: 8, to: 7 },
{ from: 9, to: 8 },
{ from: 10, to: 9 }
// { from: 8, to: 10 },
// { from: 10, to: 11 },
// { from: 11, to: 12 },
// { from: 12, to: 13 },
// { from: 13, to: 14 },
// { from: 9, to: 16 }
];
for (let i = 1; i <= 100; i++) {
num = i + 10;
nodes.push({
id: num,
label: num.toString()
});
edges.push({ from: num, to: 10 });
}
let data = {
nodes: nodes,
edges: edges
};
let container = document.getElementById("mynetwork");
//let options = {};
let options = {
nodes: {
font: {
color: "white", //字体的颜色
size: 30 //显示字体大小
},
scaling: {
min: 16,
max: 32 //缩放效果比例
},
borderWidth: 0,
color: {
border: "white",
background: "white" //若是引用图标,背景颜色
}
},
groups: {
ws: {
//系统定义的形状 dot等 这些官网都可以找到
shape: "dot",
color: "white"
}
},
edges: {
//连接线的样式
color: {
color: "white",
highlight: "white",
hover: "#848484",
inherit: "from",
opacity: 1.0
}
},
layout: {
randomSeed: 1 //配置每次生成的节点位置都一样,参数为数字1、2等
},
physics: {
// barnesHut: { gravitationalConstant: -30000 },
barnesHut: {
gravitationalConstant: -80000,
springConstant: 0.001,
springLength: 200
},
stabilization: false
//{ iterations: 2500 }
},
interaction: {
// navigationButtons: true,
hover: true, //鼠标移过后加粗该节点和连接线
selectConnectedEdges: false, //选择节点后是否显示连接线
hoverConnectedEdges: false, //鼠标滑动节点后是否显示连接线
tooltipDelay: 200,
zoomView: true //是否能缩放画布
},
edges: {
shadow: true, //连接线阴影配置
smooth: true //是否显示方向箭头
// arrows: {to : true }//箭头指向from节点
}
};
that.network = new vis.Network(container, data, options);
that.network.on("click", function(params) {});

设置 stabilization: false  可以快速生成10000个节点

总结

以上所述是小编给大家介绍的vue 集成 vis-network 实现网络拓扑图的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

vue 集成 vis-network 实现网络拓扑图的方法

vue 集成 vis-network 实现网络拓扑图的方法:vis.js 网站 https://visjs.org/ vs code 下安装命令 npm install vis-network 在vue 下引入 vis-network组件 const vis = require(vis-network/dist/vis-network.min.js); require(vis-network/d
推荐度:
标签: VUE 集成 拓扑
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top