Skip to main content

AreaSeries Class

An area series in a standard chart.

Declaration

public class AreaSeries extends AreaSeriesBase

Remarks

Add an AreaSeries object to the Chart.getSeries() collection to create an area chart. The chart creates an AreaChartView object for the series. To stack area series, call the AreaChartView.setGrouping(value) method.

Refer to the following help topic for additional information: Create Standard Charts — Presentation API for Java.

Example

Create an Area Chart with Data Labels

The following code snippet creates an area chart, displays values in data labels, and applies bold text formatting to the last data label:

import java.io.*;
import java.nio.file.*;
import java.util.List;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
import com.devexpress.system.drawing.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Presentation presentation = new Presentation()) {
            // Add a blank slide.
            presentation.getSlides().clear();
            Slide slide = new Slide(SlideLayoutType.BLANK);
            presentation.getSlides().add(slide);

            // Insert a chart that fills the slide.
            Chart chart = new Chart();
            chart.setWidth(presentation.getSlideSize().getWidth());
            chart.setHeight(presentation.getSlideSize().getHeight());
            slide.getShapes().add(chart);

            // Add an area series.
            AreaSeries series = new AreaSeries();
            series.setText("Visitors");
            series.setArguments(new ChartStringData(List.of("Jan", "Feb", "Mar", "Apr", "May")));
            series.setValues(new ChartNumericData(List.of(320.0, 410.0, 380.0, 520.0, 610.0)));
            chart.getSeries().add(series);

            // Fill the area and display values in data labels.
            ChartElement properties = new ChartElement();
            properties.setFill(new SolidFill(Color.getSeaGreen()));
            series.setProperties(properties);
            series.getDataLabels().setShowValue(true);

            // Apply bold text formatting to the last data label.
            TextProperties boldText = new TextProperties();
            boldText.setBold(true);
            AreaDataLabel lastLabel = new AreaDataLabel();
            lastLabel.setShowValue(true);
            lastLabel.setTextProperties(boldText);
            series.getDataLabels().setLabel(4, lastLabel);

            // Save the presentation.
            Files.createDirectories(Path.of("output"));
            try (OutputStream output = Files.newOutputStream(Path.of("output", "Chart.pptx"))) {
                presentation.save(output);
            }
        }
    }
}

The following screenshot illustrates the result:

 Area chart with data labels and a bold last label created with the DevExpress Presentation API for Java

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
See Also

AreaSeries()

Initializes a new instance of the AreaSeries class.

Declaration

public AreaSeries()

Methods

getAxisGroup() Method

Returns the axis group that displays the series.

Declaration

public ChartAxisGroupType getAxisGroup()

Returns

Type Description
ChartAxisGroupType

The axis group.

getErrorBars() Method

Returns the collection of error bars for the series.

Declaration

public IErrorBarCollection getErrorBars()

Returns

Type Description
IErrorBarCollection

The collection of error bars.

Remarks

Add an ErrorBar object to the collection to display error bars for series values.

Refer to the following help topic for additional information: Add Error Bars and Trend Lines to Charts — Presentation API for Java.

getTrendLine() Method

Returns the trend line of the series.

Declaration

public TrendLine getTrendLine()

Returns

Type Description
TrendLine

The trend line, or null if the series has no trend line.

setAxisGroup(ChartAxisGroupType value) Method

Sets the axis group that displays the series.

Declaration

public void setAxisGroup(ChartAxisGroupType value)

Parameters

Name Type Description
value ChartAxisGroupType

The axis group.

Remarks

The setAxisGroup(value) method accepts the following values:

Value Description
PRIMARY Indicates primary axes.
SECONDARY Indicates secondary axes.

If you do not call the setAxisGroup(value) method, the series uses primary axes. If you call the setAxisGroup(ChartAxisGroupType.SECONDARY) method, the chart moves the series to a separate chart view and creates secondary axes for this view.

Refer to the following help topics for additional information:

setTrendLine(TrendLine value) Method

Sets the trend line of the series.

Declaration

public void setTrendLine(TrendLine value)

Parameters

Name Type Description
value TrendLine

The trend line, or null to remove the trend line.

Remarks

Refer to the following help topic for additional information: Add Error Bars and Trend Lines to Charts — Presentation API for Java.