# 业务关系图JS连线组件 **Repository Path**: flyer555_admin/startwe_line ## Basic Information - **Project Name**: 业务关系图JS连线组件 - **Description**: 纯div+css3实现模拟画线条功能,用于前端业务关系图绘制的连线组件 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 4 - **Created**: 2018-08-10 - **Last Updated**: 2023-01-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 业务关系图JS连线组件 #### 项目介绍 纯div+css3实现模拟画线条功能,用于前端业务关系图绘制的连线组件 #### 软件架构 软件架构说明 使用前端模板引擎 artTemplate, jquery, 数学计算方程库algebra div+css3实现 轻量级的纯div连线组件 #### 安装教程 ### 1、引入 css: third/shape/shape.css 2. 引入jquery: third/jquery/jquery-2.1.4.min.js 3、引入artTemplate: third/template/template_debug_3_0_0.js 4、引入 algebra 数学公式计算库:third/algebra/algebra-0.2.5.min.js 5、引入画线图形组件库:third/shape_min/shape.min.js #### 使用说明 1. 承载线条和div层的容器样式代码参考 ### .paper-area { background-color: #ffffff; z-index: 1; position: relative; margin: 30px auto; overflow: hidden; display: block; box-shadow: rgba(0, 0, 0, 0.31) 0 0 13px; } .paper-area .paper-area{ background-color: transparent; margin: 0 auto; z-index: 0; } ### 2. div层代码参考 .control-abs-component{ background-color: rgba(255,255,255,.7); width: 140px; height: 42px; padding: 5px; font-size: 0; display: block; border: 1px solid transparent; position: absolute; left: 0; top: 0; z-index: 1; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } ### 3、线条自定义样式参考 .ours-line-text .text-color{ color: #ffffff; } ### 4、body内html代码 参考 ####
a
b
c
d
5、Js调用部分 #### var CurrEvents = { click:function(cfg){ var fromShapeId = $(cfg.el).attr('from-shape-id'); var toShapeId = $(cfg.el).attr('to-shape-id'); alert('click--> fromId:'+fromShapeId+',toShapeId:'+toShapeId); console.log('click--> fromId:'+fromShapeId+',toShapeId:'+toShapeId); }, click4text:function(cfg){ var fromShapeId = $(cfg.el).attr('from-shape-id'); var toShapeId = $(cfg.el).attr('to-shape-id'); alert('clickText--> fromId:'+fromShapeId+',toShapeId:'+toShapeId); console.log('clickText--> fromId:'+fromShapeId+',toShapeId:'+toShapeId); }, mouseenter4text:function(cfg){ var fromShapeId = $(cfg.el).attr('from-shape-id'); var toShapeId = $(cfg.el).attr('to-shape-id'); console.log('mouseenter4text--> fromId:'+fromShapeId+',toShapeId:'+toShapeId); }, mouseleave4text:function(cfg){ var fromShapeId = $(cfg.el).attr('from-shape-id'); var toShapeId = $(cfg.el).attr('to-shape-id'); console.log('mouseleave4text--> fromId:'+fromShapeId+',toShapeId:'+toShapeId); } }; /** * 绑定元素属性说明 * * targets-json="[{"hasArrow":false,"hasFromArrow":true,"lineText":"连线1"}]" * to-ids="ctrl_806025145230846776" * * targets-json为json数组[{ * hasArrow, 是否在目标元素位置有箭头 * hasFromArrow,//是否在出发元素位置有箭头 * lineText //连线的文本内容 * }] * to-ids为目标连线id列表 * ****/ ours.buildShapeLines('.control-abs',{ container:'.page-abs', //指定 渲染容器 cls:'', textCls:'text-color',//文本自定义样式 color:'pink', //线条颜色 lineHeight:2,//线条粗细, zIndex:1, click:'CurrEvents.click',//点击事件绑定函数 click4text:'CurrEvents.click4text', //线条文本点击事件 mouseenter4text:'CurrEvents.mouseenter4text',//线条文本鼠标移入事件 mouseleave4text:'CurrEvents.mouseleave4text'//线条文本鼠标移除事件 }); //参考代码 lib/third/shape_min/test-shape.html #### 参与贡献 1、请加入QQ群438860596交流 2、联系作者 QQ:944811924