vue 集成 vis

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个节点

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )