In This Topic
Markers are small shapes displayed at data points. Each series derived from NSeries has an associated instance of a NMarkerStyle object controlling the default marker style. It is accessible through the MarkerStyle property of the NSeries class. The NSeries class also provides the MarkerStyles data series, which contains individual marker styles for the data points. Initially the MarkerStyles data series is empty and all markers are displayed with the default style.
Controlling the markers visibility
The visibility of a marker is controlled through the Visible property of the NMarkerStyle object. By default it is set to false. The following code will display the markers of a series:
C# |
Copy Code
|
series.MarkerStyle.Visible = true;
|
Visual Basic |
Copy Code
|
series.MarkerStyle.Visible = True
|
If you want to display a marker only at some specific index (for example 3), you have to use the following code:
C# |
Copy Code
|
NMarkerStyle marker = new NMarkerStyle();
marker.Visible = true;
series.MarkerStyle.Visible = false;
series.MarkerStyles[3] = marker;
|
Visual Basic |
Copy Code
|
Dim marker As NMarkerStyle = New NMarkerStyle
marker.Visible = True
series.MarkerStyle.Visible = False
series.MarkerStyles(3) = marker
|
In the same manner you can use individual NMarkerStyle objects for the data points in order to override the other properties of the default marker style. For example you can display markers with different colors and shapes.
Controlling the markers shape
The shape of the markers is controlled through the PointShape property. It accepts values from the PointShape enumeration. By default the markers are displayed as boxes. The following example will display the markers of a series as cones:
C# |
Copy Code
|
series.MarkerStyle.PointShape = PointShape.Cone;
|
Visual Basic |
Copy Code
|
series.MarkerStyle.PointShape = PointShape.Cone
|
Controlling the markers dimensions
The width and height of the markers is controlled through the Width and Height properties respectively. By default these properties are set to 2.5f Model units. The following example will increase the size of the markers:
C# |
Copy Code
|
series.MarkerStyle.Width = 3;
series.MarkerStyle.Height = 3.5f;
|
Visual Basic |
Copy Code
|
series.MarkerStyle.Width = 3
series.MarkerStyle.Height = 3.5f
|
The depth dimension of the markers is by default automatically calculated. This feature is very useful since you do not have to bother to change the depth of the markers every time the depth of the series is changed. The auto depth can be switched off by setting the AutoDepth property to false:
C# |
Copy Code
|
series.MarkerStyle.AutoDepth = false;
|
Visual Basic |
Copy Code
|
series.MarkerStyle.AutoDepth = False
|
When the depth of the line is not calculated automatically you can set it to a custom value with the help of the Depth property:
C# |
Copy Code
|
series.MarkerStyle.Depth = 4;
|
Visual Basic |
Copy Code
|
series.MarkerStyle.Depth = 4
|
Controlling the markers appearance
The markers fill style is specified by the FillStyle property. You can change the appearance of the marker borders trough the BorderStyle property.
The following code will display the markers in red color with blue border:
C# |
Copy Code
|
series.MarkerStyle.FillStyle = new NColorFillStyle(Color.Red);
series.MarkerStyle.FillStyle = new NStrokeStyle(Color.Blue);
|
Visual Basic |
Copy Code
|
series.MarkerStyle.FillStyle = New NColorFillStyle(Color.Red)
series.MarkerStyle.BorderStyle = New NStrokeStyle(Color.Blue)
|
The vertical position of a marker towards the data point bounds can be set through the VertAlign property. It accepts values from the VertAlign enumeration: Top, Center and Bottom. Please note that the "top" of a data point is not always the upper part and "bottom" is not always the lower part of a data point. For data points that have orientation (for example floating bars) the terms "top" and "bottom" depend on the data point orientation.
Related Examples
Windows forms: Series Attributes\Markers
See Also