vue.js生成横向拓扑图
1.前端代码
<link href="https://magicbox.bk.tencent.com/static_api/v3/assets/bootstrap-3.3.4/css/bootstrap.min.css" rel="stylesheet">
<link href="https://magicbox.bk.tencent.com/static_api/v3/assets/bkTopology-1.1/css/bkTopology.css" rel="stylesheet">
<script src="https://magicbox.bk.tencent.com/static_api/v3/assets/js/jquery-1.10.2.min.js"></script>
<script src="https://magicbox.bk.tencent.com/static_api/v3/assets/bootstrap-3.3.4/js/bootstrap.min.js"></script>
<script src="https://magicbox.bk.tencent.com/static_api/v3/assets/bkTopology-1.2/js/bkTopology.js"></script>
<div id="app" style="margin-top: 60px;">
<el-row :gutter="40">
<el-col :span="16" :offset="4">
<div class="none node" id="node-templates" data-container="body" data-placement="top" data-html="true" data-trigger="hover">
<div class="node-container"><span class="node-text"></span></div>
</div>
<div class="bktopo-container">
<div class="bktopo_demo" id="bktopo_demo2">
<div class="none node" id="node-templates" data-container="body" data-placement="top" data-html="true" data-trigger="hover">
<div class="node-container"><span class="node-text"></span></div></div>
<div class="bktopo_box" style="height:350px;"></div>
</div>
</div>
</el-col>
</el-row>
</div>
<script type="text/javascript">
new Vue({
el: '#app',
data: {
},
mounted() {
this.init()
},
methods: {
init() {
axios.get(site_url + "topo/").then(res => {
if (res.data.result){
$('#bktopo_demo2 .bktopo_box').bkTopology({
data: res.data.data, //配置数据源
lineType: [ //配置线条的类型
{type: 'success', lineColor: '#46C37B'},
{type: 'info', lineColor: '#4A9BFF'},
{type: 'warning', lineColor: '#f0a63a'},
{type: 'danger', lineColor: '#c94d3c'},
{type: 'default', lineColor: '#aaa'}
]
});
}else{
this.$message.error('获取拓朴数据失败');
}
},'json');
}
}
})
</script>
2.后端代码
def topo(request):
data = {
"nodes": [
{"id": "root", "x": 10, "y": 152, "height": 50, "width": 120, "text": "卡机健康度", "className": "info"},
{"id": "child1", "x": 200, "y": 30, "height": 50, "width": 120, "text": "进程CPU监控", "className": "info"},
{"id": "child2", "x": 200, "y": 90, "height": 50, "width": 120, "text": "网管网络故障监控", "className": "info"},
{"id": "child3", "x": 200, "y": 150, "height": 50, "width": 120, "text": "进程内在泄露监控", "className": "info"},
{"id": "child4", "x": 200, "y": 210, "height": 50, "width": 120, "text": "进程存活监控", "className": "info"},
{"id": "child5", "x": 200, "y": 270, "height": 50, "width": 120, "text": "用户内在使用监控", "className": "info"},
{"id": "child1_1", "x": 380, "y": 30, "height": 50, "width": 120, "text": "监控正常无触发自愈","className": "success"},
{"id": "child2_1", "x": 380, "y": 90, "height": 50, "width": 120, "text": "监控正常无触发自愈","className": "success"},
{"id": "child3_1", "x": 380, "y": 150, "height": 50, "width": 120, "text": "发现异常触发自愈","className": "danger"},
{"id": "child3_2", "x": 560, "y": 150, "height": 50, "width": 120, "text": "重启进程正常", "className": "success"},
{"id": "child4_1", "x": 380, "y": 210, "height": 50, "width": 120, "text": "发现异常触发自愈","className": "danger"},
{"id": "child4_2", "x": 560, "y": 210, "height": 50, "width": 120, "text": "重启进程正常","className": "success"},
{"id": "child5_1", "x": 380, "y": 270, "height": 50, "width": 120, "text": "发现异常触发自愈","className": "success"},
],
"edges": [
{"source": "root", "sDirection": 'right', "target": "child1", "tDirection": 'left', "edgesType": "info"},
{"source": "root", "sDirection": 'right', "target": "child2", "tDirection": 'left', "edgesType": "info"},
{"source": "root", "sDirection": 'right', "target": "child3", "tDirection": 'left', "edgesType": "info"},
{"source": "root", "sDirection": 'right', "target": "child4", "tDirection": 'left', "edgesType": "info"},
{"source": "root", "sDirection": 'right', "target": "child5", "tDirection": 'left', "edgesType": "info"},
{"source": "child1","sDirection":'right',"target":"child1_1","tDirection":'left',"edgesType": "success"},
{"source": "child2","sDirection": 'right', "target": "child2_1", "tDirection": 'left',"edgesType": "success"},
{"source": "child3","sDirection": 'right', "target": "child3_1", "tDirection": 'left',"edgesType": "danger"},
{"source": "child3_1","sDirection": 'right', "target": "child3_2", "tDirection": 'left',"edgesType": "success"},
{"source": "child4","sDirection": 'right', "target": "child4_1", "tDirection": 'left',"edgesType": "danger"},
{"source": "child4_1","sDirection": 'right', "target": "child4_2", "tDirection": 'left',"edgesType": "success"},
{"source": "child5","sDirection": 'right', "target": "child5_1", "tDirection": 'left',"edgesType": "success"}
]
}
return JsonResponse({"result": True, "data": data})
显示效果

vue.js生成横向拓扑图的更多相关文章
- vue.js生成纵向拓扑图
1.前端代码 <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/bootstrap-3.3.4/css/ ...
- vue.js生成S型拓扑图
1.前端代码 <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/bootstrap-3.3.4/css/ ...
- vue.js 二维码生成组件
安装 通过NPM安装 npm install vue-qart --save 插件应用 将vue-qart引入你的应用 import VueQArt from 'vue-qart' new Vue({ ...
- 基于 Vue.js 之 iView UI 框架非工程化实践记要 使用 Newtonsoft.Json 操作 JSON 字符串 基于.net core实现项目自动编译、并生成nuget包 webpack + vue 在dev和production模式下的小小区别 这样入门asp.net core 之 静态文件 这样入门asp.net core,如何
基于 Vue.js 之 iView UI 框架非工程化实践记要 像我们平日里做惯了 Java 或者 .NET 这种后端程序员,对于前端的认识还常常停留在 jQuery 时代,包括其插件在需要时就引 ...
- 在Vue&Element前端项目中,使用FastReport + pdf.js生成并展示自定义报表
在我的<FastReport报表随笔>介绍过各种FastReport的报表设计和使用,FastReport报表可以弹性的独立设计格式,并可以在Asp.net网站上.Winform端上使用, ...
- 用Vue.js开发微信小程序:开源框架mpvue解析
前言 mpvue 是一款使用 Vue.js 开发微信小程序的前端框架.使用此框架,开发者将得到完整的 Vue.js 开发体验,同时为 H5 和小程序提供了代码复用的能力.如果想将 H5 项目改造为小程 ...
- npm安装教程(vue.js)
https://www.cnblogs.com/goldlong/p/8027997.html 首先理清nodejs和npm的关系: node.js是javascript的一种运行环境,是对Googl ...
- (GoRails )使用Vue.js制作拖拉list功能(v5-8)
视频5 改进视觉效果,让list看起来更舒服.新增横向滚动功能. 参考我的trello:https://trello.com/b/BYvCBpyZ/%E6%AF%8F%E6%97%A5%E8%AE%B ...
- Vue.js高效前端开发 • 【Ant Design of Vue框架进阶】
全部章节 >>>> 文章目录 一.栅格组件 1.栅格组件介绍 2.栅格组件使用 3.实践练习 二.输入组件 1.输入框组件使用 2.选择器组件使用 3.单选框组件使用 4.实践 ...
随机推荐
- UA记录
安卓QQ内置浏览器UA: Mozilla/5.0 (Linux; Android 5.0; SM-N9100 Build/LRX21V) AppleWebKit/537.36 (KHTML, like ...
- java并发编程(九)ThreadLocal & InheritableThreadLocal
参考文档: https://blog.csdn.net/u012834750/article/details/71646700 threadlocal内存泄漏:http://www.importnew ...
- java基础之 数据类型 & 值传递 引用传递 & String & 四种引用类型
一.Java数据类型 分为基本数据类型与引用数据类型 基本数据类型: byte:Java中最小的数据类型,在内存中占1个字节(8 bit),取值范围-128~127,默认值0 short:短整型,2个 ...
- 《Linux就该这么学》培训笔记_ch20使用LNMP架构部署动态网站环境
<Linux就该这么学>培训笔记_ch20使用LNMP架构部署动态网站环境 文章最后会post上书本的笔记照片. 文章主要内容: 源码包程序 LNMP动态网站架构 配置Mysql服务 配置 ...
- docker 学习操作记录 3
记录3 [BEGIN] // :: Last :: from 192.168.114.1 root@coder:~# man addgroup ADDUSER() System Manager's M ...
- vue-cli中的element-ui的主题更改
主题安装分为全局安装和局部安装(局部安装指的是项目内进行安装) 局部安装: 使用局部安装方便他人使用,他人直接安装主题需要的依赖就可以进行使用 局部安装的步骤 1.npm i element-them ...
- 查看linux系统版本及内核
一.查看Linux系统版本的命令(3种方法) 1.适用于所有的Linux发行版 cat /etc/issue [root@S-CentOS home]# cat /etc/issue CentOS r ...
- 图论 --- BFS + MST
Borg Maze Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7844 Accepted: 2623 Descrip ...
- 60 网络编程(二)——URL
认识URI.URL.URN 详细请参考:https://blog.51cto.com/xoyabc/1905492 URI:uniform resource Indent 统一资源标识符 URL:un ...
- Linux文件目录指令
1.pwd指令 pwd 显示当前所在的目录 2.ls指令 ls [选项] [目录或文件] 查看文件信息 ls -a 查看所有文件和目录,包括隐藏的 ls -l 以列表的方式显示 3.cd指令 cd 路 ...