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 |
getName()
|
Returns the name of the |
getValue()
|
Returns the integer value of the |
toString()
|
Returns the string representation of the |
valueOf(String name)
|
Returns the |
values()
|
Returns an array of all |
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);
}
}
}
}