All series objects derive from the SeriesBase class, which implements the following basic series functionality:
Visibility Control
When a series is marked as hidden, it is not displayed and does not affect the scale of the axes. Visibility is easily controlled with the Visible property.
Name of the Series
The name of the series can be displayed in the legend associated with the chart. Programmatically, the name of the series can be modified with the help of the Name property.
Margins Control
The series can be instructed to inflate its margins to fit the entire chart in the chart area. This feature is very useful if you intend to display a chart, which is likely to be displayed partially outside of the charting area (bubble chart for example). Programmatically, the user instructs the series to inflate its margins with the help of the InflateMargins property.
Integration of the Series in the Chart Legend
Each series displayed by a particular chart can add some descriptive information about itself in the associated legend. This functionality is exposed by the SeriesLegend object. This object is accessible with the help of the Legend property. See the Series Legend topic for more information.
Scaling of the Series on One or More Standard or Custom X and Y Axes
The user can scale the series on standard and custom X and Y axes. The series is always scaled on the depth axis. The series scaling functionality is exposed to the user through the following methods:
DisplayOnAxis : Controls whether the series is scaled on a particular axis.
IsDisplayedOnAxis : Queries whether the series is scaled on the specified axis.
For example, a bar chart can be scaled on the secondary vertical axis with the following code:
VB.NET | |
---|---|
bar.DisplayOnAxis(StandardAxis.SecondaryY, True) |
C# | |
---|---|
bar.DisplayOnAxis(StandardAxis.SecondaryY, true); |
You can prevent the same bar from scaling on the PrimaryY axis with the following code:
VB.NET | |
---|---|
bar.DisplayOnAxis(StandardAxis.PrimaryY, False) |
C# | |
---|---|
bar.DisplayOnAxis(StandardAxis.PrimaryY, false); |
Ability to Selectively Extract the Data Series Contained by the Series
Most of the general data manipulation routines (Sorting, Importing, etc.) operate on a number of logically connected data series contained in a DataSeriesCollection. The user can easily create a collection of these data series with just one function call. This is achieved with the GetDataSeries virtual method defined in the SeriesBase class. The user can specify which series are included and which series are explicitly excluded. The last argument--ForceAlign--determines whether the data series size must automatically be made equal.
For example, suppose that you want to obtain a data series collection containing the open, high, low, and close data series that a stock chart uses. You can do that in two ways:
1. Explicitly specify which series must be contained in the collection:
VB.NET | |
---|---|
|
C# | |
---|---|
|
2. Include all data series by default, but explicitly exclude all other except the Open, High, Low, and Close data series:
VB.NET | |
---|---|
|
C# | |
---|---|
|
It is important to remember that internally the component checks whether the series, which is present in the DataSeriesCollection object, is aligned when you try to export it to a DataTable. In this case, you can either set ForceAlign to true when you obtain the collection from the series or explicitly align the collection with the help of the Align method.