Each element contains a SmartLabel object with properties that affect the label's behavior. To show the element labels the following code can be used. The setting will propagate to all elements within the chart.
Chart.DefaultElement.ShowValue = true;
Chart.DefaultElement.ShowValue = True
Absolute Position [New in v5.0]
SmartLabels have the ability to be positioned anywhere on the chart by specifying a static Point object representing the label's desired location.
myElement.SmartLabel.AbsolutePosition = new Point(50, 210);
myElement.SmartLabel.AbsolutePosition = New Point(50, 210)
Force Label Drawing
Labels that cannot fit on the chart will not be shown by default. To force them to appear, the DynamicDisplay property must be set to false.
Chart.DefaultElement.SmartLabel.DynamicDisplay = false;
Chart.DefaultElement.SmartLabel.DynamicDisplay = False
Prevent Label Overlap
Non-column series type elements have labels which will dynamically move out of each other's way to prevent overlap. When this happens, a line is drawn to indicate which element the label pertains to. This behavior can be turned off and on using the DynamicPosition property. The following code disables this feature:
Chart.DefaultElement.SmartLabel.DynamicPosition = false;
Chart.DefaultElement.SmartLabel.DynamicPosition = False
The line drawn to indicate the element can be modified through the SmartLabel.Line property.
|Line caps can be used to make the indicator lines look like arrow pointers.|
SmartLabel Padding [New in v5.0]
In some cluttered situations where many elements are close together and in turn surrounding labels are close together as well can make the chart more difficult to understand. Using SmartLabel padding will force a gap between the elements and labels, as well as between the labels themselves.
Chart.DefaultElement.SmartLabel.Padding = 5;
Chart.DefaultElement.SmartLabel.Padding = 5
|The dynamic nature of SmartLabels positioning can result in complex label layouts. If the layout of these labels is not aesthetically pleasing or undesired, adjusting the padding value can have drastic results and in many cases favorable results.|
SmartLabel Maximum Distance Threshold [New in v5.0]
With the dynamic nature of data it is possible for the chart not to be able to find any room for a label near an element, in which case, the label can end up far away from the parent element. Using the SmartLabel.MaximumDistance property allows control over how far a label can move away from the source element.
Chart.DefaultElement.SmartLabel.DistanceMaximum = 50;
Chart.DefaultElement.SmartLabel.DistanceMaximum = 50
Element labels also have several other alignment options available provided by the LabelAlignment enumeration.
A label's default alignment is controlled with the SmartLabel.Alignment property.
Chart.DefaultElement.SmartLabel.Alignment = LabelAlignment.Top;
Chart.DefaultElement.SmartLabel.Alignment = LabelAlignment.Top
Since there may not always be enough room to place the label in desired position (Alignment). The chart engine will look at the AlignmentSecondary property which is a collection of LabelAlignment objects and find the next best one that fits. The following code clears the default secondary alignment settings and sets two options labels can use.
When a label doesn't fit into a column horizontally it will try to fit vertically. If the label is too tall to fit, the label font will decrease in size until it fits. For cases where columns have both horizontal and vertical labels, column labels may be difficult to read. If this is the case, all labels can be forced to show vertically by using this code:
Chart.DefaultElement.SmartLabel.ForceVertical = true;
Chart.DefaultElement.SmartLabel.ForceVertical = True
|Note: This feature doesn't affect horizontal charts.|