Skip to main content

Bar3DSeries Class

A 3D bar or column series in a standard chart.

Declaration

public class Bar3DSeries extends BarSeriesBase

Remarks

Add a Bar3DSeries object to the Chart.getSeries() collection to create a 3D bar or column chart. The chart creates a Bar3DChartView object for the series.

Call the setBarShapeType(BarChartShapeType value) method to specify the bar shape for an individual series.

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

Example

Create a 3D Column Chart with Different Bar Shapes

The following code snippet creates a 3D column chart with cylinder and pyramid columns 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 bar series with different bar shapes.
            String[] names = { "2024", "2025" };
            BarChartShapeType[] shapes = { BarChartShapeType.CYLINDER, BarChartShapeType.PYRAMID };
            double[][] values = { { 12, 18, 15 }, { 14, 20, 19 } };
            for (int i = 0; i < names.length; i++) {
                Bar3DSeries series = new Bar3DSeries();
                series.setText(names[i]);
                series.setArguments(new ChartStringData(List.of("Q1", "Q2", "Q3")));
                series.setValues(new ChartNumericData(List.of(values[i][0], values[i][1], values[i][2])));
                series.setBarShapeType(shapes[i]);
                chart.getSeries().add(series);
            }

            // Display the Q2 value of the second series in a data label.
            Bar3DDataLabel label = new Bar3DDataLabel();
            label.setShowValue(true);
            Bar3DSeries secondSeries = (Bar3DSeries) chart.getSeries().get(1);
            secondSeries.getDataLabels().setLabel(1, label);

            // Display the series side by side.
            Bar3DChartView view = (Bar3DChartView) chart.getViews().get(0);
            view.setBarGrouping(BarChartGrouping.CLUSTERED);

            // 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 column chart with cylinder and pyramid columns 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

Bar3DSeries()

Initializes a new instance of the Bar3DSeries class.

Declaration

public Bar3DSeries()

Methods

getBarShapeType() Method

Returns the bar shape of the series.

Declaration

public BarChartShapeType getBarShapeType()

Returns

Type Description
BarChartShapeType

The bar shape.

getDataLabels() Method

Returns data label settings for the series.

Declaration

public IBar3DDataLabels getDataLabels()

Returns

Type Description
IBar3DDataLabels

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.

setBarShapeType(BarChartShapeType value) Method

Sets the bar shape of the series.

Declaration

public void setBarShapeType(BarChartShapeType value)

Parameters

Name Type Description
value BarChartShapeType

The bar shape.

Remarks

The setBarShapeType(value) method accepts the following values:

Value Description
AUTO Indicates the default bar shape.
BOX Indicates box-shaped bars.
CONE Indicates cone-shaped bars.
CONE_TO_MAX Indicates cone-shaped bars truncated at data point values.
CYLINDER Indicates cylinder-shaped bars.
PYRAMID Indicates pyramid-shaped bars.
PYRAMID_TO_MAX Indicates pyramid-shaped bars truncated at data point values.

If you do not call the setBarShapeType(value) method, the series uses BarChartShapeType.AUTO, and the shape specified by the Bar3DChartView.setBarShapeType(value) method applies to the series.

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.