Skip to main content

LayoutModeType Enum

Lists layout modes for position and size values of chart elements.

Declaration

public enum LayoutModeType extends Enum<LayoutModeType> implements IIntEnum

Members

Name Description
EDGE

Left and top values specify the element position relative to the chart edges. Width and height values specify positions of the right and bottom element edges.

FACTOR

Left and top values specify offsets from the default element position. Width and height values specify the element size.

fromValue(int value)

Returns the LayoutModeType enumeration constant with the specified integer value.

getName()

Returns the name of the LayoutModeType enumeration constant.

getValue()

Returns the integer value of the LayoutModeType enumeration constant.

toString()

Returns the string representation of the LayoutModeType enumeration constant.

valueOf(String name)

Returns the LayoutModeType enumeration constant with the specified name.

values()

Returns an array of all LayoutModeType enumeration constants.

Remarks

Call the LayoutPosition.getMode() method to get the layout mode of a position or size value. To specify the layout mode, pass a value to the LayoutPosition(mode, value) constructor.

Example

Position a Legend and Hide a Legend Entry

The following code snippet places the chart legend in the top-left corner of the chart and hides the legend entry for the first series:

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 bar series.
            String[] names = { "2024", "2025" };
            double[][] values = { { 12, 18, 15 }, { 14, 20, 19 } };
            for (int i = 0; i < names.length; i++) {
                BarSeries series = new BarSeries();
                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])));
                chart.getSeries().add(series);
            }

            // Place the legend in the top-left corner of the chart.
            Legend legend = new Legend();
            LayoutOptions layout = new LayoutOptions();
            layout.setLeft(new LayoutPosition(LayoutModeType.EDGE, 0.05));
            layout.setTop(new LayoutPosition(LayoutModeType.EDGE, 0.05));
            layout.setWidth(new LayoutPosition(LayoutModeType.FACTOR, 0.15));
            layout.setHeight(new LayoutPosition(LayoutModeType.FACTOR, 0.15));
            legend.setLayout(layout);

            // Hide the legend entry for the first series.
            LegendEntry entry = new LegendEntry();
            entry.setHidden(true);
            legend.getCustomEntries().put(0, entry);
            chart.setLegend(legend);

            // Save the presentation.
            Files.createDirectories(Path.of("output"));
            try (OutputStream output = Files.newOutputStream(Path.of("output", "Chart.pptx"))) {
                presentation.save(output);
            }
        }
    }
}

Implements

com.devexpress.java.enums.IIntEnum

Inherited Members

java.lang.Enum.<T>valueOf(java.lang.Class<T>,java.lang.String)
java.lang.Enum.clone()
java.lang.Enum.compareTo(E)
java.lang.Enum.describeConstable()
java.lang.Enum.equals(java.lang.Object)
java.lang.Enum.finalize()
java.lang.Enum.getDeclaringClass()
java.lang.Enum.hashCode()
java.lang.Enum.name()
java.lang.Enum.ordinal()
java.lang.Enum.toString()
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
java.lang.Enum
LayoutModeType