- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
给定一个像这样的 HTML 结构:
<div id="canvas">
<div class="group group-normal" id="1">hello world</div>
<div class="group group-infiltrated" id="2">whats up dogue</div>
</div>
我目前使用 jsPlumb 从该结构创建图表:
$(function() {
jsPlumb.Defaults.Container = $("div#canvas");
jsPlumb.draggable($("div.group"), {
containment: $("div#canvas")
});
var stateMachineConnector = {
connector: "Bezier",
paintStyle: { lineWidth: 2, strokeStyle: "#056" },
endpoint: "Blank",
anchor: "Continuous",
overlays:[ ["PlainArrow", { location: 1, width: 15, length: 12 } ]]
};
jsPlumb.connect({
source: "1",
target: "2"
}, stateMachineConnector);
});
这已经给了我一个漂亮的、可拖动的图表:
问题是,在初始化图形时,所有 div
都位于 Canvas 的左上角。我了解到这是因为 jsPlumb 只提供布局图形的功能,但不提供定位图形的功能。
然后我进行了寻宝游戏,发现了许多处理定位的有用库,例如 springy、sigma 等。问题是:大多数不对 div 进行操作,而是对某些(对我而言)不透明的 SVG/Canvas 对象图进行操作。
我非常喜欢 jsPlumb,并希望继续使用它。我唯一需要从其他库中获得的是所有元素的初始定位。
如何让元素在可用空间内更均匀地放置,甚至可以让它们每次初始化图形时都以相同的方式排列?
最佳答案
这是用于定位具有连接性的 DIV 的插件:https://github.com/lndb/jsPlumb_Liviz.js基本上插件是从 graphviz 派生的 js库。
您需要通过文本区域(id=dot-src) 将连接信息传递给库。因此,无论何时建立连接,都将连接信息存储在一个字符串中,然后将其传递给 Liviz 库以进行定位。
str='digraph MyGraph {'; // This string will be set to the textarea at the end.
// Whenever connection is created update the string.
jsPlumb.bind("jsPlumbConnection", function(ci) {
console.log($('#'+ci.sourceId).data("prop").dn+"->"+$('#'+ci.targetId).data("prop").dn);
str+=ci.sourceId+"->"+ci.targetId+";";
});
// At the end set the string and call Liviz function
$('#dot-src').text(str+"}"); // Set the string
w_launch(); // call the library to position the DIV's based on connectivity.
您可以探索 graphviz 针对不同类型的选项来自定义定位。
关于javascript - 为给定的 div 结构强制驱逐库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22038228/
每个人都知道 session 中有缓存。 这个缓存通常可以通过两种方法清除: Session.Evict Session.Clear 第二种方法不仅删除单个条目的所有缓存。 我有商业方法。它接收大对象
假设一个小型测试项目(sbt 0.13.8,完整项目为 gist ): name := "test" organization := "org.example" version := "0.1.0-S
我正在寻找一种方法,使 infinispan 的默认驱逐与 TreeCache 实现一起工作。到目前为止,我搜索了文档和谷歌,但没有找到符合我问题的内容。这是 infinispan xml 中缓存的当
我想知道 Apache Cassandra 中的 Ignite 缓存逐出。是否可以将缓存条目逐出 cassandra(如 offhaep/文件逐出)。 正如我从文档( https://apacheig
我希望我知道这个列表中的每个项目到底是什么,它是如何工作的,后果是什么以及何时是正确的使用时间。 刷新 驱逐 复制 冲洗 我什至想知道每个人的作用,但我不太确定,所以我请求你的帮助,因为我真的很想了解
我希望我知道这个列表中的每个项目到底是什么,它是如何工作的,后果是什么以及什么时候是正确的使用时间。 刷新 驱逐 复制 冲洗 我什至想知道每个人是做什么的,但我不确定,所以我请求你的帮助,因为我真的很
当浏览器检测到存储空间非常低时,它可以选择驱逐 Service Worker 的缓存,如 W3C doc 所述。 . 由于我的用户可以选择为离线访问存储他们的预订,我想警告他们浏览器已删除它们。如何从
我计划在我的应用程序中使用 Guava Cache。部分 [K, V] 访问的对在统计上比其他对 >> 并且应该总是在缓存中可用。 根据 Sized Based Eviction 的规范 If you
我似乎无法找到下面看到的第一次驱逐的根本原因。如下所示,运行 evicted 不会提供与其相关的详细信息。 这一切都是在添加到 project/plugins.sbt 之后发生的:libraryDep
我希望以一种不知道集群上运行的应用程序细节的方式执行 Kubernetes 集群的自动滚动更新。原则上,PodDisruptionBudget 应该促进这一点。 问题来了:这个 Kubernetes
我正在将 Jenkins-X 用于一个相对较大的项目,该项目由大约 30 个模块组成,其中 15 个是服务(因此,包含 Dockerfile 和一个用于部署的相应 Helm 图表)。 在其中一些相对较
我是一名优秀的程序员,十分优秀!