DiagramLinks-s consist of series of straight or Bezier segments and arrowhead shapes. The link and arrowhead shapes, and also color attributes and text can be customized as detailed below:
Links can be straight or curved and can contain one or more segments. Set DiagramLink.shape to change the shape. It takes as an argument one of the LinkShape enumeration values:
JavaScript Copy Code |
---|
myLink.shape = LinkShape.Cascading; |
The link can be customized further by changing its controlPoints array, whose elements specify the position of the link segments. The number of control points per segment depends on the link's shape: Bezier links have four control points per segment. Each straight segment has two control points. Adjacent segments share a control point.
The following code sets three control points of a polyline link, which results in two segments:
JavaScript Copy Code |
---|
var Point = MindFusion.Drawing.Point; |
Note |
---|
Always call DiagramLink.updateFromPoints() after you change coordinates of individual control points in the array. |
Each link can display arrowhead shapes at its ends. The shape at the start is specified via baseShape property, the shape at the end is specified via headShape. Arrowheads can also be displayed at middles of segments, helping users follow the path of long links. They are defined by the intermediateShape property. Arrowhead values can be set to either a Shape instance or a string that identifies it:
JavaScript Copy Code |
---|
myLink.headShape = "BowArrow"; |
Shape objects designed specifically as arrowheads are exposed as static members of the ArrowHeads class.
Link segments are rendered according to stroke, strokeThickness and strokeDashStyle attributes. The arrowheads at the head and base are filled using headBrush and baseBrush properties:
JavaScript Copy Code |
---|
// paints the link head with red brush |
Set the text property to specify text label of a link, and font to customize its font. Here is an example how to do this:
JavaScript Copy Code |
---|
myLink.text = "myLabel"; var Font = MindFusion.Drawing.Font; // the bool arguments specify whether the font is bold and italic |
The font size is specified in the diagram's current measure unit, which is millimeter by default.
Apart from main text content, the LinkLabel class lets you display additional labels and pin them to link's points or segments. Call the addLabel method to create such supplementary labels, and use LinkLabel (and base ItemLabel) properties and methods to customize their appearance and position.