Giter Club home page Giter Club logo

dag-diagram's Introduction

VUE DAG diagram

=========== for English guide , click there

DEMO DEMO 国内用

使用说明

B站视频 https://www.bilibili.com/video/av80288517/

重要提醒

老版本为vue2, node版本16以上强烈建议使用vue3版本. 示例项目安装方法为joao-cli安装 npm install -g joao-cli joao init 根据提示输入新建项目名称 cd project npm i && npm run dev 打开localhost:5173 localhost:5173/dag就是示例页面

效果展示

  • 画布移动 / 复原 [图片上传中...(画布缩放.gif-823313-1567493208259-0)]

  • 画布缩放 / 复原 画布缩放.gif

  • 拖动节点 节点拖动gif.gif

  • 框选拖动多个节点 框选拖动gif.gif

  • 添加节点 添加节点gif.gif

  • 删除节点 删除节点.gif

  • 添加节点关系 添加节点关系gif.gif

  • 删除节点关系 删除节点关系gif.gif

  • 添加节点入口 / 出口 节点出入口添加gif.gif

  • 展示模型训练流程 ( 自定义用法需自行开发 ) 节点训练gif.gif

使用方法

  • 基础安装
npm install --save dag-board

vue项目的main.js中

import DAGBoard from 'dag-board'
Vue.use(DAGBoard)

具体文件里中

    <DAGBoard :DataAll="DataAll" @updateDAG="updateDAG" @editNodeDetails="editNodeDetails"></DAGBoard>
DataAll: 数据源
updateDAG:每次动作行为会抛出最新的数据, 和对应事件名称.
editNodeDetails: 可选内容,右键点击节点会带出节点数据,用此方法接受, 进行二次开发.比如更改节点携带的数据等.
  • 高级安装 (动态添加节点的时候模拟用)
    <node-bus v-if="nodeBusDragging" //  是否正在添加节点
    :value="nodeName"                       //   模拟的节点名称
    :pos_x="nodeBusPositionX"          //   动态赋值 鼠标位置的x坐标 
    :pos_y="nodeBusPositionY" />      //   动态赋值 鼠标位置的y坐标

以上内容均可前往github 下载项目查看使用过程, 熟练使用vue即可无障碍阅读代码.

数据源的扩展性 / 样式自定义

为了更多同学能友好体验,在github右侧有JSON模拟器.使用如下图.

  • 节点自定义 节点自定义.gif
一份完整的节点包括以下几个内容
{
			"id": 1,                             // 节点id
			"in_ports": [ 0 ],                   // 入口下标
			"name": "NODE_PARENT",               // 节点名称
			"out_ports": [ 0, 1 ],               // 出口下标
			"pos_x": 157,                        // 节点坐标 距离左侧
			"pos_y": 120,                        // 节点坐标 距离顶部
			"nodeStyle": {                       /* 非必要 节点样式 */ 
				"border": "2px solid red"
			},
			"iconStyle": {                       /* 非必要 节点icon样式 */
				"background": "red"
			},
			"iconClassName": "el-icon-link",     /* 非必要  节点icon的类名 */
			"nameDescribe": "气泡内容",           /* 非必要 气泡内容 */               
		},
  • 节点关系自定义 节点关系自定义gif.gif
// 一份完整的节点关系包括以下几个内容
"edges": [
		{
			"dst_input_idx": 0,  // 目标节点出口的下标
			"dst_node_id": 2,    // 目标节点的id
			"id": 1,             // 节点的id
			"src_node_id": 1,    // 来源节点的id
			"src_output_idx": 0  // 来源节点的入口下标
            "style": { }      /* 非必要 自定义节点样式 */
		}
	],

很多内容致敬了阿里PAI的早期样式

如果使用当中有任何问题或者实现不了的需求,

可以qq群艾特我.793841737.

更新说明 2020年10月17日15:44:49

增加了删除按钮的取消范围 增加了path的可选范围 正在做自动布局

更新说明 2020年04月29日17:30:15

增加新示范页, 可以进行节点拖拽添加,及单节点表单信息编辑功能,以帮助新用户快速上手.

更新说明 2019-12-04 15:55:15

增加横版模式 ( demo页点击右上角 change version 体验 )

开启横版模式
缓存放入
GlobalConfig: {
  isVertical: Boolean // true是默认模式 false为横版模式
}

拖拽更加顺滑 缩放效率更加合理

更新说明 2019年09月23日17:34:22

节点可以添加

  rightClickEvent": [
				{
					"label": "do some thing1",
					"eventName": "eventOfDoSomeThingFirst"
				},
				{
					"label": "do some thing2",
					"eventName": "evnetOfDoSomeThingSecond"
				}
			],

属性来实现私有方法追加, 右键的面板会展示私有方法名.点击可以触发 doSthPersonal方法, 第一个参数为你定义的方法名, 第二个参数可以拿到节点id, 具体看demo即可.

    <DAGBoard :DataAll="DataAll" @updateDAG="updateDAG" @editNodeDetails="editNodeDetails" @doSthPersonal="doSthPersonal"></DAGBoard>

更新说明 2019年10月09日12:26:25

节点可以添加

  edgesText
  textStyle
  {
			"dst_input_idx": 0,
			"dst_node_id": 2,
			"id": 1,
			"src_node_id": 1,
			"src_output_idx": 3,
			"edgesText": "example text"
		},
		{
			"dst_input_idx": 1,
			"dst_node_id": 3,
			"id": 2,
			"src_node_id": 1,
			"src_output_idx": 1,
			"edgesText": "personal style",
			"textStyle": {
				"fontSize": "12px",
				"stroke": "yellow"
			}
		},

属性来实现文字的展示, edgesText是文字内容, textStyle是文字的私有样式,注意是svg的标签, 字段与普通dom不同

dag-diagram's People

Contributors

hsywhu avatar murongqimiao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dag-diagram's Issues

Right-click menu is sometimes blocked

The right-click menu will be partially hidden if the node is at the bottom or the right side of the canvas since the menu is always expanded at the bottom right of the click place.
image
image

Is it possible to change the place to show the menu in these situations? For example, make the menu shows on top of the click place if it's near the bottom of the canvas.

license issue

You may add a license to show what others can do with your repo, I suggest friendly license like MIT.

您好,请问节点删除的时候,触发updateDAG后如何拿到节点的id?

您好,请问节点删除的时候,触发updateDAG后如何拿到节点的id?
目前在使用时右键删除某节点时进行debug发现,在updateDAG方法中可以拿到action,但是获取到的id是空的,请问如何或者被删除节点的id呢?多谢!!
另外节点右键弹出的菜单可以自己定义成中文吗?再次感谢,盼复!

support auto layout ?

first of all , thanks for your great work, it inspire me a lot , and I maybe write a react version according to your sourcecode.

my question is : if the node has no position(posi_x,posi_y) attribute , now can the diagram support auto layout ?

谷歌浏览器下锚点显示不全

谷歌浏览器中hover到锚点上拖动连线时锚点只显示了一半,另一半遮挡住了,在Safari浏览器上正常,你线上的demo也是一样,希望能看一下

我该怎么部署

我将源码下载下来了,然后在本地能成功运行,可是怎么都无法打包到dist文件夹,我想部署到服务器

自动布局

你好请问一下 什么时候能出一个自动布局的功能。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.