Jquery jsPlumb-如何获得锚点';s位置

Jquery jsPlumb-如何获得锚点';s位置,jquery,jsplumb,Jquery,Jsplumb,我试图保存并加载jsPlumb流程图,但在重新创建连接时遇到问题。当我尝试加载时,它们彼此重叠。图1显示了我如何保存流程图,图2显示了如何加载流程图 我看过主题和一个主题,使用endpoint.anchor.x和endpoint.anchor.y或connectionInfo.sourceEndpoint.anchor.x或connectionInfo.sourceEndpoint.anchor.ysimple不起作用。如果我用console.log打印它,它会显示undefined。我不知

我试图保存并加载jsPlumb流程图,但在重新创建连接时遇到问题。当我尝试加载时,它们彼此重叠。图1显示了我如何保存流程图,图2显示了如何加载流程图


我看过主题和一个主题,使用
endpoint.anchor.x
endpoint.anchor.y
connectionInfo.sourceEndpoint.anchor.x
connectionInfo.sourceEndpoint.anchor.y
simple不起作用。如果我用
console.log
打印它,它会显示
undefined
。我不知道这是关于版本还是其他什么的,但看起来“anchor”没有“x”和“y”。我正在使用jsPlumb 1.5.5

我用
控制台.log打印了
连接
以查看其属性,并使用
connection.endpoints[0].endpoint.x
connection.endpoints[0]。endpoint.y
connection.endpoints[1].endpoint.x
connection.endpoints[1]。endpoint.y

其中:0为源端点;1是目标终点;x和y是它们各自的x和y坐标

更新 详细信息现在包含在
endpoint
anchor
对象中,如下所示:

connection.endpoints[0].anchor.x
connection.endpoints[0]。anchor.y
connection.endpoints[1].anchor.x
connection.endpoints[1].anchor.y
请参见我的jsplumb:

您可以创建流程图并保存json。重新加载页面,粘贴保存的json,然后单击load,它将重新创建流程图,保存所有对象和连接的坐标

获取锚位置的代码如下所示:

    $.each(jsPlumb.getConnections(), function (idx, connection) {
    connections.push({
        connectionId: connection.id,
        pageSourceId: connection.sourceId,
        pageTargetId: connection.targetId,
        anchors: $.map(connection.endpoints, function(endpoint) {

            return [[endpoint.anchor.x, 
            endpoint.anchor.y, 
            endpoint.anchor.getOrientation()[0], 
            endpoint.anchor.getOrientation()[1],
            endpoint.anchor.offsets[0],
            endpoint.anchor.offsets[1]
        ]];

  })
    });
});

如何使用锚点x和y重新绘制连接?你能分享一些代码吗@首先重新创建连接:connection=instance.connect({source:sourceId,target:targetId});然后我将其设置为:connection.endpoints[0].endpoint.x=xSource;connection.endpoints[0]。endpoint.y=ySource;connection.endpoints[1].endpoint.x=xTarget;connection.endpoints[1]。endpoint.y=y目标;如果你想让我说得更清楚,别麻烦问了,我很乐意帮助你,我也能做到。目前,我面临着这个问题——我们有一个流程图,每个组件中有两个端点,我们当然不会同时使用这两个端点。但是,当我们恢复图表时,我们应该显示那些未使用的空端点。我很快就检查了一遍,但没有找到帮助。我没有弄清楚。“显示那些未使用的空端点”是什么意思?我也使用流程图,但只有一个端点,如果使用多个端点,我看不出有问题。。我正在使用instance.makeSource(…)和instance.makeTarget(…)重新创建我的组件,这样我的组件就有一个端点(如果有更多端点就不会有问题),然后我使用我在上面编写的代码设置连接
makeSource
makeTarget
工作正常,但是我们无法适当地拖动。不管怎么说,我终于想出了解决办法,谢谢!