Skip to main content

Line3DChartView Class

Contains settings that apply to 3D line series in a chart view.

Declaration

public class Line3DChartView extends GroupedChartView

Remarks

When you add a Line3DSeries object to a chart, the chart creates a Line3DChartView object for the series. Call the Chart.getViews() method to access chart views.

If the chart has no 3D view settings, the chart also creates a View3DOptions object with an X rotation of 15, a Y rotation of 20, and a perspective of 30. Call the Chart.setView3D(value) method to rotate the chart and specify perspective.

Call the setGapDepth(int value) method to specify the depth gap between series.

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)
See Also

Line3DChartView()

Initializes a new instance of the Line3DChartView class.

Declaration

public Line3DChartView()

Methods

getChartType() Method

Returns the chart type of the view.

Declaration

public ChartType getChartType()

Returns

Type Description
ChartType

ChartType.LINE_3_D.

getGapDepth() Method

Returns the distance between series in the depth direction.

Declaration

public int getGapDepth()

Returns

Type Description
int

The depth gap between series (from 0 to 500).

setGapDepth(int value) Method

Sets the distance between series in the depth direction.

Declaration

public void setGapDepth(int value)

Parameters

Name Type Description
value int

The depth gap between series (from 0 to 500).

Exceptions

Type Description
ArgumentOutOfRangeException

Thrown if the value parameter is less than 0 or greater than 500.

Remarks

The value range is from 0 to 500. If you do not call the setGapDepth(value) method, the API uses 150.