基于Web使用andflow_js 画个ER图

andflow_js组件希望可以在网页上设计和展示流程图、架构图、关系图等图形,如今andflow_js 可以用来实现基于Web的ER图。只需要传递 json配置参数即可实现,同时还能通过js函数进行实时读取、调整。

在这里插入图片描述
代码如下:

var flowModel= {
	"code": "",
	"name": "",
	"show_action_body": "true",
	"show_action_content": "true",
	"theme": "flow_theme_default",
	"link_type": "Flowchart",
	"params": [],
	"actions": [],
	"links": [
		{
			"source_id": "list_item_list_86360da09b96477998fa8eb539a39f51_1",
			"target_id": "list_item_list_45b0a819cce542169be1d7e124b250e5_0",
			"label_source": "N",
			"label_target": "1"
		},
		{
			"source_id": "list_item_list_86360da09b96477998fa8eb539a39f51_0",
			"target_id": "list_item_list_cdf17f356147444d9108a010c6370cbe_0",
			"label_source": "N",
			"label_target": "1"
		}
	],
	"groups": [],
	"lists": [
		{
			"id": "list_cdf17f356147444d9108a010c6370cbe",
			"name": "erd",
			"left": "23px",
			"top": "106px",
			"items": [
				{
					"id": "list_item_list_cdf17f356147444d9108a010c6370cbe_0",
					"title": "id"
				},
				{
					"id": "list_item_list_cdf17f356147444d9108a010c6370cbe_1",
					"title": "name"
				},
				{
					"id": "list_item_list_cdf17f356147444d9108a010c6370cbe_2",
					"title": "age"
				},
				{
					"id": "list_item_list_cdf17f356147444d9108a010c6370cbe_3",
					"title": "grade"
				},
				{
					"id": "list_item_list_cdf17f356147444d9108a010c6370cbe_4",
					"title": "phone"
				},
				{
					"id": "list_item_list_cdf17f356147444d9108a010c6370cbe_5",
					"title": "address"
				}
			],
			"title": "students",
			"width": "150px",
			"height": "200px"
		},
		{
			"id": "list_45b0a819cce542169be1d7e124b250e5",
			"name": "erd",
			"left": "543px",
			"top": "103px",
			"items": [
				{
					"id": "list_item_list_45b0a819cce542169be1d7e124b250e5_0",
					"title": "id"
				},
				{
					"id": "list_item_list_45b0a819cce542169be1d7e124b250e5_1",
					"title": "groupname"
				},
				{
					"id": "list_item_list_45b0a819cce542169be1d7e124b250e5_2",
					"title": ""
				},
				{
					"id": "list_item_list_45b0a819cce542169be1d7e124b250e5_3",
					"title": ""
				}
			],
			"title": "group",
			"width": "150px",
			"height": "200px"
		},
		{
			"id": "list_86360da09b96477998fa8eb539a39f51",
			"name": "erd",
			"left": "273px",
			"top": "114px",
			"items": [
				{
					"id": "list_item_list_86360da09b96477998fa8eb539a39f51_0",
					"title": "student_id"
				},
				{
					"id": "list_item_list_86360da09b96477998fa8eb539a39f51_1",
					"title": "group_id"
				},
				{
					"id": "list_item_list_86360da09b96477998fa8eb539a39f51_2",
					"title": ""
				}
			],
			"title": "student_group",
			"width": "150px",
			"height": "200px"
		}
	]
};


    var options={
        tags:tags,            //组件过滤标签列表
        metadata:metadata,    //组件元素
        flowModel:flowModel,  //流程模型
        img_path: "../img/meta/",
        editable:true,   //是否可编辑,默认true
        show_toolbar: true,
        metadata_position: 'default', //top,left,default
        render_action:function(metadata,action,html){ return html; },//节点渲染
        render_action_helper: function(metadata,html){return null},  //节点拖拉渲染
        render_state_list: function(datas){return null},             //流程状态列表渲染
        render_link:function(conn,linktype,linkdata){return null},   //连接线渲染
        event_group_click:function(group){
 
        },
        event_group_dblclick: function(group){
            
        },
        //节点单击事件
        event_action_click:function(metadata,action){
 

        },
        //节点双击事件
        event_action_dblclick:function(metadata,action){
 

        },
        //连线单击事件
        event_link_click: function (link) {
           
        },
        //连线双击事件
        event_link_dblclick: function (link) {

            var label = prompt("set link labels, split by ',' ", (link.label_source||'')+","+(link.label_target||''));
            
            var labels = label.split(",");
            if(labels.length>0){
                link.label_source=labels[0];
            }

            if(labels.length>1){
                link.label_target=labels[1];
            }
            
            andflow.setLinkInfo(link);  
        },

        //画图板单击事件
        event_canvas_click: function(e){
            
        }
    }


    andflow.newInstance("andflow",options);
    andflow.showFlow();

添加公众号,回复andflow,获取源代码
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Zone 7

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值