WPF NodeXL curvature

Jan 27, 2012 at 10:39 PM
Edited Jan 28, 2012 at 9:09 AM

How can I change the curvature of edges in code? In the NodeXL Excel Template there are three curvature options you can set in the Graph Options dialog. But I can not figure out how to do this using the WPF NodeXL control.

Jan 29, 2012 at 7:11 AM

The curvature is determined by a couple of properties on the EdgeDrawer owned by the GraphDrawer owned by the NodeXLControl.  Do this before drawing the graph:

            EdgeDrawer edgeDrawer = nodeXLControl1.GraphDrawer.EdgeDrawer;
            edgeDrawer.CurveStyle = EdgeCurveStyle.Bezier;
            edgeDrawer.BezierDisplacementFactor = 0.2;

As described in the NodeXLApi.chm help file, the EdgeDrawer.BezierDisplacementFactor property "is the distance of the edge's Bezier control point from the midpoint of a straight line connecting the edge's endpoints, expressed as a multiple of the straight line's length."  Larger values result in greater curvature.  The NodeXL Excel Template uses values between 0.1 (low) and 1.2 (very high).

-- Tony

Jan 29, 2012 at 1:42 PM

Thank you for your response but CurveStyle and BezierDisplacementFactor properties are not mentioned in the API documentation. I have tried both source code versions 54291 and 52263 from the repository but the EdgeDrawer class does not have these properties. What am I missing here?

Jan 29, 2012 at 5:35 PM

The latest source code is available on the Downloads tab at http://nodexl.codeplex.com/releases.

-- Tony

Jan 29, 2012 at 5:58 PM

The latest source code provided the solution I needed.

Jan 29, 2012 at 6:06 PM
Edited Jan 29, 2012 at 7:57 PM

By the way, if you are just using the NodeXLControl and you do not need to customize it, then you don't need the source code at all.  Instead, look for the latest "NodeXL Class Libraries" download on the Downloads tab.  That contains precompiled NodeXL assemblies along with the help file that explains how to use them.

-- Tony