search/mag_sel search/close
Aspose::Words::Drawing::Charts::ChartSeriesCollection Class Reference

Represents collection of a ChartSeries.

Examples

Shows how to add and remove series data in a chart.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a column chart that will contain three series of demo data by default.
SharedPtr<Shape> chartShape = builder->InsertChart(ChartType::Column, 400, 300);
SharedPtr<Chart> chart = chartShape->get_Chart();
// Each series has four decimal values: one for each of the four categories.
// Four clusters of three columns will represent this data.
SharedPtr<ChartSeriesCollection> chartData = chart->get_Series();
ASSERT_EQ(3, chartData->get_Count());
// Print the name of every series in the chart.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ChartSeries>>> enumerator = chart->get_Series()->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << enumerator->get_Current()->get_Name() << std::endl;
}
}
// These are the names of the categories in the chart.
ArrayPtr<String> categories = MakeArray<String>({u"Category 1", u"Category 2", u"Category 3", u"Category 4"});
// We can add a series with new values for existing categories.
// This chart will now contain four clusters of four columns.
chart->get_Series()->Add(u"Series 4", categories, MakeArray<double>({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->LINQ_Any([](SharedPtr<ChartSeries> s) { return s->get_Name() == u"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();

#include <Aspose.Words.Cpp/Drawing/Charts/ChartSeriesCollection.h>

+ Inheritance diagram for Aspose::Words::Drawing::Charts::ChartSeriesCollection:

Public Member Functions

SharedPtr< ChartSeriesAdd (String seriesName, ArrayPtr< double > xValues, ArrayPtr< double > yValues)
 Adds new ChartSeries to this collection. Use this method to add series to any type of Scatter charts. More...
 
SharedPtr< ChartSeriesAdd (String seriesName, ArrayPtr< double > xValues, ArrayPtr< double > yValues, ArrayPtr< double > bubbleSizes)
 Adds new ChartSeries to this collection. Use this method to add series to any type of Bubble charts. More...
 
SharedPtr< ChartSeriesAdd (String seriesName, ArrayPtr< DateTime > dates, ArrayPtr< double > values)
 Adds new ChartSeries to this collection. Use this method to add series to any type of Area, Radar and Stock charts. More...
 
SharedPtr< ChartSeriesAdd (String seriesName, ArrayPtr< String > categories, ArrayPtr< double > values)
 Adds new ChartSeries to this collection. Use this method to add series to any type of Bar, Column, Line and Surface charts. More...
 
void Clear ()
 Removes all ChartSeries from this collection. More...
 
int32_t get_Count ()
 Returns the number of ChartSeries in this collection. More...
 
SharedPtr< IEnumerator< SharedPtr< ChartSeries > > > GetEnumerator () override
 Returns an enumerator object. More...
 
virtual const TypeInfoGetType () const override
 
SharedPtr< ChartSeriesidx_get (int32_t index)
 Returns a ChartSeries at the specified index. More...
 
virtual bool Is (const TypeInfo &target) const override
 
void RemoveAt (int32_t index)
 Removes a ChartSeries at the specified index. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Function Documentation

◆ Add() [1/4]

System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeries> Aspose::Words::Drawing::Charts::ChartSeriesCollection::Add ( System::String  seriesName,
System::ArrayPtr< double >  xValues,
System::ArrayPtr< double >  yValues 
)

Adds new ChartSeries to this collection. Use this method to add series to any type of Scatter charts.

Returns
Recently added ChartSeries object.
Examples

Shows how to create an appropriate type of chart series for a graph type.

void ChartSeriesCollection_()
{
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// There are several ways of populating a chart's series collection.
// Different series schemas are intended for different chart types.
// 1 - Column chart with columns grouped and banded along the X-axis by category:
SharedPtr<Chart> chart = AppendChart(builder, ChartType::Column, 500, 300);
ArrayPtr<String> categories = MakeArray<String>({u"Category 1", u"Category 2", u"Category 3"});
// Insert two series of decimal values containing a value for each respective category.
// This column chart will have three groups, each with two columns.
chart->get_Series()->Add(u"Series 1", categories, MakeArray<double>({76.6, 82.1, 91.6}));
chart->get_Series()->Add(u"Series 2", categories, MakeArray<double>({64.2, 79.5, 94.0}));
// Categories are distributed along the X-axis, and values are distributed along the Y-axis.
ASSERT_EQ(ChartAxisType::Category, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 2 - Area chart with dates distributed along the X-axis:
chart = AppendChart(builder, ChartType::Area, 500, 300);
ArrayPtr<System::DateTime> dates =
MakeArray<System::DateTime>({System::DateTime(2014, 3, 31), System::DateTime(2017, 1, 23), System::DateTime(2017, 6, 18),
System::DateTime(2019, 11, 22), System::DateTime(2020, 9, 7)});
// Insert a series with a decimal value for each respective date.
// The dates will be distributed along a linear X-axis,
// and the values added to this series will create data points.
chart->get_Series()->Add(u"Series 1", dates, MakeArray<double>({15.8, 21.5, 22.9, 28.7, 33.1}));
ASSERT_EQ(ChartAxisType::Category, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 3 - 2D scatter plot:
chart = AppendChart(builder, ChartType::Scatter, 500, 300);
// Each series will need two decimal arrays of equal length.
// The first array contains X-values, and the second contains corresponding Y-values
// of data points on the chart's graph.
chart->get_Series()->Add(u"Series 1", MakeArray<double>({3.1, 3.5, 6.3, 4.1, 2.2, 8.3, 1.2, 3.6}),
MakeArray<double>({3.1, 6.3, 4.6, 0.9, 8.5, 4.2, 2.3, 9.9}));
chart->get_Series()->Add(u"Series 2", MakeArray<double>({2.6, 7.3, 4.5, 6.6, 2.1, 9.3, 0.7, 3.3}),
MakeArray<double>({7.1, 6.6, 3.5, 7.8, 7.7, 9.5, 1.3, 4.6}));
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 4 - Bubble chart:
chart = AppendChart(builder, ChartType::Bubble, 500, 300);
// Each series will need three decimal arrays of equal length.
// The first array contains X-values, the second contains corresponding Y-values,
// and the third contains diameters for each of the graph's data points.
chart->get_Series()->Add(u"Series 1", MakeArray<double>({1.1, 5.0, 9.8}), MakeArray<double>({1.2, 4.9, 9.9}), MakeArray<double>({2.0, 4.0, 8.0}));
doc->Save(ArtifactsDir + u"Charts.ChartSeriesCollection.docx");
}
static SharedPtr<Chart> AppendChart(SharedPtr<DocumentBuilder> builder, ChartType chartType, double width, double height)
{
SharedPtr<Shape> chartShape = builder->InsertChart(chartType, width, height);
SharedPtr<Chart> chart = chartShape->get_Chart();
chart->get_Series()->Clear();
return chart;
}

◆ Add() [2/4]

System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeries> Aspose::Words::Drawing::Charts::ChartSeriesCollection::Add ( System::String  seriesName,
System::ArrayPtr< double >  xValues,
System::ArrayPtr< double >  yValues,
System::ArrayPtr< double >  bubbleSizes 
)

Adds new ChartSeries to this collection. Use this method to add series to any type of Bubble charts.

Returns
Recently added ChartSeries object.
Examples

Shows how to create an appropriate type of chart series for a graph type.

void ChartSeriesCollection_()
{
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// There are several ways of populating a chart's series collection.
// Different series schemas are intended for different chart types.
// 1 - Column chart with columns grouped and banded along the X-axis by category:
SharedPtr<Chart> chart = AppendChart(builder, ChartType::Column, 500, 300);
ArrayPtr<String> categories = MakeArray<String>({u"Category 1", u"Category 2", u"Category 3"});
// Insert two series of decimal values containing a value for each respective category.
// This column chart will have three groups, each with two columns.
chart->get_Series()->Add(u"Series 1", categories, MakeArray<double>({76.6, 82.1, 91.6}));
chart->get_Series()->Add(u"Series 2", categories, MakeArray<double>({64.2, 79.5, 94.0}));
// Categories are distributed along the X-axis, and values are distributed along the Y-axis.
ASSERT_EQ(ChartAxisType::Category, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 2 - Area chart with dates distributed along the X-axis:
chart = AppendChart(builder, ChartType::Area, 500, 300);
ArrayPtr<System::DateTime> dates =
MakeArray<System::DateTime>({System::DateTime(2014, 3, 31), System::DateTime(2017, 1, 23), System::DateTime(2017, 6, 18),
System::DateTime(2019, 11, 22), System::DateTime(2020, 9, 7)});
// Insert a series with a decimal value for each respective date.
// The dates will be distributed along a linear X-axis,
// and the values added to this series will create data points.
chart->get_Series()->Add(u"Series 1", dates, MakeArray<double>({15.8, 21.5, 22.9, 28.7, 33.1}));
ASSERT_EQ(ChartAxisType::Category, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 3 - 2D scatter plot:
chart = AppendChart(builder, ChartType::Scatter, 500, 300);
// Each series will need two decimal arrays of equal length.
// The first array contains X-values, and the second contains corresponding Y-values
// of data points on the chart's graph.
chart->get_Series()->Add(u"Series 1", MakeArray<double>({3.1, 3.5, 6.3, 4.1, 2.2, 8.3, 1.2, 3.6}),
MakeArray<double>({3.1, 6.3, 4.6, 0.9, 8.5, 4.2, 2.3, 9.9}));
chart->get_Series()->Add(u"Series 2", MakeArray<double>({2.6, 7.3, 4.5, 6.6, 2.1, 9.3, 0.7, 3.3}),
MakeArray<double>({7.1, 6.6, 3.5, 7.8, 7.7, 9.5, 1.3, 4.6}));
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 4 - Bubble chart:
chart = AppendChart(builder, ChartType::Bubble, 500, 300);
// Each series will need three decimal arrays of equal length.
// The first array contains X-values, the second contains corresponding Y-values,
// and the third contains diameters for each of the graph's data points.
chart->get_Series()->Add(u"Series 1", MakeArray<double>({1.1, 5.0, 9.8}), MakeArray<double>({1.2, 4.9, 9.9}), MakeArray<double>({2.0, 4.0, 8.0}));
doc->Save(ArtifactsDir + u"Charts.ChartSeriesCollection.docx");
}
static SharedPtr<Chart> AppendChart(SharedPtr<DocumentBuilder> builder, ChartType chartType, double width, double height)
{
SharedPtr<Shape> chartShape = builder->InsertChart(chartType, width, height);
SharedPtr<Chart> chart = chartShape->get_Chart();
chart->get_Series()->Clear();
return chart;
}

◆ Add() [3/4]

System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeries> Aspose::Words::Drawing::Charts::ChartSeriesCollection::Add ( System::String  seriesName,
System::ArrayPtr< System::DateTime dates,
System::ArrayPtr< double >  values 
)

Adds new ChartSeries to this collection. Use this method to add series to any type of Area, Radar and Stock charts.

Examples

Shows how to create an appropriate type of chart series for a graph type.

void ChartSeriesCollection_()
{
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// There are several ways of populating a chart's series collection.
// Different series schemas are intended for different chart types.
// 1 - Column chart with columns grouped and banded along the X-axis by category:
SharedPtr<Chart> chart = AppendChart(builder, ChartType::Column, 500, 300);
ArrayPtr<String> categories = MakeArray<String>({u"Category 1", u"Category 2", u"Category 3"});
// Insert two series of decimal values containing a value for each respective category.
// This column chart will have three groups, each with two columns.
chart->get_Series()->Add(u"Series 1", categories, MakeArray<double>({76.6, 82.1, 91.6}));
chart->get_Series()->Add(u"Series 2", categories, MakeArray<double>({64.2, 79.5, 94.0}));
// Categories are distributed along the X-axis, and values are distributed along the Y-axis.
ASSERT_EQ(ChartAxisType::Category, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 2 - Area chart with dates distributed along the X-axis:
chart = AppendChart(builder, ChartType::Area, 500, 300);
ArrayPtr<System::DateTime> dates =
MakeArray<System::DateTime>({System::DateTime(2014, 3, 31), System::DateTime(2017, 1, 23), System::DateTime(2017, 6, 18),
System::DateTime(2019, 11, 22), System::DateTime(2020, 9, 7)});
// Insert a series with a decimal value for each respective date.
// The dates will be distributed along a linear X-axis,
// and the values added to this series will create data points.
chart->get_Series()->Add(u"Series 1", dates, MakeArray<double>({15.8, 21.5, 22.9, 28.7, 33.1}));
ASSERT_EQ(ChartAxisType::Category, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 3 - 2D scatter plot:
chart = AppendChart(builder, ChartType::Scatter, 500, 300);
// Each series will need two decimal arrays of equal length.
// The first array contains X-values, and the second contains corresponding Y-values
// of data points on the chart's graph.
chart->get_Series()->Add(u"Series 1", MakeArray<double>({3.1, 3.5, 6.3, 4.1, 2.2, 8.3, 1.2, 3.6}),
MakeArray<double>({3.1, 6.3, 4.6, 0.9, 8.5, 4.2, 2.3, 9.9}));
chart->get_Series()->Add(u"Series 2", MakeArray<double>({2.6, 7.3, 4.5, 6.6, 2.1, 9.3, 0.7, 3.3}),
MakeArray<double>({7.1, 6.6, 3.5, 7.8, 7.7, 9.5, 1.3, 4.6}));
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 4 - Bubble chart:
chart = AppendChart(builder, ChartType::Bubble, 500, 300);
// Each series will need three decimal arrays of equal length.
// The first array contains X-values, the second contains corresponding Y-values,
// and the third contains diameters for each of the graph's data points.
chart->get_Series()->Add(u"Series 1", MakeArray<double>({1.1, 5.0, 9.8}), MakeArray<double>({1.2, 4.9, 9.9}), MakeArray<double>({2.0, 4.0, 8.0}));
doc->Save(ArtifactsDir + u"Charts.ChartSeriesCollection.docx");
}
static SharedPtr<Chart> AppendChart(SharedPtr<DocumentBuilder> builder, ChartType chartType, double width, double height)
{
SharedPtr<Shape> chartShape = builder->InsertChart(chartType, width, height);
SharedPtr<Chart> chart = chartShape->get_Chart();
chart->get_Series()->Clear();
return chart;
}

◆ Add() [4/4]

System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeries> Aspose::Words::Drawing::Charts::ChartSeriesCollection::Add ( System::String  seriesName,
System::ArrayPtr< System::String categories,
System::ArrayPtr< double >  values 
)

Adds new ChartSeries to this collection. Use this method to add series to any type of Bar, Column, Line and Surface charts.

Returns
Recently added ChartSeries object.
Examples

Shows how to create an appropriate type of chart series for a graph type.

void ChartSeriesCollection_()
{
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// There are several ways of populating a chart's series collection.
// Different series schemas are intended for different chart types.
// 1 - Column chart with columns grouped and banded along the X-axis by category:
SharedPtr<Chart> chart = AppendChart(builder, ChartType::Column, 500, 300);
ArrayPtr<String> categories = MakeArray<String>({u"Category 1", u"Category 2", u"Category 3"});
// Insert two series of decimal values containing a value for each respective category.
// This column chart will have three groups, each with two columns.
chart->get_Series()->Add(u"Series 1", categories, MakeArray<double>({76.6, 82.1, 91.6}));
chart->get_Series()->Add(u"Series 2", categories, MakeArray<double>({64.2, 79.5, 94.0}));
// Categories are distributed along the X-axis, and values are distributed along the Y-axis.
ASSERT_EQ(ChartAxisType::Category, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 2 - Area chart with dates distributed along the X-axis:
chart = AppendChart(builder, ChartType::Area, 500, 300);
ArrayPtr<System::DateTime> dates =
MakeArray<System::DateTime>({System::DateTime(2014, 3, 31), System::DateTime(2017, 1, 23), System::DateTime(2017, 6, 18),
System::DateTime(2019, 11, 22), System::DateTime(2020, 9, 7)});
// Insert a series with a decimal value for each respective date.
// The dates will be distributed along a linear X-axis,
// and the values added to this series will create data points.
chart->get_Series()->Add(u"Series 1", dates, MakeArray<double>({15.8, 21.5, 22.9, 28.7, 33.1}));
ASSERT_EQ(ChartAxisType::Category, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 3 - 2D scatter plot:
chart = AppendChart(builder, ChartType::Scatter, 500, 300);
// Each series will need two decimal arrays of equal length.
// The first array contains X-values, and the second contains corresponding Y-values
// of data points on the chart's graph.
chart->get_Series()->Add(u"Series 1", MakeArray<double>({3.1, 3.5, 6.3, 4.1, 2.2, 8.3, 1.2, 3.6}),
MakeArray<double>({3.1, 6.3, 4.6, 0.9, 8.5, 4.2, 2.3, 9.9}));
chart->get_Series()->Add(u"Series 2", MakeArray<double>({2.6, 7.3, 4.5, 6.6, 2.1, 9.3, 0.7, 3.3}),
MakeArray<double>({7.1, 6.6, 3.5, 7.8, 7.7, 9.5, 1.3, 4.6}));
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisX()->get_Type());
ASSERT_EQ(ChartAxisType::Value, chart->get_AxisY()->get_Type());
// 4 - Bubble chart:
chart = AppendChart(builder, ChartType::Bubble, 500, 300);
// Each series will need three decimal arrays of equal length.
// The first array contains X-values, the second contains corresponding Y-values,
// and the third contains diameters for each of the graph's data points.
chart->get_Series()->Add(u"Series 1", MakeArray<double>({1.1, 5.0, 9.8}), MakeArray<double>({1.2, 4.9, 9.9}), MakeArray<double>({2.0, 4.0, 8.0}));
doc->Save(ArtifactsDir + u"Charts.ChartSeriesCollection.docx");
}
static SharedPtr<Chart> AppendChart(SharedPtr<DocumentBuilder> builder, ChartType chartType, double width, double height)
{
SharedPtr<Shape> chartShape = builder->InsertChart(chartType, width, height);
SharedPtr<Chart> chart = chartShape->get_Chart();
chart->get_Series()->Clear();
return chart;
}

◆ Clear()

void Aspose::Words::Drawing::Charts::ChartSeriesCollection::Clear ( )

Removes all ChartSeries from this collection.

Examples

Shows how to add and remove series data in a chart.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a column chart that will contain three series of demo data by default.
SharedPtr<Shape> chartShape = builder->InsertChart(ChartType::Column, 400, 300);
SharedPtr<Chart> chart = chartShape->get_Chart();
// Each series has four decimal values: one for each of the four categories.
// Four clusters of three columns will represent this data.
SharedPtr<ChartSeriesCollection> chartData = chart->get_Series();
ASSERT_EQ(3, chartData->get_Count());
// Print the name of every series in the chart.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ChartSeries>>> enumerator = chart->get_Series()->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << enumerator->get_Current()->get_Name() << std::endl;
}
}
// These are the names of the categories in the chart.
ArrayPtr<String> categories = MakeArray<String>({u"Category 1", u"Category 2", u"Category 3", u"Category 4"});
// We can add a series with new values for existing categories.
// This chart will now contain four clusters of four columns.
chart->get_Series()->Add(u"Series 4", categories, MakeArray<double>({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->LINQ_Any([](SharedPtr<ChartSeries> s) { return s->get_Name() == u"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();

◆ get_Count()

int32_t Aspose::Words::Drawing::Charts::ChartSeriesCollection::get_Count ( )

Returns the number of ChartSeries in this collection.

Examples

Shows how to add and remove series data in a chart.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a column chart that will contain three series of demo data by default.
SharedPtr<Shape> chartShape = builder->InsertChart(ChartType::Column, 400, 300);
SharedPtr<Chart> chart = chartShape->get_Chart();
// Each series has four decimal values: one for each of the four categories.
// Four clusters of three columns will represent this data.
SharedPtr<ChartSeriesCollection> chartData = chart->get_Series();
ASSERT_EQ(3, chartData->get_Count());
// Print the name of every series in the chart.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ChartSeries>>> enumerator = chart->get_Series()->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << enumerator->get_Current()->get_Name() << std::endl;
}
}
// These are the names of the categories in the chart.
ArrayPtr<String> categories = MakeArray<String>({u"Category 1", u"Category 2", u"Category 3", u"Category 4"});
// We can add a series with new values for existing categories.
// This chart will now contain four clusters of four columns.
chart->get_Series()->Add(u"Series 4", categories, MakeArray<double>({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->LINQ_Any([](SharedPtr<ChartSeries> s) { return s->get_Name() == u"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();

◆ GetEnumerator()

System::SharedPtr<System::Collections::Generic::IEnumerator<System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeries> > > Aspose::Words::Drawing::Charts::ChartSeriesCollection::GetEnumerator ( )
override

Returns an enumerator object.

Examples

Shows how to add and remove series data in a chart.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a column chart that will contain three series of demo data by default.
SharedPtr<Shape> chartShape = builder->InsertChart(ChartType::Column, 400, 300);
SharedPtr<Chart> chart = chartShape->get_Chart();
// Each series has four decimal values: one for each of the four categories.
// Four clusters of three columns will represent this data.
SharedPtr<ChartSeriesCollection> chartData = chart->get_Series();
ASSERT_EQ(3, chartData->get_Count());
// Print the name of every series in the chart.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ChartSeries>>> enumerator = chart->get_Series()->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << enumerator->get_Current()->get_Name() << std::endl;
}
}
// These are the names of the categories in the chart.
ArrayPtr<String> categories = MakeArray<String>({u"Category 1", u"Category 2", u"Category 3", u"Category 4"});
// We can add a series with new values for existing categories.
// This chart will now contain four clusters of four columns.
chart->get_Series()->Add(u"Series 4", categories, MakeArray<double>({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->LINQ_Any([](SharedPtr<ChartSeries> s) { return s->get_Name() == u"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();

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Drawing::Charts::ChartSeriesCollection::GetType ( ) const
overridevirtual

Reimplemented from System::Object.

◆ idx_get()

System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeries> Aspose::Words::Drawing::Charts::ChartSeriesCollection::idx_get ( int32_t  index)

Returns a ChartSeries at the specified index.

The index is zero-based.

Negative indexes are allowed and indicate access from the back of the collection. For example -1 means the last item, -2 means the second before last and so on.

If index is greater than or equal to the number of items in the list, this returns a null reference.

If index is negative and its absolute value is greater than the number of items in the list, this returns a null reference.

Parameters
indexAn index into the collection.
Examples

Shows how to add and remove series data in a chart.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a column chart that will contain three series of demo data by default.
SharedPtr<Shape> chartShape = builder->InsertChart(ChartType::Column, 400, 300);
SharedPtr<Chart> chart = chartShape->get_Chart();
// Each series has four decimal values: one for each of the four categories.
// Four clusters of three columns will represent this data.
SharedPtr<ChartSeriesCollection> chartData = chart->get_Series();
ASSERT_EQ(3, chartData->get_Count());
// Print the name of every series in the chart.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ChartSeries>>> enumerator = chart->get_Series()->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << enumerator->get_Current()->get_Name() << std::endl;
}
}
// These are the names of the categories in the chart.
ArrayPtr<String> categories = MakeArray<String>({u"Category 1", u"Category 2", u"Category 3", u"Category 4"});
// We can add a series with new values for existing categories.
// This chart will now contain four clusters of four columns.
chart->get_Series()->Add(u"Series 4", categories, MakeArray<double>({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->LINQ_Any([](SharedPtr<ChartSeries> s) { return s->get_Name() == u"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();

◆ Is()

virtual bool Aspose::Words::Drawing::Charts::ChartSeriesCollection::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from System::Object.

◆ RemoveAt()

void Aspose::Words::Drawing::Charts::ChartSeriesCollection::RemoveAt ( int32_t  index)

Removes a ChartSeries at the specified index.

Parameters
indexThe zero-based index of the ChartSeries to remove.
Examples

Shows how to add and remove series data in a chart.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a column chart that will contain three series of demo data by default.
SharedPtr<Shape> chartShape = builder->InsertChart(ChartType::Column, 400, 300);
SharedPtr<Chart> chart = chartShape->get_Chart();
// Each series has four decimal values: one for each of the four categories.
// Four clusters of three columns will represent this data.
SharedPtr<ChartSeriesCollection> chartData = chart->get_Series();
ASSERT_EQ(3, chartData->get_Count());
// Print the name of every series in the chart.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ChartSeries>>> enumerator = chart->get_Series()->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << enumerator->get_Current()->get_Name() << std::endl;
}
}
// These are the names of the categories in the chart.
ArrayPtr<String> categories = MakeArray<String>({u"Category 1", u"Category 2", u"Category 3", u"Category 4"});
// We can add a series with new values for existing categories.
// This chart will now contain four clusters of four columns.
chart->get_Series()->Add(u"Series 4", categories, MakeArray<double>({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->LINQ_Any([](SharedPtr<ChartSeries> s) { return s->get_Name() == u"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();

◆ Type()

static const System::TypeInfo& Aspose::Words::Drawing::Charts::ChartSeriesCollection::Type ( )
static