前端流程图jsplumb学习笔记
1、这篇博客很好,另外两个是官网文档
http://www.cnblogs.com/leomYili/p/6346526.html
https://jsplumbtoolkit.com/community/apidocs/classes/Connector.html
https://jsplumbtoolkit.com/community/doc/connections.html#draganddrop
2、Jsplump流程图画虚线用"dashstyle": "2 4"
PaintStyle: {
lineWidth: 3,
strokeStyle: color,
"dashstyle": "2 4"
}
3、简单连接
jsPlumb.connect({
source:"window4",
target:"window5",
anchors:["BottomRight","TopLeft"],
paintStyle:{strokeWidth:7,stroke:'rgb(131,8,135)'},
hoverPaintStyle:{ stroke:"rgb(0, 0, 135)" },
endpointStyle:{ width:40, height:40 },
endpoint:"Rectangle",
connector:["Flowchart", { midpoint: 0.8}],
overlays:[
["Label",{label:"FOO",id:"label",location:0.7
}]
]
});
(1)connector:["Flowchart", { midpoint: 0.8}],设置折线抓点的位置,
0-1,越小离源端点越近
(2)label location 0-1, 越小离源端点越近
(3)配置项写法都是name:[“type1”,{option1:value,option2:value2}]
(4)anchors:[[ 0,0.5, -1, 0 ],"RightMiddle"], 用数组自定义anchor位置,
[x,y,dx,dy],x和y为以noder的左上角为起点,向下或向右增加到1。dx、dy指连接线出去的x、y方向矢量的分量,dx/dy组合定义出成一个角度,取值-1到1。-1为向左,向上,1为向右和向下。0分别为垂直和水平方向。
4、 Connection.连接器, Connector连接线是连接器的一个组成要素
5、用css设置connection连接器样式
jsPlumb.connect({
source:"someElement",
target:"someOtherElement",
cssClass: "redLine dashLine",
});
CSS:
svg.redLine path {
stroke: red;
stroke-width: 3;
}
svg.dashLine path {
stroke-dasharray: 5;
}
注svg虚线样式规则参照
https://segmentfault.com/a/1190000007309718
6、动态切换connection paintstyle
instance.registerConnectionType("black", {
paintStyle: {
strokeWidth: 2,
stroke: "#000000",
joinstyle: "round",
outlineStroke: "white",
outlineWidth: 2,
"dashstyle": "2 4"
},
});
var aa = instance.connect({
uuids: ["Window1BottomCenter", "Window2TopCenter"],
editable: true,
type: "black"
});
或aa.setType(“black”)
7、批量加入connection
jsPlumb.ready(function () {
var color = "#0070c0";
var instance = jsPlumb.getInstance({
Connector: ["Straight", { curviness: 2 }],
PaintStyle: {
strokeWidth: 2,
stroke: "#0070c0",
joinstyle: "round",
outlineWidth: 2
},
EndpointStyle: { radius: 1, fillStyle: color },
Container: "canvas"
});
var _addEndpoints = function (nodeId, sourceAnchors, targetAnchors) {
for (var i = 0; i < sourceAnchors.length; i++) {
var sourceUUID = nodeId + "-" + sourceAnchors[i];
instance.addEndpoint(nodeId, {
anchor: sourceAnchors[i], uuid: sourceUUID
});
}
for (var j = 0; j < targetAnchors.length; j++) {
var targetUUID = nodeId + "-" + targetAnchors[j];
instance.addEndpoint(nodeId, { anchor: targetAnchors[j], uuid: targetUUID });
}
};
instance.batch(function () {
var arrowCommon = { foldback: 0.7, fillStyle: color, width: 14 },
overlays = [
["Arrow", { location: 1 }, arrowCommon,],
];
_addEndpoints("nodeSiteInspectionRecordMainCheck", ["RightMiddle"], []);
_addEndpoints("nodeCorrectionInstructionBook", ["RightMiddle"], ["LeftMiddle"]);
_addEndpoints("nodeSiteInspectionRecordRecheck", ["RightMiddle"], ["LeftMiddle"]);
_addEndpoints("nodeCorrectiveReviewOpinions", ["RightMiddle"], ["LeftMiddle"]);
_addEndpoints("nodeArchive", [], ["LeftMiddle"]);
instance.connect({ uuids: ["nodeSiteInspectionRecordMainCheck-RightMiddle", "nodeCorrectionInstructionBook-LeftMiddle"], overlays: overlays });
instance.connect({ uuids: ["nodeCorrectionInstructionBook-RightMiddle", "nodeSiteInspectionRecordRecheck-LeftMiddle"], overlays: overlays });
instance.connect({ uuids: ["nodeSiteInspectionRecordRecheck-RightMiddle", "nodeCorrectiveReviewOpinions-LeftMiddle"], overlays: overlays });
instance.connect({ uuids: ["nodeCorrectiveReviewOpinions-RightMiddle", "nodeArchive-LeftMiddle"], overlays: overlays });
});
jsPlumb.fire("jsPlumbDemoLoaded", instance);
});
8、配置事件以及label位置内容配置
label压线问题:(1)用jquery修改top。避免label压住水平方向的连线
var flowchartWindow1_flowchartWindow2_connection = jsPlumb.connect({
});
flowchartWindow1_flowchartWindow2_connection.setLabel({
label: "上级立案上级立案上级立案",
location: 0.2,
cssClass: "connection-label"
});
var label = flowchartWindow1_flowchartWindow2_connection.getLabelOverlay().canvas;
var originTop = $(label).position().top;
$(label).css("top", originTop - 30 + "px");
(2)而且将label的marginleft设置成width的一半多点,避免label压住垂直方向的连线
.remarksLabel {
color: #ff0000;
font-size: 8px;
width: 80px;
height: 40px;
margin-left: 45px;
}
1、 菱形节点,用css实现,背景图片
2、 节点旁边的标注,在nodetext边添加label标识
3、 后台连接器(connection)数据模型整理
(1)sourceNodeId string 源节点id,要与页面的id一致;
(2)targetNodeId string 目标节点id,要与页面的id一致;
(3)ConnectionCssClass string要与页面的css名类一致;;
(4)anchors:两种类型:[[ 0,0.3, -1, 0 ],"RightMiddle"]和[“LeftMiddle”,"RightMiddle"]
统一做成数值型的[[ 0,0.3, -1, 0 ], [ 0,0.3, -1, 0 ]]
(5)ConnectorMidpoint: double折点比例位置
(6)LabelText:string 连旁标签内容
(7)LabelLocation:double 标签在连线上的位置
jsPlumb.connect({
source: "flowchartWindow1",
target: "flowchartWindow2",
cssClass: "redline dashline",
anchors:[[ 0,0.3, -1, 0 ],"RightMiddle"],
connector:["Flowchart", { midpoint: 0.9}],
overlays: [
["Label", {
label: "上级立案上级立案上级立案",
id: "label",
location:0.6
}]
]
});
4、 后台节点数据模型
{
"NodeId": "nodeSiteInspectionRecordMainCheck",
"SystemName": "SiteInspectionRecord",
"WriteStateCssClassName": "finished",
"MissionId": "574A979F-4471-4441-A6B3-493B3F6479FA",
"IsWritedByApp": "false",
"HasAttachmentFiles": "true"
},
7、connection.setLabel({
label: "上级立案上级立案上级立案",
location:0.8,
cssClass:"connection-label"
});
8、 jsPlumb.select().addClass("dashLine");
获取连接器增加css类
9、anthor常用值
RightMiddle { 1, 0.5, 1, 0 }
LeftMiddle{ 0, 0.5, -1, 0 } ,
BottomCenter{ 0.5, 1, 0, 1 },
TopCenter{ 0.5, 0, 0, -1 }
右左{{ 1, 0.5, 1, 0 },{ 0, 0.5, -1, 0 } }
下上{{ 0.5, 1, 0, 1 },{ 0.5, 0, 0, -1 } }
10、项目实践
详情参见市安监
前端流程图jsplumb学习笔记的更多相关文章
- jsPlumb学习笔记
这就是一个给元素画连接线的工具. <!DOCTYPE html> <html> <head> <title>jsPlumb</title> ...
- jsPlumb 学习笔记
介绍 使用svg完成画图,四个概念: anchor: endpoint在的位置,可通过name访问 endpoint:connection的一端节点,通过addPoint makeSource, co ...
- 前端开发——HTML学习笔记
HTML03
- 前端flex布局学习笔记
flex布局,即为弹性布局,其为盒模型提供最大的灵活性,任何一个容器都可以指定为flex布局. eg:.box{ display:flex: } 行内元素也可以使用flex布局. 注意:设置flex布 ...
- 今日前端框架Vue学习笔记
在线网页网址http://xingxunxinxi.com/StudentCourse/first.html代码 界面
- 前端框架vue学习笔记:环境搭建
兼容性 不兼容IE8以下 Vue Devtools 能够更好的对界面进行审查和调试 环境搭建 1.nodejs(新版本的集成了npm)[npm是node包管理 node package manager ...
- 前端框架vue学习笔记
占坑
- 前端html基础学习笔记二
表单 1 : 表单标签 <form></form> 属性 : action = '接口地址' method = 'get / post' name = '表单名称' 2 : 表 ...
- CSS3与页面布局学习笔记(八)——浏览器兼容性问题与前端性能优化方案
一.浏览器兼容 1.1.概要 世界上没有任何一个浏览器是一样的,同样的代码在不一样的浏览器上运行就存在兼容性问题.不同浏览器其内核亦不尽相同,相同内核的版本不同,相同版本的内核浏览器品牌不一样,各种运 ...
随机推荐
- 如果是多个 c 代码的源码文件,编译方法如下: $ gcc test1.c test2.c -o main.out $ ./main.out test1.c 与 test2.c 是两个源代码文件。
如果是多个 c 代码的源码文件,编译方法如下: $ gcc test1.c test2.c -o main.out $ ./main.out test1.c 与 test2.c 是两个源代码文件.
- 深谈CDQ分治
关于CDQ分治我想我自己做过前面的题应该会了这种思想了吧,然后我是真的“会了”. 我想针对于偏序问题我是会了,我现在只会三维偏序了,脑子都是疼的. 但是 CDQ分治最主要的还是基于时间方面的分治思想, ...
- 【JMeter】基础元件
测试计划(Test Plan) 它用来描述一个测试方案,包含与本次性能测试所有相关的功能.也就说本次测试的所有内容是于基于一个计划的. “函数测试模式”复选框,如果被选择,它会使Jmeter记录来自服 ...
- 【接口】【面试题】http协议相关面试题
浏览器输入 url 按回车背后经历了哪些? 1.在 PC 浏览器的地址栏输入一串 URL,然后按 Enter 键这个页面渲染出来,这个过程中都发生了什么事? 1.首先,在浏览器地址栏中输入 url,先 ...
- 关于ARMv8另外几个问题
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/qianlong4526888/article/details/27510675 问题1:支持ARMv ...
- Python3学习之路~5.6 shutil & zipfile & tarfile模块
高级的 文件.文件夹.压缩包 处理模块 shutil.copyfileobj(fsrc, fdst[, length])#将文件内容拷贝到另一个文件中,可以部分内容 shutil.copyfile(s ...
- uploadify3.2.1的参数设置
$('#file_upload').uploadify({ auto:false, //接受true 或 false两个值,当为true时选择文件后会自动上传:为false时只会把选择的文件增加进队列 ...
- IE8“开发人员工具”(上)
认识“开发人员工具” 开发人员工具在IE8的工具菜单下,或者直接点击F12快捷键也可以呼叫出来. 提供一系列的小工具,让你可以方便的查找页面的bug,包括html代码.css代码和JavaScript ...
- 云锁-安全,易用,灵活的许可-Virbox许可管理平台
云许可,助力开发者保护软件财富 Virbox 云锁提供高强度加密及软件许可管理功能 安全,易用,灵活 防破解 云许可安全性体验与硬件锁一致,避免盗版导致损失 加密保护技术:反黑引擎/碎片代码执行/虚拟 ...
- 小程序编辑器vscode
安装中文版 1)打开vscode工具: 2)使用快捷键组合[Ctrl+Shift+p],在搜索框中输入“configure display language”,点击确定后: 3)如图所示 =>安 ...