Nevron Forum

How to autosize the edges to contain text

https://www.nevron.com/Forum/Topic4357.aspx

By Sandor Nagy - Tuesday, October 19, 2010

Hi,
I'm using the NGraphDataSourceImporter class to import vertices and edges. For the layout I'm using NLayeredGraphLayout.

In the event of a vertex is imported (NGraphDataSourceImporter.VertexImported) I set the text of the vertex then I call the NShape.SizeToText(New NMarginsF(10)) method to resize automatically the vertex based on its content.

I try the same in case of edges (in the NGraphDataSourceImporter.EdgeImported event). Here is my code:
Private Sub OnEdgeImported(ByVal importer As NDataSourceImporter, ByVal shape As NShape, ByVal dataRecord As INDataRecord)
Dim text As Object = dataRecord.GetColumnValue("LinkTitle")
shape.Text = text.ToString()
Dim label As NLogicalLineLabel = CType(shape.Labels.GetChildAt(0), NLogicalLineLabel)
label.UseLineOrientation = True
shape.SizeToText(New NMarginsF(10))
End Sub
But this is not resizes the edge (see the attached screenshot)

How can I resize automaticaly the edged?

Thanks,
Sandor Nagy
By Nevron Support - Thursday, October 21, 2010

Hi,

the edges cannot be sized to their text. Their size depens entirely on the distance between the shapes they connect and the type of the edge.

In your case, you can simply increase the LayerSpacing property of the Layered Graph Layout.

By Sandor Nagy - Thursday, October 21, 2010

Hi,
The suggested LayerSpacing controls the distance between all of the vertices.
How can I set the minimum distance between two vertices? Or can I set a margin around just one vertex?

Thanks,
Sandor Nagy