joint+rappid实现流程图拖拽连线绘制效果代码

代码语言:html

所属分类:图表

代码描述:joint+rappid实现流程图拖拽连线绘制效果代码

代码标签: joint rappid 流程图 拖拽 连线 绘制

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/rappid.3.7.3.css">
  
<style>
#stencil-container {
  position: absolute;
  left: 0;
  top: 0;
  width: 100px;
  bottom: 0;
}

#paper-container {
  position: absolute;
  right: 0;
  top: 0;
  left: 100px;
  bottom: 0;
}

#logo {
  position: absolute;
  bottom: 20px;
  right: 0;
}

.joint-tool circle {
  fill: #000;
}

.joint-stencil .joint-element {
  transition: transform 0.2s;
}
</style>

  
</head>

<body translate="no">
  <div id="stencil-container"></div>
<div id="paper-container"></div>

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/lodash.4.17.21.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/backbone-min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/rappid.3.7.3.js"></script>
      <script  >
"use strict";
const { dia, ui, shapes, elementTools } = joint;
const graph = new dia.Graph({}, { cellNamespace: shapes });
const paper = new dia.Paper({
    model: graph,
    cellViewNamespace: shapes,
    width: "100%",
    height: "100%",
    gridSize: 20,
    drawGrid: { name: "mesh" },
    async: true,
    sorting: dia.Paper.sorting.APPROX,
    restrictTranslate: true,
    background: { color: "#F3F7F6" },
    defaultLink: () => new shapes.standard.Link(),
    defaultConnectionPoint: { name: "boundary" }
});
document.getElementById("paper-container").appendChild(paper.el);
const stencil = new ui.Stencil({
    paper,
    usePaperGrid: true,
    width: 100,
    height: "100%",
    paperOptions: () => {
        return {
            model: new dia.Graph({}, { cellNamespace: shapes }),
            cellViewNamespace: shapes,
            background: {
                color: "#FCFCFC"
            }
        };
    },
    layout: {
        columns: 1,
        rowHeight: "compact",
        rowGap: 10,
        columnWidth: 100,
        marginY: 10,
        // reset defaults
        resizeToFit: false,
        dx: 0,
        dy: 0
    }
});
stencil.render();
document.getElementById("stencil-container").appendChild(stencil.el);
const elements = [
    {
        type: "standard.Rectangle",
        size: { width: 80, height: 60 },
        attrs: {
            body: {
                fill: "#80ffd5"
            }
       .........完整代码请登录后点击上方下载按钮下载查看

网友评论0