Aspose::Words::Drawing::Charts::ChartSeriesGroupCollection class

ChartSeriesGroupCollection class

Represents a collection of ChartSeriesGroup objects.

class ChartSeriesGroupCollection : public System::Collections::Generic::IEnumerable<System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeriesGroup>>

Methods

MethodDescription
Add(Aspose::Words::Drawing::Charts::ChartSeriesType)Adds a new series group of the specified series type to this collection.
GetEnumerator() overrideReturns an enumerator object.
RemoveAt(int32_t)Removes a series group at the specified index. All child series will be removed from the chart.
get_Count()Returns the number of series groups in this collection.
idx_get(int32_t)Returns a ChartSeriesGroup at the specified index.

Typedefs

TypedefDescription
const_iteratorConst iterator type.
iteratorIterator type.
iterator_holder_typeA collection type whose iterator types is used as iterator types in the current collection.
virtualized_iteratorVirtualized type.
virtualized_iterator_elementVirtualized element type.

Remarks

To learn more, visit the Working with Charts documentation article.

Examples

Shows how to work with the secondary axis of chart.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertChart(ChartType::Line, static_cast<double>(450), static_cast<double>(250));
System::SharedPtr<Aspose::Words::Drawing::Charts::Chart> chart = shape->get_Chart();
System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeriesCollection> series = chart->get_Series();

// Delete default generated series.
series->Clear();

auto categories = System::MakeArray<System::String>({u"Category 1", u"Category 2", u"Category 3"});
series->Add(u"Series 1 of primary series group", categories, System::MakeArray<double>({2, 3, 4}));
series->Add(u"Series 2 of primary series group", categories, System::MakeArray<double>({5, 2, 3}));

// Create an additional series group, also of the line type.
System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeriesGroup> newSeriesGroup = chart->get_SeriesGroups()->Add(ChartSeriesType::Line);
// Specify the use of secondary axes for the new series group.
newSeriesGroup->set_AxisGroup(AxisGroup::Secondary);
// Hide the secondary X axis.
newSeriesGroup->get_AxisX()->set_Hidden(true);
// Define title of the secondary Y axis.
newSeriesGroup->get_AxisY()->get_Title()->set_Show(true);
newSeriesGroup->get_AxisY()->get_Title()->set_Text(u"Secondary Y axis");

ASSERT_EQ(newSeriesGroup->get_SeriesType(), ChartSeriesType::Line);

// Add a series to the new series group.
System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeries> series3 = newSeriesGroup->get_Series()->Add(u"Series of secondary series group", categories, System::MakeArray<double>({13, 11, 16}));
series3->get_Format()->get_Stroke()->set_Weight(3.5);

doc->Save(get_ArtifactsDir() + u"Charts.SecondaryAxis.docx");

See Also