This is a migrated thread and some comments may be shown as answers.

Auto sizing shapes and overlapping connectors

1 Answer 293 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
B
Top achievements
Rank 1
B asked on 09 May 2016, 10:58 PM

Hi -

I'm trying to figure out how to autosize shapes to fix text and also nicely connect shapes.  For the most part this works, but when there are two shapes that connect back to one another the connectors overlap.  Is there a clean way of dealing with this?

Here is an example:

 

<div id="diagram"></div>
<script>
   
  var conns = [{"from":"338338","to":"338339","Label":"Send to Compliance"},{"from":"338338","to":"338341","Label":"Close Compliant"},{"from":"338339","to":"338338","Label":"Reject to Bank"},{"from":"338339","to":"338340","Label":"Review Complete"},{"from":"338340","to":"338341","Label":"Close Complaint"}];
   
  var nodes = [{"id":"338338","Name":"New Complaint","IsFirst":true},{"id":"338339","Name":"Compliance Review","IsFirst":false},{"id":"338340","Name":"Contact Customer","IsFirst":false},{"id":"338341","Name":"Closed","IsFirst":false}]
   
 $("#diagram").kendoDiagram({
        dataSource: nodes,
        connectionsDataSource:conns,
        layout: {
            type: "tree",
            subtype: "right"
        },
        shapeDefaults: {
            type: "rectangle",
            fill: {
              gradient: {
                type: "linear",
                stops: [{
                  color: "#1696d3",
                  offset: 0,
                  opacity: 0.5
                }, {
                  color: "#1696d3",
                  offset: 1,
                  opacity: 1
                }]
              }
            },
            content: {
                color: "White",
                template: "#= Name #"
            },
            height: 70,
            hover: {
                fill: "Gray"
            }
        },
        connectionDefaults: {
            stroke: {
                color: "#979797",
                width: 1
            },
            type: "polyline",
            startCap: "FilledCircle",
            endCap: "ArrowEnd",
            content:{
                template:"#= Label#"
            }
        },
 
        autoBind: true
    });
   
   
   
   
</script>

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 11 May 2016, 03:20 PM
Hi Brandon,

The connection model has fromConnector and toConnector fields that can be used to configure the end points of the two-way connections such that they do not overlap. You can also define custom connectors via the shapeDefaults.connectors option.

I have modified the provided code sample to illustrate the suggested approach:

http://dojo.telerik.com/AWUgE

Dynamically adjusting the shape width according to its text content is not supported, the width can be set via the shapeDefaults.width option.

I hope this helps.

Regards,
Dimiter Topalov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Diagram
Asked by
B
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or