Previous topicNext topic
Help > 开发指南 > 窗体开发 > 控件参考 > 控件参考 > 图表 > SmFlexChart > 属性 >
线条标记

线条标记LineMarker

折线标记是图表图上的水平线或垂直线,并绑定到轴上的某个值。它们附有标签以显示确切的数据值,通常用于显示趋势或在图表上标记重要值或阈值。在图表上绘制大量数据点的情况下,或者当用户希望在图表上显示具有多个序列的精确数据值的标签时,也可以使用折线标记。例如,折线标记在绘制全年每日股票价格波动的图表中非常有用。


FlexChart 通过 C1 的 LineMarker 类提供折线标记。Win.Chart.Interaction 命名空间。可以设置此类的 Lines 属性,以指定是要显示水平、垂直、两者还是无(默认)的线条标记。此属性接受来自 LineMarkerLines 枚举的值。LineMarker 类还提供了用于自定义行标记标签内容的 Content 属性和用于根据数据值设置标签位置的对齐属性。

在 FlexChart 中,默认情况下,线标记会随着指针一起移动,便于最终用户了解指针位置处的确切数据值。但是,可以通过将“Interaction(交互)”属性设置为“None”或“Drag”来更改此行为。值 None 表示线条标记保持静态,并且不允许最终用户与线条标记交互,而值 Drag 允许最终用户将线条标记拖动到绘图区上的所需位置。在后面的情况下,可以通过设置 DragContent 属性来指定是否允许拖动内容。同样,属性定义在拖动垂直线和水平线时是否相互链接。此外,FlexChart 还允许您在使用“VerticalPosition(垂直位置)”和“HorizontalPosition(水平位置)”属性首次加载图表时指定折线标记的默认位置。这些属性接受介于 0 到 1 之间的双精度类型值。

Vb.Net
 
Dim lineMarker As New C1.Win.Chart.Interaction.LineMarker(flexChart1)

'Set whether to show horizontal, vertical Or both line markers
lineMarker.Lines = C1.Win.Chart.Interaction.LineMarkerLines.Both

'Set the default position of the marker on load
lineMarker.VerticalPosition = 0.2
lineMarker.HorizontalPosition = 0.3

'Set where to show line marker content relative to the cross-section (horizontal, vertical line markers)
lineMarker.Alignment = C1.Win.Chart.Interaction.LineMarkerAlignment.Right

'Let the user move the line marker by dragging
lineMarker.Interaction = C1.Win.Chart.Interaction.LineMarkerInteraction.Drag

'Update the line marker when user drags the content
lineMarker.DragContent = True

'Set whether the two marker lines are linked when dragged
lineMarker.DragLines = True

'Set custom content for line marker
lineMarker.Content = "Total revenue generated ${Revenue} by the sales of {Orders} units"

C#
 
C1.Win.Chart.Interaction.LineMarker lineMarker = new C1.Win.Chart.Interaction.LineMarker(flexChart1);

//Set whether to show horizontal, vertical or both line markers
lineMarker.Lines = C1.Win.Chart.Interaction.LineMarkerLines.Both;

//Set the default position of the marker on load
lineMarker.VerticalPosition = 0.2;
lineMarker.HorizontalPosition = 0.3;

//Set where to show line marker content relative to the cross-section (horizontal, vertical line markers)
lineMarker.Alignment = C1.Win.Chart.Interaction.LineMarkerAlignment.Right;

//Let the user move the line marker by dragging
lineMarker.Interaction = C1.Win.Chart.Interaction.LineMarkerInteraction.Drag;

//Update the line marker when user drags the content
lineMarker.DragContent = true;

//Set whether the two marker lines are linked when dragged
lineMarker.DragLines = true;

//Set custom content for line marker
lineMarker.Content = "Total revenue generated ${Revenue} by the sales of {Orders} units";