Aspose::Words::Drawing::Charts::ChartXValueCollection class
Contents
[
Hide
]ChartXValueCollection class
Represents a collection of X values for a chart series.
class ChartXValueCollection : public System::Collections::Generic::IEnumerable<System::SharedPtr<Aspose::Words::Drawing::Charts::ChartXValue>>
Methods
Method | Description |
---|---|
get_Count() | Gets the number of items in this collection. |
get_FormatCode() | Gets or sets the format code applied to the X values. |
GetEnumerator() override | Returns an enumerator object. |
GetType() const override | |
idx_get(int32_t) | Gets or sets the X value at the specified index. |
idx_set(int32_t, const System::SharedPtr<Aspose::Words::Drawing::Charts::ChartXValue>&) | Gets or sets the X value at the specified index. |
Is(const System::TypeInfo&) const override | |
set_FormatCode(const System::String&) | Setter for Aspose::Words::Drawing::Charts::ChartXValueCollection::get_FormatCode. |
static Type() |
Remarks
All items of the collection other than null must have the same ValueType.
The collection allows only changing X values. To add or insert new values to a chart series, or remove values, the appropriate methods of the ChartSeries class can be used.
Examples
Shows how to get chart series data.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>();
System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertChart(Aspose::Words::Drawing::Charts::ChartType::Column, 432, 252);
System::SharedPtr<Aspose::Words::Drawing::Charts::Chart> chart = shape->get_Chart();
System::SharedPtr<Aspose::Words::Drawing::Charts::ChartSeries> series = chart->get_Series()->idx_get(0);
double minValue = std::numeric_limits<double>::max();
int32_t minValueIndex = 0;
double maxValue = std::numeric_limits<double>::lowest();
int32_t maxValueIndex = 0;
for (int32_t i = 0; i < series->get_YValues()->get_Count(); i++)
{
// Clear individual format of all data points.
// Data points and data values are one-to-one in column charts.
series->get_DataPoints()->idx_get(i)->ClearFormat();
// Get Y value.
double yValue = series->get_YValues()->idx_get(i)->get_DoubleValue();
if (yValue < minValue)
{
minValue = yValue;
minValueIndex = i;
}
if (yValue > maxValue)
{
maxValue = yValue;
maxValueIndex = i;
}
}
// Change colors of the max and min values.
series->get_DataPoints()->idx_get(minValueIndex)->get_Format()->get_Fill()->set_ForeColor(System::Drawing::Color::get_Red());
series->get_DataPoints()->idx_get(maxValueIndex)->get_Format()->get_Fill()->set_ForeColor(System::Drawing::Color::get_Green());
doc->Save(get_ArtifactsDir() + u"Charts.GetChartSeriesData.docx");
See Also
- Namespace Aspose::Words::Drawing::Charts
- Library Aspose.Words for C++