Modifier

Partager via


SmartLabelStyle Class

Definition

Provides methods and properties used to perform intelligent, rule-based data point label positioning to resolve overlapping data point label issues.

public ref class SmartLabelStyle
[System.ComponentModel.TypeConverter(typeof(System.Web.UI.DataVisualization.Charting.NoNameExpandableObjectConverter))]
public class SmartLabelStyle
[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.DataVisualization.Charting.NoNameExpandableObjectConverter))>]
type SmartLabelStyle = class
Public Class SmartLabelStyle
Inheritance
SmartLabelStyle
Derived
Attributes

Examples

Imports System.Web.UI.DataVisualization.Charting  

Private Function SetSmartLabelsOptions()  

   ' Enabling the SmartLabels™ attribute.  
   Chart1.Series("Series1").SmartLabels.Enabled = true  

   ' Set the callout style.  
   Chart1.Series("Series1").SmartLabels.CalloutStyle = LabelCalloutStyle.Underlined  

   ' Set the callout line color.  
   Chart1.Series("Series1").SmartLabels.CalloutLineColor = Color.Goldenrod;  

   ' Set the callout line style.  
   Chart1.Series("Series1").SmartLabels.CalloutLineStyle = ChartDashStyle.Dash  

   ' Set the callout line width.  
   Chart1.Series("Series1").SmartLabels.CalloutLineWidth = 3   

   ' Set the callout line anchor cap.  
   Chart1.Series("Series1").SmartLabels.CalloutLineAnchorCap = LineAnchorCap.Arrow  
End Function  
using System.Web.UI.DataVisualization.Charting  

private void SetSmartLabelsOptions()  
{  
   // Enabling the SmartLabels™ attribute.  
   Chart1.Series["Series1"].SmartLabels.Enabled = true;  

   // Set the callout style.  
   Chart1.Series["Series1"].SmartLabels.CalloutStyle = LabelCalloutStyle.Underlined;  

   // Set the callout line color.  
   Chart1.Series["Series1"].SmartLabels.CalloutLineColor = Color.Goldenrod;  

   // Set the callout line style.  
   Chart1.Series["Series1"].SmartLabels.CalloutLineStyle = ChartDashStyle.Dash;  

   // Set the callout line width.  
   Chart1.Series["Series1"].SmartLabels.CalloutLineWidth = 3;  

   // Set the callout line anchor cap.  
   Chart1.Series["Series1"].SmartLabels.CalloutLineAnchorCap = LineAnchorCap.Arrow;  
}  

Remarks

When smart labels are enabled, the chart repositions overlapping data point labels, based on a set of user-defined rules.

Callout lines will be drawn to link the label with its data point. The visual attributes of the callout line can be controlled. These visual attributes include color, line style, and line width. The CalloutStyle and CalloutLineAnchorCapStyle properties control the embellishments, such as arrowheads, that appear at the end of the callout line.

The CalloutLineColor property can be set to any Color object. If you set the color of the callout line, you will also automatically set the color of the CalloutLineAnchorCapStyle and the embellishment defined by the CalloutStyle.

The CalloutLineWidth property controls the pixel width of the callout line. Use of this property will also scale the embellishments of the CalloutLineAnchorCapStyle and the CalloutStyle.

The movement of smart labels can be controlled through the use of several motion-related properties. These define the rules of movement for the direction, distance and whether the data point label is allowed to leave the plotting area. The default movement rules will normally resolve most issues. The MaxMovingDistance defines a value that specifies the maximum distance in pixels from the data point that data point labels are allowed to be moved in case of overlapping. The MinMovingDistance property defines a value that specifies the minimum distance in pixels from the data point that data point labels will be moved in case of overlapping. When a data point label needs to be repositioned, the label will be moved by at least the number of pixels specified.

The IsOverlappedHidden property indicates whether the labels are hidden when overlapping issues cannot be resolved. If the IsOverlappedHidden property is true, and the data point cannot be drawn within the area specified by MinMovingDistance and MaxMovingDistance in the directions allowed by MovingDirection, the data point label will not be drawn.

The MovingDirection property defines the direction(s) in which the data point label can be moved. This property accepts one LabelAlignmentStyles value or a bitwise-OR of multiple LabelAlignmentStyles values. The default is the bitwise-OR of all LabelAlignmentStyles values, to allow repositioning in all possible directions except to the center of the data point.

Smart labels are not supported for the following chart types:

  • Bar charts: bar and hundred-percent-stacked bar charts.

  • Shape charts: pie, doughnut, polar and radar charts.

  • Range charts: range, range column and range bar charts.

  • Stacked area charts: stacked area and hundred-percent-stacked area charts.

Constructors

SmartLabelStyle()

Initializes a new instance of the SmartLabelStyle class.

Properties

AllowOutsidePlotArea

Gets or sets a flag that specifies whether a SmartLabelStyle object can be drawn outside the plotting area.

CalloutBackColor

Gets or sets the background color of the label callout.

CalloutLineAnchorCapStyle

Gets or sets the anchor cap style of the label callout line.

CalloutLineColor

Gets or sets the color of the label callout line.

CalloutLineDashStyle

Gets or sets the style of the label callout line.

CalloutLineWidth

Gets or sets the width of the label callout line.

CalloutStyle

Gets or sets the callout style of the repositioned SmartLabelStyle object.

Enabled

Gets or sets a flag that indicates whether a SmartLabelStyle algorithm is enabled.

IsMarkerOverlappingAllowed

Gets or sets a flag that specifies whether the point labels are allowed to overlap a point marker.

IsOverlappedHidden

Gets or sets a flag that indicates whether overlapped labels that cannot be repositioned will be hidden.

MaxMovingDistance

Gets or sets the maximum distance, in pixels, that the overlapped SmartLabelStyle object can be moved from the marker.

MinMovingDistance

Gets or sets the minimum distance, in pixels, that the overlapped SmartLabelStyle object can be moved from the marker.

MovingDirection

Gets or sets the direction(s) in which the overlapped SmartLabelStyle object is allowed to be moved.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to