com.aspose.words

Interface IChartDataPoint

Contains properties of a single data point on the chart.

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
abstract booleangetBubble3D()
abstractvoid
setBubble3D(booleanvalue)
           Specifies whether the bubbles in Bubble chart should have a 3-D effect applied to them.
abstract intgetExplosion()
abstractvoid
setExplosion(intvalue)
           Specifies the amount the data point shall be moved from the center of the pie. Can be negative, negative means that property is not set and no explosion should be applied. Applies only to Pie charts.
abstract booleangetInvertIfNegative()
abstractvoid
setInvertIfNegative(booleanvalue)
           Specifies whether the parent element shall inverts its colors if the value is negative.
abstract ChartMarkergetMarker()
Specifies a data marker. Marker is automatically created when requested.
 

    • Property Getters/Setters Detail

      • getBubble3D/setBubble3D

        public abstract boolean getBubble3D() / public abstract void setBubble3D(boolean value)
        
        Specifies whether the bubbles in Bubble chart should have a 3-D effect applied to them.

        Example:

        Demonstrates bubble chart-exclusive features.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Insert a bubble chart with 3D effects on each bubble
        Shape shape = builder.insertChart(ChartType.BUBBLE_3_D, 500.0, 350.0);
        Chart chart = shape.getChart();
        
        Assert.assertTrue(chart.getSeries().get(0).getBubble3D());
        
        // Apply a data label to each bubble that displays the size of its bubble
        for (int i = 0; i < 3; i++) {
            ChartDataLabel cdl = chart.getSeries().get(0).getDataLabels().add(i);
            cdl.setShowBubbleSize(true);
        }
        
        doc.save(getArtifactsDir() + "Charts.Bubble3D.docx");
      • getExplosion/setExplosion

        public abstract int getExplosion() / public abstract void setExplosion(int value)
        
        Specifies the amount the data point shall be moved from the center of the pie. Can be negative, negative means that property is not set and no explosion should be applied. Applies only to Pie charts.

        Example:

        Shows how to manipulate the position of the portions of a pie chart.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        Shape shape = builder.insertChart(ChartType.PIE, 500.0, 350.0);
        Chart chart = shape.getChart();
        
        // In a pie chart, the portions are the data points, which cannot have markers or sizes applied to them
        // However, we can set this variable to move any individual "slice" away from the center of the chart
        ChartDataPoint cdp = chart.getSeries().get(0).getDataPoints().add(0);
        cdp.setExplosion(10);
        
        cdp = chart.getSeries().get(0).getDataPoints().add(1);
        cdp.setExplosion(40);
        
        doc.save(getArtifactsDir() + "Charts.PieChartExplosion.docx");
      • getInvertIfNegative/setInvertIfNegative

        public abstract boolean getInvertIfNegative() / public abstract void setInvertIfNegative(boolean value)
        
        Specifies whether the parent element shall inverts its colors if the value is negative.

        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);
            }
        }
      • getMarker

        public abstract ChartMarker getMarker()
        
        Specifies a data marker. Marker is automatically created when requested.

        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);
            }
        }