Skip to main content

AreaDataLabel Class

Contains settings for a data label in an area chart.

Declaration

public class AreaDataLabel extends DataLabel

Remarks

The AreaDataLabel class inherits label content and formatting settings from DataLabel and DataLabelBase classes (for example, AreaDataLabel.setShowValue(value) and AreaDataLabel.setCustomText(value) methods).

To format the data label of an individual data point, pass an AreaDataLabel object to the IAreaDataLabels.setLabel(key, value) method.

Refer to the following help topic for additional information: Customize Chart Data Labels — 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
JavaObject
See Also

AreaDataLabel()

Initializes a new instance of the AreaDataLabel class.

Declaration

public AreaDataLabel()

Methods

deepClone() Method

Returns a deep copy of this AreaDataLabel instance.

Declaration

public AreaDataLabel deepClone()

Returns

Type Description
AreaDataLabel

A deep copy of this AreaDataLabel.