It is available in a free Community edition and a paid Toolkit edition.
The Toolkit edition wraps the Community edition with a comprehensive data binding layer, as well as several UI widgets for building applications and integrations for popular libraries, and is commercially licensed.
Recently, I have tried to develop a simple web app that uses drag and drop components and has lines connecting them. I came across these two simple and amazing javascript libraries:
Plain Draggable: simple and high performance library to allow HTML/SVG element to be dragged.
Joining lines with svgs was worth a shot for me, and it worked perfectly...
first of all, Scalable Vector Graphics (SVG) is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation. SVG images and their behaviors are defined in XML text files. you can create an svg in HTML using <svg> tag. Adobe Illustrator is one of the best software used to create an complex svgs using paths.
Procedure to join two divs using a line :
create two divs and give them any position as you need
(for the sake of explanation I am doing some inline styling but it is always good to make a separate css file for styling)
<svg><line id="line1"/></svg>
Line tag allows us to draw a line between two specified points(x1,y1) and (x2,y2). (for a reference visit w3schools.) we haven't specified them yet. because we will be using jQuery to edit the attributes (x1,y1,x2,y2) of line tag.
I used selectors to select the two divs and line...
var pos1 = div1.position();
var pos2 = div2.position();
jQuery position() method allows us to obtain the current position of an element. For more information, visit https://api.jquery.com/position/ (you can use offset() method too)
Now as we have obtained all the positions we need we can draw line as follows...
as position() returns two values, one 'left' and other 'top', we can easily access them using .top and .left using the objects (here pos1 and pos2) ...
Now line tag has two distinct co-ordinates to draw line between two points.
Tip: add event listeners as you need to divs
Tip: make sure you import jQuery library first before writing anything in script tag
After adding co-ordinates through JQuery ... It will look something like this
Following snippet is for demonstration purpose only, please follow steps above to get correct solution
js-graph.it supports this use case, as seen by its getting started guide, supporting dragging elements without connection overlaps. Doesn't seem like it supports editing/creating connections. Doesn't seem it is maintained anymore.
发布评论
评论(12)
jsPlumb 是一个支持拖放的选项,如其 众多演示,包括 流程图演示。
它有免费的社区版和付费的工具包版。
jsPlumb is an option available that supports drag and drop, as seen by its numerous demos, including the Flowchart demo.
It is available in a free Community edition and a paid Toolkit edition.
最近,我尝试开发一个简单的网络应用程序,它使用拖放组件并用线连接它们。我遇到了这两个简单而令人惊叹的 javascript 库:
工作示例链接(用法:单击“添加场景”创建可拖动对象,单击“添加选项”绘制引导线两个不同之间可拖动)
Recently, I have tried to develop a simple web app that uses drag and drop components and has lines connecting them. I came across these two simple and amazing javascript libraries:
Working example link (usage: click on add scene to create a draggable, click on add choice to draw a leader line between two different draggables)
用 svgs 连接线条对我来说值得一试,而且效果非常好......
首先,可扩展矢量图形(SVG)是一种基于 XML 的矢量图像格式,用于二维图形,支持交互性和动画。 SVG 图像及其行为在 XML 文本文件中定义。您可以使用
标签在 HTML 中创建 svg。 Adobe Illustrator 是用于使用路径创建复杂 svgs 的最佳软件之一。
使用线条连接两个 div 的过程:
创建两个 div 并根据需要给它们任何位置
(为了解释起见,我正在做一些内联样式,但制作一个单独的 css 文件用于样式总是好的)
Line 标签允许我们在两个指定点 (x1,y1) 和 (x2,y2) 之间绘制一条线。 (有关参考,请访问 w3schools。)我们尚未指定它们。因为我们将使用 jQuery 来编辑 line 标记的属性 (x1,y1,x2,y2)。
在
标签中写入
我使用选择器来选择两个 div 和行...
jQuery
position()
方法允许我们获取元素的当前位置。有关更多信息,请访问 https://api.jquery.com/position/ (您可以使用 < code>offset() 方法也是如此)现在我们已经获得了我们需要的所有位置,我们可以如下绘制线条...
jQuery
.attr()
方法用于更改属性所选元素。我们在上面一行中所做的就是将行的属性从 更改
为
position()
返回两个值,一个为“left”,另一个为“top”,我们可以使用 .top 和 .left 轻松访问它们使用对象(此处 pos1 和 pos2)...现在线标记有两个不同的坐标来在两点之间绘制线。
提示:根据需要添加事件侦听器
提示:在脚本标记中写入任何内容之前,请确保先导入 jQuery 库
之后通过 JQuery 添加坐标...它看起来像这样
以下代码片段仅用于演示目的,请按照上述步骤获得正确的解决方案
Joining lines with svgs was worth a shot for me, and it worked perfectly...
first of all, Scalable Vector Graphics (SVG) is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation. SVG images and their behaviors are defined in XML text files. you can create an svg in HTML using
<svg>
tag. Adobe Illustrator is one of the best software used to create an complex svgs using paths.Procedure to join two divs using a line :
create two divs and give them any position as you need
(for the sake of explanation I am doing some inline styling but it is always good to make a separate css file for styling)
<svg><line id="line1"/></svg>
Line tag allows us to draw a line between two specified points(x1,y1) and (x2,y2). (for a reference visit w3schools.) we haven't specified them yet. because we will be using jQuery to edit the attributes (x1,y1,x2,y2) of line tag.
in
<script>
tag writeI used selectors to select the two divs and line...
jQuery
position()
method allows us to obtain the current position of an element. For more information, visit https://api.jquery.com/position/ (you can useoffset()
method too)Now as we have obtained all the positions we need we can draw line as follows...
jQuery
.attr()
method is used to change attributes of the selected element.All we did in above line is we changed attributes of line from
to
as
position()
returns two values, one 'left' and other 'top', we can easily access them using .top and .left using the objects (here pos1 and pos2) ...Now line tag has two distinct co-ordinates to draw line between two points.
Tip: add event listeners as you need to divs
Tip: make sure you import jQuery library first before writing anything in script tag
After adding co-ordinates through JQuery ... It will look something like this
Following snippet is for demonstration purpose only, please follow steps above to get correct solution
几天前我也有同样的要求,
我使用了完整的宽度和高度svg并将其添加到我所有的div下方并添加了动态地将线条添加到这些 svg 中。
在这里查看我如何使用 svg
HTML
https:// /jsfiddle.net/kgfamo4b/
I also had the same requirement few days back
I used an full width and height svg and added it below all my divs and added lines to these svg dynamically.
Checkout the how I did it here using svg
HTML
https://jsfiddle.net/kgfamo4b/
VisJS 通过其 箭头示例,支持可拖动元素。
它还支持可编辑连接,及其交互事件示例。
VisJS supports this with its Arrows example, that supports draggable elements.
It also supports editable connections, with its Interaction Events example.
GoJS 支持这一点,其 状态图示例,支持元素拖放和连接编辑。
GoJS supports this, with its State Chart example, that supports dragging and dropping of elements, and editing of connections.
mxGraph — 由 draw.io — 支持此用例,其 图形编辑器示例。 文档。 示例。
mxGraph — used by draw.io — supports this use case, with its Grapheditor example. Documentation. Examples.
Raphaël 支持这一点,其 Graffle 示例。
Raphaël supports this, with its Graffle example.
D3 有 数百个例子,其中一些适合这个问题。
无需拖放且已修复的示例:
无需拖放的交互式示例:
拖放示例:
D3 has hundreds of examples, some of which are suitable for this question.
Examples without drag and drop, that are fixed:
Examples without drag and drop, that are interactive:
Examples with dragging and dropping:
Cytoscape 以其 支持拖动元素的架构示例。
要创建连接,可以使用 edgehandles 扩展。 尚不支持编辑现有连接。 问题。
用于编辑连接形状,有 edge-editing 扩展。 演示。
< href="https://github.com/sitnarf/cytoscape.js-edge-editation" rel="nofollow noreferrer">edit-editation 扩展看起来很有希望,但还没有演示。
Cytoscape supports this with its Architecture example which supports dragging elements.
For creating connections, there is the edgehandles extension. It does not yet support editing existing connections. Question.
For editing connection shapes, there is the edge-editing extension. Demo.
The edit-editation extension seems promising, however there is no demo yet.
js-graph.it 支持此用例,如其 入门指南,支持拖动元素而无需连接重叠。它似乎不支持编辑/创建连接。好像不再维护了。
js-graph.it supports this use case, as seen by its getting started guide, supporting dragging elements without connection overlaps. Doesn't seem like it supports editing/creating connections. Doesn't seem it is maintained anymore.
JointJS/Rappid 通过其 Kitchensink 示例,支持拖放元素以及重新定位连接。 它有很多示例。
JointJS/Rappid supports this use case with its Kitchensink example which supports dragging and dropping of elements, and repositioning of connections. It has many examples.