jsplumb.js是一款流程图绘制插件

jsplumb.js是一款流程图绘制插件

jsplumb.js是web在线流程设计插件,可以实现viso的效果,用于制作流程图效果。

使用方式:

第一步引入bfwone 加载依赖项jsplumb

<script id="bfwone" data="dep=jsplumb&err=0" type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/bfwone.js"></script>

第二步准备dom元素

    <div id="diagramContainer">
        <div id="item_left" class="item">
            1
        </div>
        <div id="item_right" class="item" style="Left:300px;top:100px;">
            2
        </div>
    </div>

第三步配置参数

jsPlumb.ready(function () {
                jsPlumb.setContainer('diagramContainer')

                var common = {
                    isSource: true,
                    isTarget: true,
                    connector: 'Bezier',
                    endpoint: 'Dot',
                    paintStyle: {
                        fill: 'white',
                        outlineStroke: 'blue',
                        strokeWidth: 1
                    },
                    hoverPaintStyle: {
                        outlineStroke: 'lightblue'
                    },
                    connectorStyle: {
                        outlineStroke: 'green',
                        strokeWidth: 1
                    },
                    connectorHoverStyle: {
                        strokeWidth: 1
                    }
                };

                jsPlumb.addEndpoint('item_left', {
                    anchors: ['Right']
                }, common);

                jsPlumb.addEndpoint('item_right', {
                    anchor: 'Left'
                }, common);

                jsPlumb.addEndpoint('item_right', {
                    anchor: 'Right'
                }, common);
                jsPlumb.draggable('item_left');
                jsPlumb.draggable('item_right');
            })

具体示例如下

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>BFW NEW PAGE</title>
    <script id="bfwone" data="dep=jsplumb&err=0" type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/bfwone.js"></script>
    <script type="text/javascript">
        bready(function() {
            jsPlumb.ready(function () {
                jsPlumb.setContainer('diagramContainer')

                var common = {
                    isSource: true,
                    isTarget: true,
                    connector: 'Bezier',
                    endpoint: 'Dot',
                    paintStyle: {
                        fill: 'white',
                        outlineStroke: 'blue',
                        strokeWidth: 1
                    },
                    hoverPaintStyle: {
                        outlineStroke: 'lightblue'
                    },
                    connectorStyle: {
                        outlineStroke: 'green',
                        strokeWidth: 1
                    },
                    connectorHoverStyle: {
                        strokeWidth: 1
                    }
                };

                jsPlumb.addEndpoint('item_left', {
                    anchors: ['Right']
                }, common);

                jsPlumb.addEndpoint('item_right', {
                    anchor: 'Left'
                }, common);

                jsPlumb.addEndpoint('item_right', {
                    anchor: 'Right'
                }, common);
                jsPlumb.draggable('item_left');
                jsPlumb.draggable('item_right');
            })
        });
    </script>
    <style>
        #diagramContainer {
            position: relative;
            padding: 20px;
            width: 80%;
            height: 400px;
            border: 1px solid gray;

        }
        .item {
            position: absolute;
            width: 100px;
            background: green;
            text-align: center;
            line-height: 100px;
            color: white;
            height: 100px;
        }
    </style>
</head>
<body>
    <div id="diagramContainer">
        <div id="item_left" class="item">
            1
        </div>
        <div id="item_right" class="item" style="Left:300px;top:100px;">
            2
        </div>
    </div>
</body>
</html>

项目webide地址:

http://project.bfw.wiki/project/15728527036129520019.html


立即下载jsplumb.js查看所有js插件

网友评论0

程序员在线工具箱