com.aspose.words
Class ChartDataPointCollection

java.lang.Object
    extended by com.aspose.words.ChartDataPointCollection
All Implemented Interfaces:
java.lang.Iterable

public class ChartDataPointCollection 
extends java.lang.Object

Represents collection of a ChartDataPoint.

Example:

Shows how to customize chart data points.
@Test
public void chartDataPoint() throws Exception {
    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.0, 350.0);
    Chart chart = shape.getChart();

    // Apply diamond-shaped data points to the line of the first series
    for (ChartSeries series : chart.getSeries()) {
        applyDataPoints(series, 4, MarkerSymbol.DIAMOND, 15);
    }

    // We can further decorate a series line by smoothing it
    chart.getSeries().get(0).setSmooth(true);

    // Get the enumerator for the data point collection from one series
    Iterator<ChartDataPoint> enumerator = chart.getSeries().get(0).getDataPoints().iterator();

    // And use it to go over all the data labels in one series and change their separator
    while (enumerator.hasNext()) {
        Assert.assertFalse(enumerator.next().getInvertIfNegative());
    }

    // If the chart looks too busy, we can remove data points one by one
    chart.getSeries().get(1).getDataPoints().removeAt(2);

    // We can also clear an entire data point collection for one whole series
    chart.getSeries().get(2).getDataPoints().clear();

    doc.save(getArtifactsDir() + "Charts.ChartDataPoint.docx");
}

/// <summary>
/// Applies a number of data points to a series
/// </summary>
private void applyDataPoints(ChartSeries series, int dataPointsCount, /*MarkerSymbol*/int markerSymbol, int dataPointSize) {
    for (int i = 0; i < dataPointsCount; i++) {
        ChartDataPoint point = series.getDataPoints().add(i);
        point.getMarker().setSymbol(markerSymbol);
        point.getMarker().setSize(dataPointSize);

        Assert.assertEquals(point.getIndex(), i);
    }
}

Property Getters/Setters Summary
intgetCount()
           Returns the number of ChartDataPoint in this collection.
ChartDataPointget(int index)
           Returns ChartDataPoint for the specified index. If there is no ChartDataPoint for the specified index, returns default series ChartDataPoint.
 
Method Summary
ChartDataPointadd(int index)
           Adds new ChartDataPoint at the specified index.
voidclear()
           Removes all ChartDataPoint from this collection.
java.util.Iterator<ChartDataPoint>iterator()
           Returns an enumerator object.
voidremoveAt(int index)
           Removes a ChartDataPoint at the specified index.
 

Property Getters/Setters Detail

getCount

public int getCount()
Returns the number of ChartDataPoint in this collection.

Example:

Shows how to customize chart data points.
@Test
public void chartDataPoint() throws Exception {
    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.0, 350.0);
    Chart chart = shape.getChart();

    // Apply diamond-shaped data points to the line of the first series
    for (ChartSeries series : chart.getSeries()) {
        applyDataPoints(series, 4, MarkerSymbol.DIAMOND, 15);
    }

    // We can further decorate a series line by smoothing it
    chart.getSeries().get(0).setSmooth(true);

    // Get the enumerator for the data point collection from one series
    Iterator<ChartDataPoint> enumerator = chart.getSeries().get(0).getDataPoints().iterator();

    // And use it to go over all the data labels in one series and change their separator
    while (enumerator.hasNext()) {
        Assert.assertFalse(enumerator.next().getInvertIfNegative());
    }

    // If the chart looks too busy, we can remove data points one by one
    chart.getSeries().get(1).getDataPoints().removeAt(2);

    // We can also clear an entire data point collection for one whole series
    chart.getSeries().get(2).getDataPoints().clear();

    doc.save(getArtifactsDir() + "Charts.ChartDataPoint.docx");
}

/// <summary>
/// Applies a number of data points to a series
/// </summary>
private void applyDataPoints(ChartSeries series, int dataPointsCount, /*MarkerSymbol*/int markerSymbol, int dataPointSize) {
    for (int i = 0; i < dataPointsCount; i++) {
        ChartDataPoint point = series.getDataPoints().add(i);
        point.getMarker().setSymbol(markerSymbol);
        point.getMarker().setSize(dataPointSize);

        Assert.assertEquals(point.getIndex(), i);
    }
}

get

public ChartDataPoint get(int index)
Returns ChartDataPoint for the specified index. If there is no ChartDataPoint for the specified index, returns default series ChartDataPoint.

Example:

Shows how to customize chart data points.
@Test
public void chartDataPoint() throws Exception {
    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.0, 350.0);
    Chart chart = shape.getChart();

    // Apply diamond-shaped data points to the line of the first series
    for (ChartSeries series : chart.getSeries()) {
        applyDataPoints(series, 4, MarkerSymbol.DIAMOND, 15);
    }

    // We can further decorate a series line by smoothing it
    chart.getSeries().get(0).setSmooth(true);

    // Get the enumerator for the data point collection from one series
    Iterator<ChartDataPoint> enumerator = chart.getSeries().get(0).getDataPoints().iterator();

    // And use it to go over all the data labels in one series and change their separator
    while (enumerator.hasNext()) {
        Assert.assertFalse(enumerator.next().getInvertIfNegative());
    }

    // If the chart looks too busy, we can remove data points one by one
    chart.getSeries().get(1).getDataPoints().removeAt(2);

    // We can also clear an entire data point collection for one whole series
    chart.getSeries().get(2).getDataPoints().clear();

    doc.save(getArtifactsDir() + "Charts.ChartDataPoint.docx");
}

/// <summary>
/// Applies a number of data points to a series
/// </summary>
private void applyDataPoints(ChartSeries series, int dataPointsCount, /*MarkerSymbol*/int markerSymbol, int dataPointSize) {
    for (int i = 0; i < dataPointsCount; i++) {
        ChartDataPoint point = series.getDataPoints().add(i);
        point.getMarker().setSymbol(markerSymbol);
        point.getMarker().setSize(dataPointSize);

        Assert.assertEquals(point.getIndex(), i);
    }
}

Method Detail

add

public ChartDataPoint add(int index)
Adds new ChartDataPoint at the specified index.
Parameters:
index - Target data point index.

Example:

Shows how to customize chart data points.
@Test
public void chartDataPoint() throws Exception {
    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.0, 350.0);
    Chart chart = shape.getChart();

    // Apply diamond-shaped data points to the line of the first series
    for (ChartSeries series : chart.getSeries()) {
        applyDataPoints(series, 4, MarkerSymbol.DIAMOND, 15);
    }

    // We can further decorate a series line by smoothing it
    chart.getSeries().get(0).setSmooth(true);

    // Get the enumerator for the data point collection from one series
    Iterator<ChartDataPoint> enumerator = chart.getSeries().get(0).getDataPoints().iterator();

    // And use it to go over all the data labels in one series and change their separator
    while (enumerator.hasNext()) {
        Assert.assertFalse(enumerator.next().getInvertIfNegative());
    }

    // If the chart looks too busy, we can remove data points one by one
    chart.getSeries().get(1).getDataPoints().removeAt(2);

    // We can also clear an entire data point collection for one whole series
    chart.getSeries().get(2).getDataPoints().clear();

    doc.save(getArtifactsDir() + "Charts.ChartDataPoint.docx");
}

/// <summary>
/// Applies a number of data points to a series
/// </summary>
private void applyDataPoints(ChartSeries series, int dataPointsCount, /*MarkerSymbol*/int markerSymbol, int dataPointSize) {
    for (int i = 0; i < dataPointsCount; i++) {
        ChartDataPoint point = series.getDataPoints().add(i);
        point.getMarker().setSymbol(markerSymbol);
        point.getMarker().setSize(dataPointSize);

        Assert.assertEquals(point.getIndex(), i);
    }
}

clear

public void clear()
Removes all ChartDataPoint from this collection.

Example:

Shows how to customize chart data points.
@Test
public void chartDataPoint() throws Exception {
    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.0, 350.0);
    Chart chart = shape.getChart();

    // Apply diamond-shaped data points to the line of the first series
    for (ChartSeries series : chart.getSeries()) {
        applyDataPoints(series, 4, MarkerSymbol.DIAMOND, 15);
    }

    // We can further decorate a series line by smoothing it
    chart.getSeries().get(0).setSmooth(true);

    // Get the enumerator for the data point collection from one series
    Iterator<ChartDataPoint> enumerator = chart.getSeries().get(0).getDataPoints().iterator();

    // And use it to go over all the data labels in one series and change their separator
    while (enumerator.hasNext()) {
        Assert.assertFalse(enumerator.next().getInvertIfNegative());
    }

    // If the chart looks too busy, we can remove data points one by one
    chart.getSeries().get(1).getDataPoints().removeAt(2);

    // We can also clear an entire data point collection for one whole series
    chart.getSeries().get(2).getDataPoints().clear();

    doc.save(getArtifactsDir() + "Charts.ChartDataPoint.docx");
}

/// <summary>
/// Applies a number of data points to a series
/// </summary>
private void applyDataPoints(ChartSeries series, int dataPointsCount, /*MarkerSymbol*/int markerSymbol, int dataPointSize) {
    for (int i = 0; i < dataPointsCount; i++) {
        ChartDataPoint point = series.getDataPoints().add(i);
        point.getMarker().setSymbol(markerSymbol);
        point.getMarker().setSize(dataPointSize);

        Assert.assertEquals(point.getIndex(), i);
    }
}

iterator

public java.util.Iterator<ChartDataPointiterator()
Returns an enumerator object.

Example:

Shows how to customize chart data points.
@Test
public void chartDataPoint() throws Exception {
    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.0, 350.0);
    Chart chart = shape.getChart();

    // Apply diamond-shaped data points to the line of the first series
    for (ChartSeries series : chart.getSeries()) {
        applyDataPoints(series, 4, MarkerSymbol.DIAMOND, 15);
    }

    // We can further decorate a series line by smoothing it
    chart.getSeries().get(0).setSmooth(true);

    // Get the enumerator for the data point collection from one series
    Iterator<ChartDataPoint> enumerator = chart.getSeries().get(0).getDataPoints().iterator();

    // And use it to go over all the data labels in one series and change their separator
    while (enumerator.hasNext()) {
        Assert.assertFalse(enumerator.next().getInvertIfNegative());
    }

    // If the chart looks too busy, we can remove data points one by one
    chart.getSeries().get(1).getDataPoints().removeAt(2);

    // We can also clear an entire data point collection for one whole series
    chart.getSeries().get(2).getDataPoints().clear();

    doc.save(getArtifactsDir() + "Charts.ChartDataPoint.docx");
}

/// <summary>
/// Applies a number of data points to a series
/// </summary>
private void applyDataPoints(ChartSeries series, int dataPointsCount, /*MarkerSymbol*/int markerSymbol, int dataPointSize) {
    for (int i = 0; i < dataPointsCount; i++) {
        ChartDataPoint point = series.getDataPoints().add(i);
        point.getMarker().setSymbol(markerSymbol);
        point.getMarker().setSize(dataPointSize);

        Assert.assertEquals(point.getIndex(), i);
    }
}

removeAt

public void removeAt(int index)
Removes a ChartDataPoint at the specified index.
Parameters:
index - The zero-based index of the bookmark to remove.

Example:

Shows how to customize chart data points.
@Test
public void chartDataPoint() throws Exception {
    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.0, 350.0);
    Chart chart = shape.getChart();

    // Apply diamond-shaped data points to the line of the first series
    for (ChartSeries series : chart.getSeries()) {
        applyDataPoints(series, 4, MarkerSymbol.DIAMOND, 15);
    }

    // We can further decorate a series line by smoothing it
    chart.getSeries().get(0).setSmooth(true);

    // Get the enumerator for the data point collection from one series
    Iterator<ChartDataPoint> enumerator = chart.getSeries().get(0).getDataPoints().iterator();

    // And use it to go over all the data labels in one series and change their separator
    while (enumerator.hasNext()) {
        Assert.assertFalse(enumerator.next().getInvertIfNegative());
    }

    // If the chart looks too busy, we can remove data points one by one
    chart.getSeries().get(1).getDataPoints().removeAt(2);

    // We can also clear an entire data point collection for one whole series
    chart.getSeries().get(2).getDataPoints().clear();

    doc.save(getArtifactsDir() + "Charts.ChartDataPoint.docx");
}

/// <summary>
/// Applies a number of data points to a series
/// </summary>
private void applyDataPoints(ChartSeries series, int dataPointsCount, /*MarkerSymbol*/int markerSymbol, int dataPointSize) {
    for (int i = 0; i < dataPointsCount; i++) {
        ChartDataPoint point = series.getDataPoints().add(i);
        point.getMarker().setSymbol(markerSymbol);
        point.getMarker().setSize(dataPointSize);

        Assert.assertEquals(point.getIndex(), i);
    }
}

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.