ChartSeriesCollection Class

Represents collection of a ChartSeries.

ExpandedInheritance Hierarchy

SystemObject
  Aspose.Words.Drawing.ChartsChartSeriesCollection

Namespace:  Aspose.Words.Drawing.Charts
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 21.11.0

ExpandedSyntax

public class ChartSeriesCollection : IEnumerable<ChartSeries>, 
	IEnumerable

The ChartSeriesCollection type exposes the following members.

ExpandedProperties

  NameDescription
Public propertyCode exampleCount
Returns the number of ChartSeries in this collection.
Public propertyCode exampleItem
Returns a ChartSeries at the specified index.

ExpandedMethods

  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
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode exampleGetEnumerator
Returns an enumerator object.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodCode exampleRemoveAt
Removes a ChartSeries at the specified index.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

ExpandedExamples

Shows how to add and remove series data in a chart.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a column chart that will contain three series of demo data by default.
Shape chartShape = builder.InsertChart(ChartType.Column, 400, 300);
Chart chart = chartShape.Chart;

// Each series has four decimal values: one for each of the four categories.
// Four clusters of three columns will represent this data.
ChartSeriesCollection chartData = chart.Series;

Assert.AreEqual(3, chartData.Count);

// Print the name of every series in the chart.
using (IEnumerator<ChartSeries> enumerator = chart.Series.GetEnumerator())
{
    while (enumerator.MoveNext())
    {
        Console.WriteLine(enumerator.Current.Name);
    }
}

// These are the names of the categories in the chart.
string[] categories = { "Category 1", "Category 2", "Category 3", "Category 4" };

// We can add a series with new values for existing categories.
// This chart will now contain four clusters of four columns.
chart.Series.Add("Series 4", categories, new[] { 4.4, 7.0, 3.5, 2.1 });

// A chart series can also be removed by index, like this.
// This will remove one of the three demo series that came with the chart.
chartData.RemoveAt(2);

Assert.False(chartData.Any(s => s.Name == "Series 3"));

// We can also clear all the chart's data at once with this method.
// When creating a new chart, this is the way to wipe all the demo data
// before we can begin working on a blank chart.
chartData.Clear();

ExpandedSee Also