LineDataLabel Class
Contains settings for a data label in a line chart.
Declaration
public class LineDataLabel extends DataLabel
Remarks
The LineDataLabel class inherits label content and formatting settings from DataLabel and DataLabelBase classes (for example, LineDataLabel.setShowValue(value) and LineDataLabel.setCustomText(value) methods).
The setLabelPosition(LineDataLabelPosition value) method specifies the label position relative to the data point.
To format the data label of an individual data point, pass a LineDataLabel object to the ILineDataLabels.setLabel(key, value) method.
Refer to the following help topic for additional information: Customize Chart Data Labels — Presentation API for Java.
Example
Create a Line Chart with Markers and Data Labels
The following code snippet creates a line chart with two series, displays circle markers, smooths the second line, and displays a data label for the last data point of the first series:
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 two line series with circle markers.
String[] names = { "2024", "2025" };
double[][] values = { { 12, 18, 15, 21 }, { 14, 16, 22, 25 } };
for (int i = 0; i < names.length; i++) {
LineSeries series = new LineSeries();
series.setText(names[i]);
series.setArguments(new ChartStringData(List.of("Q1", "Q2", "Q3", "Q4")));
series.setValues(new ChartNumericData(List.of(values[i][0], values[i][1], values[i][2], values[i][3])));
Marker marker = new Marker();
marker.setSymbol(MarkerStyle.CIRCLE);
marker.setSize(8);
series.setMarker(marker);
chart.getSeries().add(series);
}
// Smooth the second line.
LineSeries secondSeries = (LineSeries) chart.getSeries().get(1);
secondSeries.setSmooth(true);
// Display the Q4 value of the first series above the data point.
LineDataLabel label = new LineDataLabel();
label.setShowValue(true);
label.setLabelPosition(LineDataLabelPosition.TOP);
LineSeries firstSeries = (LineSeries) chart.getSeries().get(0);
firstSeries.getDataLabels().setLabel(3, label);
// 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:

Inherited Members
Inheritance
LineDataLabel()
Initializes a new instance of the LineDataLabel class.
Declaration
public LineDataLabel()
Methods
deepClone() Method
Returns a deep copy of this LineDataLabel instance.
Declaration
public LineDataLabel deepClone()
Returns
| Type | Description |
|---|---|
LineDataLabel |
A deep copy of this |
getLabelPosition() Method
Returns the data label position relative to the data point.
Declaration
public LineDataLabelPosition getLabelPosition()
Returns
| Type | Description |
|---|---|
| LineDataLabelPosition | The data label position. |
setLabelPosition(LineDataLabelPosition value) Method
Sets the data label position relative to the data point.
Declaration
public void setLabelPosition(LineDataLabelPosition value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | LineDataLabelPosition | The data label position. |
Exceptions
| Type | Description |
|---|---|
| NullPointerException | Thrown if the |
Remarks
The setLabelPosition(value) method accepts the following values:
| Value | Description |
|---|---|
| LEFT | Indicates that the data label is to the left of the data point. |
| TOP | Indicates that the data label is above the data point. |
| RIGHT | Indicates that the data label is to the right of the data point. |
| BOTTOM | Indicates that the data label is below the data point. |
| CENTER | Indicates that the data label is centered on the data point. |
| DEFAULT | Indicates that the data label position is not specified, and the chart application uses the default position. |
If you do not call the setLabelPosition(value) method, the API uses LineDataLabelPosition.DEFAULT for a new data label and the value from the document for a loaded data label.