jsPlumb画流程图

2023-10-28 01:50
文章标签 流程图 jsplumb

本文主要是介绍jsPlumb画流程图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

获取的JSON格式

{"linkDataArray":[{"targetAnchors":["Bottom","Right","Top","Left"],"routerId":"R00001","from":"E00001","sourceAnchors":["Bottom","Right","Top","Left"],"to":"T00001","label":""},{"targetAnchors":["Bottom","Right","Top","Left"],"routerId":"R00002","from":"T00001","sourceAnchors":["Bottom","Right","Top","Left"],"to":"T00002","label":""},{"targetAnchors":["Bottom","Right","Top","Left"],"routerId":"R00003","from":"T00002","sourceAnchors":["Bottom","Right","Top","Left"],"to":"T00004","label":""},{"targetAnchors":["Bottom","Right","Top","Left"],"routerId":"R00004","from":"T00004","sourceAnchors":["Bottom","Right","Top","Left"],"to":"T00003","label":""},{"targetAnchors":["Bottom","Right","Top","Left"],"routerId":"R00005","from":"T00003","sourceAnchors":["Bottom","Right","Top","Left"],"to":"T00005","label":""},{"targetAnchors":["Bottom","Right","Top","Left"],"routerId":"R00006","from":"T00005","sourceAnchors":["Bottom","Right","Top","Left"],"to":"E00002","label":""}],"nodeDataArray":[{"locTop":151,"deal":"1","bgColor":"#cccccc","locLeft":303.8909912109375,"nodeWidth":"60px","nodeHeight":"60px","text":"开始","nodeType":"start","list":null,"key":"E00001"},{"locTop":288,"deal":"1","bgColor":"#cccccc","locLeft":461.8909912109375,"nodeWidth":"60px","nodeHeight":"60px","text":"结束","nodeType":"end","list":null,"key":"E00002"},{"locTop":151,"deal":"1","bgColor":"#cccccc","locLeft":444.8909912109375,"nodeWidth":"100px","nodeHeight":"60px","text":"审核","nodeType":"comm","list":null,"key":"T00001"},{"locTop":151,"deal":"1","bgColor":"#cccccc","locLeft":615.8909912109375,"nodeWidth":"100px","nodeHeight":"60px","text":"审核","nodeType":"comm","list":null,"key":"T00002"},{"locTop":289,"deal":"0","bgColor":"#6babdc","locLeft":804.8909912109375,"nodeWidth":"100px","nodeHeight":"60px","text":"审核","nodeType":"comm","list":null,"key":"T00003"},{"locTop":150,"deal":"2","bgColor":"#ff0000","locLeft":804.8909912109375,"nodeWidth":"100px","nodeHeight":"60px","text":"审核","nodeType":"comm","list":null,"key":"T00004"},{"locTop":288,"deal":"0","bgColor":"#6babdc","locLeft":615.8909912109375,"nodeWidth":"100px","nodeHeight":"60px","text":"审核","nodeType":"comm","list":null,"key":"T00005"}]}

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script type="text/javascript" src="${ctx}/static/js/component/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/component/jquery-ui.min.js"></script>
<script type="text/javascript" src="${ctx}/static/js/component/graphlib.min.js"></script>
<script type="text/javascript" src="${ctx}/static/jquery.jsPlumb.min.js"></script><style>#diagramContainer {font-size: smaller;   padding: 20px;height: 1000px;border: 1px solid gray;background: #fff;background-image: linear-gradient(#bab5b54d 1px, transparent 0), linear-gradient(90deg, #bab5b54d 1px, transparent 0), linear-gradient(#bab5b54d 1px, transparent 0), linear-gradient(90deg, #bab5b54d 1px, transparent 0);background-size: 15px 15px, 15px 15px, 75px 75px, 75px 75px;}/** 画图基础模型   */.cir_css{position: absolute;text-align: center;line-height: 60px;height: 60px;width: 60px;border: 2px solid rgb(64, 175, 254);border-radius: 30px;display:table;background:linear-gradient(to right, rgba(107, 171, 220, 0.9), rgba(107, 171, 220, 0.8), rgba(107, 171, 220, 0.9));}.rect_css{position: absolute;text-align: center;line-height:60px;height: 60px;width: 100px;border: 2px solid rgb(64, 175, 254);border-radius: 5px;display:table;background:linear-gradient(to right, rgba(107, 171, 220, 0.9), rgba(107, 171, 220, 0.8), rgba(107, 171, 220, 0.9));}.box_text{display:table-cell;vertical-align:middle;line-height:20px;}.text_box{width: 100px;}</style>
</head>
<body><div id="diagramContainer"></div><script type="text/javascript">var url="json数据链接地址";var graph = new graphlib.Graph();/* global jsPlumb */function makeStyle(flag) {let config = {};config.connectorPaintStyle = {lineWidth: 2,strokeStyle: "#61b8d0",};// 鼠标悬浮在连接线上的样式config.connectorHoverStyle = {lineWidth: 2,strokeStyle: "green",};return {// 端点形状endpoint: ['Dot', {radius: 6,fill: flag == 'dim' ? '#a2a1a1' : 'black'}],// 连接线的样式connectorStyle: config.connectorPaintStyle,connectorHoverStyle: config.connectorHoverStyle,// 端点的样式paintStyle: {fillStyle: flag == 'dim' ? '#a2a1a1' : 'black',radius: 4},hoverPaintStyle: {fillStyle: '#4caf50',strokeStyle: '#4caf50'},isSource: false,		//开启可删除线connector: ['Straight', {gap: 0,cornerRadius: 5,alwaysRespectStubs: true}],isTarget: false,		//开启可删除线// 设置连接点最多可以链接几条线maxConnections: -1,connectorOverlays: [['Arrow', {width: 8,length: 10,location: 1}]]};}// 给节点添加端点,返回端点idfunction addEndPoint(nodeId, anchors,pointStyle) {let endPointId = nodeId + '-' + getUUID();setTimeout(function() {jsPlumb.addEndpoint(nodeId, {uuid: endPointId,anchors: anchors},pointStyle);}, 30);return endPointId;}function getUUID() {let s = [];let hexDigits = "0123456789abcdef";for(let i = 0; i < 36; i++) {s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);}s[14] = "4";s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);s[8] = s[13] = s[18] = s[23] = "-";let uuid = s.join("");return uuid.replace(/-/g, '');}let config = {baseStyle: makeStyle('base'),dimStyle: makeStyle('dim')};jsPlumb.ready(function () {var pointStyle = config.baseStyle;jsPlumb.setContainer('diagramContainer');   $.getJSON(url,{},function(data){var nodeArr=data.nodeDataArray;		//节点列表var linkArr=data.linkDataArray;		//线段列表nodeArr.forEach(function(item, i){var id = item.key;var ntype=item.nodeType;if(ntype=='comm'){var css="rect_css";$("#diagramContainer").append('<div class="'+css+'" style=\'position: absolute\' id="' + id + '" data-id=" " ><span class="box_text">' + item.text+'</span></div>');$("#diagramContainer").append('<div class="text_box" id="' + id + '_span" style=\'position: absolute\'><p>'+item.desc+'</p>'+'<div>');}else{var css="cir_css";$("#diagramContainer").append('<div class="'+css+'" style=\'position: absolute\' id="' + id + '" data-id=" " ><span class="box_text">' + item.text+'</span></div>');}$("#" + id).css("left", item.locLeft).css("top", item.locTop);jsPlumb.draggable(id);		//开启可以移动});linkArr.forEach(function(item, i){var defaultAnchors = ["Bottom", "Right", "Top", "Left"];// 1、新增端点,一条连接线两个端点//let sourceEndPointId = addEndPoint(item.from, defaultAnchors,pointStyle);//let targetEndPointId = addEndpoint(item.to, defaultAnchors,pointStyle);let endPointId = item.from + '-' + getUUID();jsPlumb.addEndpoint(item.from, {uuid: endPointId,anchors: defaultAnchors},pointStyle);let endPointId2 = item.to + '-' + getUUID();jsPlumb.addEndpoint(item.to, {uuid: endPointId2,anchors: defaultAnchors},pointStyle);jsPlumb.connect({uuids: [endPointId, endPointId2]});//jsPlumb.connect({source:item.from,target:item.to});});});});</script>
</body>
</html>

这篇关于jsPlumb画流程图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/289867

相关文章

240907-Gradio插入Mermaid流程图并自适应浏览器高度

A. 最终效果 B. 示例代码 import gradio as grmermaid_code = """<iframe srcdoc='<!DOCTYPE html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Spa

Mysql 安装的步骤详解,安装流程图详文(每步都 带图 详解)

Mysql的安装流程----详细安装步骤,带图详细。 MySQL5.0版本的安装图解教程是给新手学习的,当前mysql5.0.96是最新的稳定版本。 mysql 下载地址 http://www.jb51.net/softs/2193.html 下面的是MySQL安装的图解,用的可执行文件安装的,详细说明了一下!打开下载的mysql安装文件mysql-5.0.27-win32.zip,双

【流程图】流程图符号

1、常用符号 2、例子(胡乱画的)

流程图符号速查:快速掌握流程图绘制要点

流程图是一种以图形化方式表示算法或过程的步骤和逻辑关系的图表,它通过使用一系列标准的符号和连接线来清晰地展示流程的顺序和决策点。这种表示方法不仅使得复杂的过程更加易于理解,而且也便于跟踪和优化。以下是对流程图的进一步扩写,包括其制作步骤、应用场景和一些实用技巧。流程图常常用来表示一些动态过程,通常会有一个“起点”, 可以有一个或多个终点,流程图可以直观、明确地表示动态过程从开始到结束的全部步骤,在

svg/webvowl 流程图创建

项目链接:https://code.csdn.net/u013372487/webvowl/tree/master

游戏启动器(更新器)流程图

在一个大型的端游项目中做了个启动器,流程是结合其他游戏的流程改进后。我以前也没有做过端游,算是新手吧,欢迎大家指出其中的不足指出!

flowable 根据xml 字符串生成流程图

//获取xml         InputStream stream = repositoryService.getProcessModel(processDefinitionId);                String result = IOUtils.toString(stream, StandardCharsets.UTF_8);         // 创建 X

24年一级消防工程师报名流程图解(建议电脑)

报考流程: 1、登录中国人事考试网,点击网上报名,登录帐户和密.码,找到“一级消防工程师”的报考入口,选择报考省份,进入在线报名界面。 2、报考人员阅读《承诺制告知书》和《报名须知》后,点击“已阅读并知晓”进入报考信息录入界面。 3、报考人员选择考试地点,核查点、报考级别、学历、学位、身份証、单位信息,系统显示相应的科目名称,正面打勾代表本人报考某门考试科目。 4、报考人员填写相关信息后,系统将生

@antv/g6 业务场景:流程图

1、流程图是流经一个系统的信息流、观点流或部件流的图形代表。在企业中,流程图主要用来说明某一过程。这种过程既可以是生产线上的工艺流程,也可以是完成一项任务必需的管理过程。业务场景流程图如下: 2、绘制流程图的 Tips 流程图一般是用标准的符号绘制的,并非严格要求使用这些方框,圆圈,菱形或其它标准的符号来制作一个流程图,但是标准符号确实能更清晰地展示事件的类别。以下是大多数情况常用的一组标

软件设计文档绘图:流程图、数据流图、UML

摘要: 在软件设计过程中,编写详尽的文档是不可或缺的一环,而图形化表达则是这些文档中至关重要的组成部分。为了清晰、直观地展示系统结构、数据处理流程以及设计思想,设计师们常常运用多种图表来辅助说明。其中,最为常用且高效的图形包括流程图、数据流图以及统一建模语言(UML)图。 流程图:流程图是描述一系列顺序性操作步骤的经典工具,它通过图形化的方式展示了从起点到终点的流程逻辑。在软件设计中,流程图