To represent a single chart, data points must be combined into a series. The Series class is responsible for managing data points as a single chart.
Creating a Series
The Series class provides only default constructor without parameters. Use it for creating an instance of Series.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=1
Adding Data Points
Series provides the DataPoints property that returns a DataPoints collection. This collection supports properties and methods peculiar to standard .NET collections. It allows adding the DataPoint objects explicitly or implicitly using their coordinates.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=4
Loading Data Points from a Data Source
Alternatively, you can load data points into the series from a data source which implements the IEnumerable interface. The data source might be an array, collection, OleDbDataReader , SqlDataReader , DataRowCollection , DataView . To perform this, use either DataPoints.DataBindXY (to bind both the X and Y values) or DataBindY (to only bind the Y values).
Getting the Default Data Point
You can obtain the default data point that serves as a template for new data points via the DefaultDataPoint property.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=21
Specifying a Type of the Chart
You can specify a type of the chart diagram by setting the ChartType property. This property allows getting or setting a ChartType enumeration value.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=1
Assigning to a Chart Area
Each data series belongs to a particular chart area. The ChartArea property allows getting or setting the name of the ChartArea that the Series belongs to. You can use it if you don't want the series to belong to the default chart area.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=11
Assigning to Axes
Each series of data points might be plotted along either primary or secondary X and Y axes of the associated ChartArea. This is indicated by the IsPrimaryAxisX and IsPrimaryAxisY properties, respectively.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=82
Setting a Name
You can get or set the name of the Series using its Name property.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=82
Setting Custom Attributes
Each type of chart may support some custom properties, or attributes, which are only applicable to this type. All these attributes are stored in the CustomAttributes object that is returned by the CustomAttributes property. You can use it to additionally set up a chart of the certain type. Please refer to WorkingWithCustomAttributes for more information.
Code Sample
[C#]
// Creating a series
Series series = new Series();
// Adding data points
series.DataPoints.Add(new DataPoint(10, 20));
series.DataPoints.Add(57.8, 4, 225);
// Specifying type of chart
series.ChartType = ChartType.Candlestick;
// Assigning to chart area
series.ChartArea = chart.ChartAreas[4].Name;
// Assigning to secondary axes
series.IsPrimaryAxisX = false;
series.IsPrimaryAxisY = false;
// Setting name
series.Name = "I'm a beautiful data series";
[VB .NET]
' Creating a series
Dim series As Series = New Series()
' Adding data points
series.DataPoints.Add(New DataPoint(10, 20))
series.DataPoints.Add(57.8, 4, 225)
' Specifying type of chart
series.ChartType = ChartType.Candlestick
' Assigning to chart area
series.ChartArea = chart.ChartAreas(4).Name
' Assigning to secondary axes
series.IsPrimaryAxisX = False
series.IsPrimaryAxisY = False
' Setting name
series.Name = "I'm a beautiful data series"
Clarifies working with custom attributes.
10/28/2005 12:18:46 PM - -83.217.194.222