如何在JsPlumb中与边缘建立连接?

con*_*ile 10 html javascript css jquery jsplumb

如何设置一个JsPlumb连接,该连接在中间分割并转到多个端点,如下图所示?

答:用一个连接连接两个端点:

在此输入图像描述

B:使用一个连接连接两个端点:

在此输入图像描述

C:使用一个连接连接三个端点:

在此输入图像描述

编辑:使用FlowChart选项,我得到一个小点的奇怪错误,请参见下图.

在此输入图像描述

its*_*oma 13

下面链接到jsfiddle与脚本.所有蓝色块都是可拖动的,因此您可以尝试块位置和连接行为.

我很抱歉这么大的答案;)

答:用一个连接连接两个端点:

http://jsfiddle.net/TkyJB/2/

在此输入图像描述

jsPlumb.ready(function() {

    // default settings for connectors
    var connectionParams = {
        connector: ["Flowchart", {cornerRadius:1}],
        paintStyle:{ 
            lineWidth: 1,
            outlineColor:"blue",
            outlineWidth: 0
        },
        detachable:false,
        endpointStyle: { radius:1 }
    };

    // w2 <=> w1
    jsPlumb.connect({
        source: "window2", 
        target: "window1",
        anchors: ["TopCenter", "Left"]
    }, connectionParams);

    // w2 <=> w2
    jsPlumb.connect({
        source: "window2", 
        target: "window3",
        anchors: ["BottomCenter", "Left"]
    }, connectionParams);

    //
    jsPlumb.draggable(
        jsPlumb.getSelector(".window"),
        { containment:".demo"}
    );
});
Run Code Online (Sandbox Code Playgroud)

B:使用一个连接连接两个端点:

jsPlumb规则:2个窗口之间的一个连接.因此,如果您需要最终划分某些连接,则需要创建代理点,该代理点将作为一个寡妇的源,并将为其他窗口创建2个新连接.

http://jsfiddle.net/TkyJB/8/

在此输入图像描述

jsPlumb.ready(function() {

    // default settings for connectors
    var connectionParams = {
        connector: ["Flowchart", {cornerRadius:1}],
        paintStyle:{ 
            lineWidth: 1,
            outlineColor:"green",
            outlineWidth: 0
        },
        detachable:false,
        endpointStyle: { radius:1 }
    };

    // w1 <=> w1s
    jsPlumb.connect({
        source: "window1", 
        target: "window1s",
        anchors: ["Right", "Center"],
        anchor:[ "Perimeter", { shape:"Circle" } ]
    }, connectionParams);

    // w1s <=> w2
    jsPlumb.connect({
        source: "window1s", 
        target: "window2",
        anchors: ["Center", "Bottom"]
    }, connectionParams);

    // w1s <=> w3
    jsPlumb.connect({
        source: "window1s", 
        target: "window3",
        anchors: ["Center", "Top"]
    }, connectionParams);

    //
    jsPlumb.draggable(
        jsPlumb.getSelector(".window"),
        { containment:".demo"}
    );
});
Run Code Online (Sandbox Code Playgroud)

C:使用一个连接连接三个端点:

它与'B'中的相同,但具有额外的隐藏代理块.

http://jsfiddle.net/TkyJB/7/

在此输入图像描述

jsPlumb.ready(function() {

    // default settings for connectors
    var connectionParams = {
        connector: ["Flowchart", {cornerRadius:1}],
        paintStyle:{ 
            lineWidth: 1,
            outlineColor:"blue",
            outlineWidth: 0
        },
        detachable:false,
        endpointStyle: { radius:1 }
    };

    // w1 <=> w1s1
    jsPlumb.connect({
        source: "window1", 
        target: "window1s1",
        anchors: ["Right", "Center"]
    }, connectionParams);

    // w1s1 <=> w1s2
    jsPlumb.connect({
        source: "window1s1", 
        target: "window1s2",
        anchors: ["Center", "Center"]
    }, connectionParams);

    // w1s1 <=> w2
    jsPlumb.connect({
        source: "window1s1", 
        target: "window2",
        anchors: ["TopCenter", "Left"]
    }, connectionParams);

    // w1s1 <=> w3
    jsPlumb.connect({
        source: "window1s1", 
        target: "window3",
        anchors: ["BottomCenter", "Left"]
    }, connectionParams);

    // w1s2 <=> w4
    jsPlumb.connect({
        source: "window1s2", 
        target: "window4",
        anchors: ["Right", "Left"]
    }, connectionParams);

    //
    jsPlumb.draggable(
        jsPlumb.getSelector(".window"),
        { containment:".demo"}
    );

});
Run Code Online (Sandbox Code Playgroud)