ComponentOne Chart 8.0 for ActiveX
Programming Markers

 

Programming Markers

For More information, see Adding Markers.

Markers provide a way to identify a particular data element on the screen or a particular value in a plot.

On plots, area graphs and bar charts, two markers are defined: an X-marker and a Y-marker. The X-marker is a line perpendicular to the X-axis, and the Y-marker is a line perpendicular to the Y-axis.

On stacking bar charts, the X-marker is a short line drawn through one of the bar blocks, and the Y-marker is a line perpendicular to the Y-axis.

On pie charts, only the X-marker is defined, and is a line drawn from the center of the pie outward through the center of the selected slice.

In the 2D Chart control, the X- and Y-markers are represented by the Markerscollection, and are named “X” and “Y” respectively. To display a marker, set its IsShowing property:

Chart2D1.ChartArea.Markers("Y").IsShowing = True

Once the marker is displayed, it can be positioned. For example, the following code positions the Y-marker at the point where the mouse is currently located. As the mouse moves, the Y-marker moves with it.

Private Sub Chart2D1_MouseMove(Button As Integer, Shift As Integer, _

x As Single, y As Single)

Dim px As Long

Dim py As Long

Dim vx As Double

Dim vy As Double

px = x / Screen.TwipsPerPixelX   ' Get the current mouse X position

py = y / Screen.TwipsPerPixelY   ' Get the current mouse Y position

' Convert to chart coordinates

Chart2D1.ChartGroups(1).CoordToDataCoord px, py, vx, vy

' Set position of Y-marker

Chart2D1.ChartArea.Markers("Y").Value.y = vy

End Sub

This procedure positions the marker using chart coordinates. You can also position a marker by specifying a dataset and point through which the marker should be drawn. To do this, use the Index property instead of the Value property.


Performance Issues

Markers and Data Styles

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback