ChartSeriesCollection Class
Represents collection of a ChartSeries.
Inheritance Hierarchy
SystemObject
  Aspose.Words.Drawing.ChartsChartSeriesCollection

Namespace: Aspose.Words.Drawing.Charts
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.12
Syntax
public class ChartSeriesCollection : IEnumerable<ChartSeries>, 
	IEnumerable

The ChartSeriesCollection type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleCount
Returns the number of ChartSeries in this collection.
Public propertyCode exampleItem
Returns a ChartSeries at the specified index.
Methods
  NameDescription
Public methodCode exampleAdd(String, DateTime, Double)
Adds new ChartSeries to this collection. Use this method to add series to any type of Area, Radar and Stock charts.
Public methodCode exampleAdd(String, Double, Double)
Adds new ChartSeries to this collection. Use this method to add series to any type of Scatter charts.
Public methodCode exampleAdd(String, String, Double)
Adds new ChartSeries to this collection. Use this method to add series to any type of Bar, Column, Line and Surface charts.
Public methodCode exampleAdd(String, Double, Double, Double)
Adds new ChartSeries to this collection. Use this method to add series to any type of Bubble charts.
Public methodCode exampleClear
Removes all ChartSeries from this collection.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodCode exampleGetEnumerator
Returns an enumerator object.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodCode exampleRemoveAt
Removes a ChartSeries at the specified index.
Public methodToString (Inherited from Object.)
Examples
Shows how to work with a chart's data collection.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Use a document builder to insert a bar chart
Shape chartShape = builder.InsertChart(ChartType.Column, 400, 300);
Chart chart = chartShape.Chart;

// All charts come with demo data
// This column chart currently has 3 series with 4 categories, which means 4 clusters, 3 columns in each
ChartSeriesCollection chartData = chart.Series;
Assert.AreEqual(3, chartData.Count);

// Iterate through the series with an enumerator and print their names
using (IEnumerator<ChartSeries> enumerator = chart.Series.GetEnumerator())
{
    // And use it to go over all the data labels in one series and change their separator
    while (enumerator.MoveNext())
    {
        Console.WriteLine(enumerator.Current.Name);
    }
}

// We can add new data by adding a new series to the collection, with categories and data
// We will match the existing category/series names in the demo data and add a 4th column to each column cluster
string[] categories = { "Category 1", "Category 2", "Category 3", "Category 4" };
chart.Series.Add("Series 4", categories, new[] { 4.4, 7.0, 3.5, 2.1 });

Assert.AreEqual(4, chartData.Count);
Assert.AreEqual("Series 4", chartData[3].Name);

// We can remove series by index
chartData.RemoveAt(2);

Assert.AreEqual(3, chartData.Count);
Assert.AreEqual("Series 4", chartData[2].Name);

// We can also remove out all the series
// This leaves us with an empty graph and is a convenient way of wiping out demo data
chartData.Clear();

Assert.AreEqual(0, chartData.Count);
See Also