ChartYValueCollection
Contents
[
Hide
]ChartYValueCollection class
Represents a collection of Y values for a chart series.
public class ChartYValueCollection : IEnumerable<ChartYValue>
Properties
Name | Description |
---|---|
Count { get; } | Gets the number of items in this collection. |
FormatCode { get; set; } | Gets or sets the format code applied to the Y values. |
Item { get; set; } | Gets or sets the Y value at the specified index. |
Methods
Name | Description |
---|---|
GetEnumerator() | Returns an enumerator object. |
Remarks
All items of the collection other than null must have the same ValueType
.
The collection allows only changing Y 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.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder();
Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
Chart chart = shape.Chart;
ChartSeries series = chart.Series[0];
double minValue = double.MaxValue;
int minValueIndex = 0;
double maxValue = double.MinValue;
int maxValueIndex = 0;
for (int i = 0; i < series.YValues.Count; i++)
{
// Clear individual format of all data points.
// Data points and data values are one-to-one in column charts.
series.DataPoints[i].ClearFormat();
// Get Y value.
double yValue = series.YValues[i].DoubleValue;
if (yValue < minValue)
{
minValue = yValue;
minValueIndex = i;
}
if (yValue > maxValue)
{
maxValue = yValue;
maxValueIndex = i;
}
}
// Change colors of the max and min values.
series.DataPoints[minValueIndex].Format.Fill.ForeColor = Color.Red;
series.DataPoints[maxValueIndex].Format.Fill.ForeColor = Color.Green;
doc.Save(ArtifactsDir + "Charts.GetChartSeriesData.docx");
See Also
- method Add
- method Add
- method Add
- method Insert
- method Insert
- method Insert
- method Remove
- class ChartYValue
- namespace Aspose.Words.Drawing.Charts
- assembly Aspose.Words