Skip to main content

Line3DSeries Class

A 3D line series in a standard chart.

Declaration

public class Line3DSeries extends LineSeriesBase

Remarks

Add a Line3DSeries object to the Chart.getSeries() collection to create a 3D line chart. The chart creates a Line3DChartView object for the series.

Call the Chart.setView3D(value) method to rotate the chart and specify perspective.

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

Example

Create a 3D Line Chart

The following code snippet creates a 3D line chart with two series, rotates the chart, increases the depth gap between series, and displays a data label for one data point:

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

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 3D line series.
            String[] names = { "Online", "Retail" };
            double[][] values = { { 12, 18, 15, 21 }, { 9, 11, 14, 13 } };
            for (int i = 0; i < names.length; i++) {
                Line3DSeries series = new Line3DSeries();
                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])));
                chart.getSeries().add(series);
            }

            // Increase the depth gap between series.
            Line3DChartView view = (Line3DChartView) chart.getViews().get(0);
            view.setGapDepth(250);

            // Rotate the chart.
            View3DOptions view3D = new View3DOptions();
            view3D.setXRotation(20);
            view3D.setYRotation(30);
            chart.setView3D(view3D);

            // Display the Q4 value of the first series.
            Line3DDataLabel label = new Line3DDataLabel();
            label.setShowValue(true);
            Line3DSeries firstSeries = (Line3DSeries) 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:

 3D line chart with two series and a data 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

Line3DSeries()

Initializes a new instance of the Line3DSeries class.

Declaration

public Line3DSeries()

Methods

getDataLabels() Method

Returns data label settings for the series.

Declaration

public ILine3DDataLabels getDataLabels()

Returns

Type Description
ILine3DDataLabels

Data label settings.

Remarks

Refer to the following help topic for additional information: Customize Chart Data Labels — Presentation API for Java.

getDataLabelsRange() Method

Returns a reference to cells that contain text for series data labels.

Declaration

public IChartDataReference getDataLabelsRange()

Returns

Type Description
IChartDataReference

A reference to the cell range, or null if the series has no data label range.

setDataLabelsRange(IChartDataReference value) Method

Sets a reference to cells that contain text for series data labels.

Declaration

public void setDataLabelsRange(IChartDataReference value)

Parameters

Name Type Description
value IChartDataReference

A reference to the cell range, or null to remove the reference.

Remarks

When you assign a cell range to a series in a chart, the API calls the setShowDataLabelRange(true) method of the object that the series getDataLabels() method returns. Each data label displays the value of the cell with the same index in the range. Call the setDataLabelsRange(null) method to remove cell values from data labels.