ChartDataPointCollection Class

Represents collection of a ChartDataPoint.

Inheritance Hierarchy


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


public class ChartDataPointCollection : IEnumerable<ChartDataPoint>, 

The ChartDataPointCollection type exposes the following members.


Public propertyCode exampleCount
Returns the number of ChartDataPoint in this collection.
Public propertyCode exampleItem
Returns ChartDataPoint for the specified index. If there is no ChartDataPoint for the specified index, returns default series ChartDataPoint.


Public methodCode exampleAdd
Adds new ChartDataPoint at the specified index.
Public methodCode exampleClear
Removes all ChartDataPoint from this collection.
Public methodEquals (Inherited from Object.)
Public methodCode exampleGetEnumerator
Returns an enumerator object.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodCode exampleRemoveAt
Removes a ChartDataPoint at the specified index.
Public methodToString (Inherited from Object.)


Shows how to customize chart data points.
public void ChartDataPoint()
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    // Add a line chart, which will have default data that we will use
    Shape shape = builder.InsertChart(ChartType.Line, 500, 350);
    Chart chart = shape.Chart;

    // Apply diamond-shaped data points to the line of the first series
    foreach (ChartSeries series in chart.Series) 
        ApplyDataPoints(series, 4, MarkerSymbol.Diamond, 15);

    // We can further decorate a series line by smoothing it
    chart.Series[0].Smooth = true;

    // Get the enumerator for the data point collection from one series
    using (IEnumerator<ChartDataPoint> enumerator = chart.Series[0].DataPoints.GetEnumerator())
        // And use it to go over all the data labels in one series and change their separator
        while (enumerator.MoveNext())

    // If the chart looks too busy, we can remove data points one by one

    // We can also clear an entire data point collection for one whole series

    doc.Save(ArtifactsDir + "Charts.ChartDataPoint.docx");

/// <summary>
/// Applies a number of data points to a series
/// </summary>
private static void ApplyDataPoints(ChartSeries series, int dataPointsCount, MarkerSymbol markerSymbol, int dataPointSize)
    for (int i = 0; i < dataPointsCount; i++)
        ChartDataPoint point = series.DataPoints.Add(i);
        point.Marker.Symbol = markerSymbol;
        point.Marker.Size = dataPointSize;

        Assert.AreEqual(i, point.Index);

See Also