Skip to main content

Bar3DDataLabel Class

Contains settings for a data label in a 3D bar chart.

Declaration

public class Bar3DDataLabel extends DataLabel

Remarks

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

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

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

Bar3DDataLabel()

Initializes a new instance of the Bar3DDataLabel class.

Declaration

public Bar3DDataLabel()

Methods

deepClone() Method

Returns a deep copy of this Bar3DDataLabel instance.

Declaration

public Bar3DDataLabel deepClone()

Returns

Type Description
Bar3DDataLabel

A deep copy of this Bar3DDataLabel.