SmartLabelStyle 类

定义

提供用于执行基于规则的数据点标签智能定位的方法和属性,以解决数据点标签重叠的问题。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
type SmartLabelStyle = class
Public Class SmartLabelStyle
继承
SmartLabelStyle
派生
属性

示例

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;  
}  

注解

启用智能标签后, 图表将根据一组用户定义的规则重新定位重叠的数据点标签。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. CalloutStyleCalloutLineAnchorCapStyle属性控制出现在标注线条末尾的 embellishments (如箭头)。The CalloutStyle and CalloutLineAnchorCapStyle properties control the embellishments, such as arrowheads, that appear at the end of the callout line.

属性可以设置为任何Color对象。 CalloutLineColorThe CalloutLineColor property can be set to any Color object. 如果设置标注线条的颜色, 还会自动设置的CalloutLineAnchorCapStyle颜色和定义CalloutStyle的 embellishment。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.

CalloutLineWidth属性控制标注线条的像素宽度。The CalloutLineWidth property controls the pixel width of the callout line. 使用此属性还将缩放CalloutLineAnchorCapStyle CalloutStyle和的 embellishments。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. MaxMovingDistance定义一个值, 该值指定在重叠时允许数据点标签移动的数据点的最大距离 (以像素为单位)。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. MinMovingDistance属性定义一个值, 该值指定数据点标签在重叠时将移动的数据点的最小距离 (以像素为单位)。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.

IsOverlappedHidden属性指示在无法解决重叠问题时标签是否处于隐藏状态。The IsOverlappedHidden property indicates whether the labels are hidden when overlapping issues cannot be resolved. true MinMovingDistance MaxMovingDistance如果属性为, 且不能在所允许MovingDirection的方向中绘制数据点, 则不会绘制数据点标签。 IsOverlappedHiddenIf 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.

MovingDirection属性定义可在其中移动数据点标签的方向。The MovingDirection property defines the direction(s) in which the data point label can be moved. 此属性接受一个LabelAlignmentStyles值或多个LabelAlignmentStyles值的按位或。This property accepts one LabelAlignmentStyles value or a bitwise-OR of multiple LabelAlignmentStyles values. 默认值为所有LabelAlignmentStyles值的按位 "或", 以允许在除数据点中心以外的所有可能方向上重新定位。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.

构造函数

SmartLabelStyle()

初始化 SmartLabelStyle 类的新实例。Initializes a new instance of the SmartLabelStyle class.

属性

AllowOutsidePlotArea

获取或设置一个用于指定是否可以在绘图区之外绘制 SmartLabelStyle 对象的标志。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

获取或设置重新定位的 SmartLabelStyle 对象的标注样式。Gets or sets the callout style of the repositioned SmartLabelStyle object.

Enabled

获取或设置指示 SmartLabelStyle 算法是否启用的标志。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

获取或设置重叠的 SmartLabelStyle 对象可从标记移开的最大距离(以像素为单位)。Gets or sets the maximum distance, in pixels, that the overlapped SmartLabelStyle object can be moved from the marker.

MinMovingDistance

获取或设置重叠的 SmartLabelStyle 对象可从标记移开的最小距离(以像素为单位)。Gets or sets the minimum distance, in pixels, that the overlapped SmartLabelStyle object can be moved from the marker.

MovingDirection

获取或设置重叠的 SmartLabelStyle 对象可移动的方向。Gets or sets the direction(s) in which the overlapped SmartLabelStyle object is allowed to be moved.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于