ChartDataPoint Class
Allows to specify formatting of a single data point on the chart.
Inheritance Hierarchy
SystemObject
  Aspose.Words.Drawing.ChartsChartDataPoint

Namespace: Aspose.Words.Drawing.Charts
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.12
Syntax
public class ChartDataPoint : IChartDataPoint

The ChartDataPoint type exposes the following members.

Properties
  NameDescription
Public propertyBubble3D
Public propertyExplosion
Public propertyCode exampleIndex
Index of the data point this object applies formatting to.
Public propertyInvertIfNegative
Public propertyMarker
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Remarks
On a series, the ChartDataPoint object is a member of the ChartDataPointCollection. The ChartDataPointCollection contains a ChartDataPoint object for each point.
Examples
Shows how to customize chart data points.
[Test]
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())
        {
            Assert.False(enumerator.Current.InvertIfNegative);
        }
    }

    // If the chart looks too busy, we can remove data points one by one
    chart.Series[1].DataPoints.RemoveAt(2);

    // We can also clear an entire data point collection for one whole series
    chart.Series[2].DataPoints.Clear();

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

/// <summary>
/// Applies a number of data points to a series
/// </summary>
private 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