ChartEx Class
A chart of a type introduced in Microsoft Excel 2016 (for example, a waterfall, funnel, or treemap chart) on a slide.
Declaration
public class ChartEx extends ChartBase
Remarks
Add series to the ChartEx.getSeries() collection to populate a chart with data. The series type specifies the chart type. For example, a WaterfallSeries creates a waterfall chart. The ChartExType enumeration lists available chart types.
To create a standard chart (for example, a bar, line, or pie chart), use the Chart class.
Refer to the following help topics for additional information:
- Create and Customize Charts — Presentation API for Java
- Create Waterfall, Funnel, Treemap, and Other Office 2016 Charts — Presentation API for Java
Example
Create a Waterfall Chart with Total Columns
The following code snippet creates a waterfall chart, displays the first and last data points as totals, displays connector lines, and adds a chart title:
import java.io.*;
import java.nio.file.*;
import java.util.List;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
import com.devexpress.system.drawing.*;
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.
ChartEx chart = new ChartEx();
chart.setWidth(presentation.getSlideSize().getWidth());
chart.setHeight(presentation.getSlideSize().getHeight());
slide.getShapes().add(chart);
// Create a waterfall series and specify data.
WaterfallSeries series = new WaterfallSeries();
series.setText("Cash Flow");
series.setArguments(new ChartStringData(List.of("Start", "Jan", "Feb", "Mar", "End")));
series.setValues(new ChartNumericData(List.of(10.0, 12.0, -5.0, 8.0, 25.0)));
// Display the first and last points as totals and connect the columns.
series.getSubtotalDataPoints().add(0);
series.getSubtotalDataPoints().add(4);
series.setShowConnectorLines(true);
chart.getSeries().add(series);
// Add a chart title.
TextProperties titleTextProperties = new TextProperties();
titleTextProperties.setFontSize(30f);
titleTextProperties.setFill(new SolidFill(Color.getDarkBlue()));
chart.setTitle(new ChartTitleEx(
new TextArea("Cash Flow", new TextParagraphProperties(titleTextProperties))));
// 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:

Inherited Members
Inheritance
Constructors
ChartEx() Constructor
Initializes a new instance of the ChartEx class.
Declaration
public ChartEx()
Remarks
If you do not specify the chart width or height, the API sets the width to 600 and the height to 400 Document units (1/300 inch).
ChartEx(float x, float y, float width, float height) Constructor
Initializes a new instance of the ChartEx class with the specified position and size.
Declaration
public ChartEx(float x, float y, float width, float height)
Parameters
| Name | Type | Description |
|---|---|---|
| x | float | The horizontal position of the chart. |
| y | float | The vertical position of the chart. |
| width | float | The chart width. |
| height | float | The chart height. |
ChartEx(float x, float y, float width) Constructor
Initializes a new instance of the ChartEx class with the specified position and width.
Declaration
public ChartEx(float x, float y, float width)
Parameters
| Name | Type | Description |
|---|---|---|
| x | float | The horizontal position of the chart. |
| y | float | The vertical position of the chart. |
| width | float | The chart width. |
Remarks
If you do not specify the chart width or height, the API sets the width to 600 and the height to 400 Document units (1/300 inch).
ChartEx(float x, float y) Constructor
Initializes a new instance of the ChartEx class with the specified position.
Declaration
public ChartEx(float x, float y)
Parameters
| Name | Type | Description |
|---|---|---|
| x | float | The horizontal position of the chart. |
| y | float | The vertical position of the chart. |
Remarks
If you do not specify the chart width or height, the API sets the width to 600 and the height to 400 Document units (1/300 inch).
ChartEx(float x) Constructor
Initializes a new instance of the ChartEx class with the specified horizontal position.
Declaration
public ChartEx(float x)
Parameters
| Name | Type | Description |
|---|---|---|
| x | float | The horizontal position of the chart. |
Remarks
If you do not specify the chart width or height, the API sets the width to 600 and the height to 400 Document units (1/300 inch).
Methods
deepClone() Method
Creates a copy of the chart.
Declaration
public ChartEx deepClone()
Returns
| Type | Description |
|---|---|
ChartEx |
A copy of the chart. |
Remarks
The copy contains series, axes, title, legend, and other chart settings. To display the copy, add it to the shape collection of a slide (SlideBase.getShapes()).
getArgumentAxis() Method
Returns the category axis.
Declaration
public CategoryAxisEx getArgumentAxis()
Returns
| Type | Description |
|---|---|
| CategoryAxisEx | The category axis, or |
getColorPalette() Method
Returns the chart color palette.
Declaration
public ChartColorPalette getColorPalette()
Returns
| Type | Description |
|---|---|
| ChartColorPalette | The chart color palette. |
getLegend() Method
Returns the chart legend.
Declaration
public LegendEx getLegend()
Returns
| Type | Description |
|---|---|
| LegendEx | The chart legend, or |
getSecondaryValueAxis() Method
Returns the secondary value axis.
Declaration
public ValueAxisEx getSecondaryValueAxis()
Returns
| Type | Description |
|---|---|
| ValueAxisEx | The secondary value axis, or |
getSeries() Method
Returns the collection of chart series.
Declaration
public ISeriesExCollection getSeries()
Returns
| Type | Description |
|---|---|
| ISeriesExCollection | The collection of chart series. |
Remarks
The first series type specifies the chart layout. If the collection contains a ParetoSeries, the chart uses the Pareto layout. The chart creates axes that the layout requires.
A ParetoSeries requires an associated HistogramSeries in the same collection. Call the ParetoSeries.setHistogramSeries(value) method to specify the histogram series, and add the histogram series to the collection before the Pareto series. Otherwise, the API throws an InvalidOperationException.
The API also throws an InvalidOperationException if the series type is not compatible with the chart style or with axes that you assigned before you added series.
getStyle() Method
Returns the chart style.
Declaration
public ChartExStyle getStyle()
Returns
| Type | Description |
|---|---|
| ChartExStyle | The chart style. |
getTitle() Method
Returns the chart title.
Declaration
public ChartTitleEx getTitle()
Returns
| Type | Description |
|---|---|
| ChartTitleEx | The chart title, or |
getValueAxis() Method
Returns the primary value axis.
Declaration
public ValueAxisEx getValueAxis()
Returns
| Type | Description |
|---|---|
| ValueAxisEx | The primary value axis, or |
setArgumentAxis(CategoryAxisEx value) Method
Sets the category axis.
Declaration
public void setArgumentAxis(CategoryAxisEx value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | CategoryAxisEx | The category axis. |
Exceptions
| Type | Description |
|---|---|
| ArgumentNullException | Thrown if you call the |
| InvalidOperationException | Thrown if the chart layout does not support a category axis (for example, a treemap chart). The exception message is “The current chart layout does not support the specified axis type.” |
Remarks
Box and whisker, funnel, histogram, Pareto, and waterfall charts use a category axis. The chart creates the category axis when you add series of these types.
If you assign a category axis before the chart contains series, the chart stores the axis and applies it when you add the first series. If the layout of this series does not support a category axis, the API throws an InvalidOperationException when you add the series.
Refer to the following help topic for additional information: Customize Chart Axes — Presentation API for Java.
setColorPalette(ChartColorPalette value) Method
Sets the chart color palette.
Declaration
public void setColorPalette(ChartColorPalette value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ChartColorPalette | The chart color palette. |
Exceptions
| Type | Description |
|---|---|
| ArgumentNullException | Thrown if the |
Remarks
A new chart uses the ChartColorPalette.COLORFUL_1 palette.
setLegend(LegendEx value) Method
Sets the chart legend.
Declaration
public void setLegend(LegendEx value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | LegendEx | The chart legend, or |
Remarks
A new chart displays a legend. To hide the legend, call the setLegend(null) method.
Refer to the following help topic for additional information: Customize Chart Legends — Presentation API for Java.
setSecondaryValueAxis(ValueAxisEx value) Method
Sets the secondary value axis.
Declaration
public void setSecondaryValueAxis(ValueAxisEx value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ValueAxisEx | The secondary value axis. |
Exceptions
| Type | Description |
|---|---|
| ArgumentNullException | Thrown if you call the |
| InvalidOperationException | Thrown if the chart layout does not support a secondary value axis (for example, a waterfall chart). The exception message is “The current chart layout does not support the specified axis type.” |
Remarks
The chart creates a secondary value axis for the Pareto layout.
If you assign a secondary value axis before the chart contains series, the chart stores the axis. If the first series is not a histogram or Pareto series, the API throws an InvalidOperationException when you add the series. If the first series is a histogram series, the chart does not display the axis until you add a Pareto series.
Refer to the following help topic for additional information: Customize Chart Axes — Presentation API for Java.
setStyle(ChartExStyle value) Method
Sets the chart style.
Declaration
public void setStyle(ChartExStyle value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ChartExStyle | The chart style. |
Exceptions
| Type | Description |
|---|---|
| InvalidOperationException | Thrown if the style is not compatible with the chart type (for example, the |
Remarks
A new chart uses the ChartExStyle.STYLE_1 style. Available styles depend on the chart type:
| Chart Type | Available Styles |
|---|---|
| Box and whisker, histogram, Pareto | STYLE_1–STYLE_6 |
| Sunburst, waterfall | STYLE_1–STYLE_8 |
| Funnel, treemap | STYLE_1–STYLE_9 |
The API checks whether the style is compatible with the chart type when you call the setStyle(value) method and when you add or replace a series.
The value parameter accepts the following values:
| Value | Description |
|---|---|
| CUSTOM | Indicates custom style settings. |
| STYLE_1 | Indicates predefined style 1. |
| STYLE_2 | Indicates predefined style 2. |
| STYLE_3 | Indicates predefined style 3. |
| STYLE_4 | Indicates predefined style 4. |
| STYLE_5 | Indicates predefined style 5. |
| STYLE_6 | Indicates predefined style 6. |
| STYLE_7 | Indicates predefined style 7. |
| STYLE_8 | Indicates predefined style 8. |
| STYLE_9 | Indicates predefined style 9. |
setTitle(ChartTitleEx value) Method
Sets the chart title.
Declaration
public void setTitle(ChartTitleEx value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ChartTitleEx | The chart title, or |
Remarks
A new chart does not display a title. To display a title, pass a ChartTitleEx object to the setTitle(value) method.
setValueAxis(ValueAxisEx value) Method
Sets the primary value axis.
Declaration
public void setValueAxis(ValueAxisEx value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ValueAxisEx | The primary value axis. |
Exceptions
| Type | Description |
|---|---|
| ArgumentNullException | Thrown if you call the |
| InvalidOperationException | Thrown if the chart layout does not support a value axis (for example, a funnel chart). The exception message is “The current chart layout does not support the specified axis type.” |
Remarks
Box and whisker, histogram, Pareto, and waterfall charts use a value axis. The chart creates the primary value axis when you add series of these types.
If you assign a value axis before the chart contains series, the chart stores the axis and applies it when you add the first series. If the layout of this series does not support a value axis, the API throws an InvalidOperationException when you add the series.
Refer to the following help topic for additional information: Customize Chart Axes — Presentation API for Java.