Skip to main content

ChartOptions Class

Contains display options for a standard chart.

Declaration

public class ChartOptions extends OfficeObject

Remarks

Call the Chart.getOptions() method to access chart options.

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

Example

Display Blank Values as Gaps in a Line Chart

The following code snippet creates a line chart with a blank value, displays the blank value as a gap, and applies rounded chart corners:

import java.io.*;
import java.nio.file.*;
import java.time.*;
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);

            // Populate monthly values and leave the July value blank.
            ChartData data = chart.getData();
            double[] values = { 23, 20, 17, 14, 9, 3, Double.NaN, 4, 11, 10, 13, 17 };
            for (int i = 0; i < values.length; i++) {
                data.get("B" + (i + 1)).setDateTimeValue(
                        LocalDate.of(2025, i + 1, 1).atStartOfDay(ZoneOffset.UTC).toInstant());
                if (!Double.isNaN(values[i]))
                    data.get("A" + (i + 1)).setNumericValue(values[i]);
            }

            // Bind a line series to the chart data.
            LineSeries series = new LineSeries();
            series.setArguments(new ChartDataReference("B1", "B12"));
            series.setValues(new ChartDataReference("A1", "A12"));
            chart.getSeries().add(series);

            // Display the blank value as a gap and round chart corners.
            chart.getOptions().setDisplayBlanksAs(DisplayBlanksAsType.GAP);
            chart.getOptions().setRoundedCorners(true);

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

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
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
OfficeObject
ChartOptions

Methods

deepClone() Method

Creates a copy of the chart options.

Declaration

public ChartOptions deepClone()

Returns

Type Description
ChartOptions

A copy of the chart options.

getDisplayBlanksAs() Method

Returns the display mode for blank values.

Declaration

public DisplayBlanksAsType getDisplayBlanksAs()

Returns

Type Description
DisplayBlanksAsType

The display mode for blank values.

getPlotVisibleOnly() Method

Returns whether the chart plots data from visible cells only.

Declaration

public boolean getPlotVisibleOnly()

Returns

Type Description
boolean

true if the chart plots data from visible cells only; otherwise, false.

getRoundedCorners() Method

Returns whether the chart area has rounded corners.

Declaration

public boolean getRoundedCorners()

Returns

Type Description
boolean

true if the chart area has rounded corners; otherwise, false.

getShowDataLabelsOverMax() Method

Returns whether the chart displays data labels for values that exceed the value axis maximum.

Declaration

public boolean getShowDataLabelsOverMax()

Returns

Type Description
boolean

true if the chart displays data labels for values that exceed the value axis maximum; otherwise, false.

setDisplayBlanksAs(DisplayBlanksAsType value) Method

Sets the display mode for blank values.

Declaration

public void setDisplayBlanksAs(DisplayBlanksAsType value)

Parameters

Name Type Description
value DisplayBlanksAsType

The display mode for blank values.

Remarks

A new chart displays blank values as zeros (DisplayBlanksAsType.ZERO).

The value parameter accepts the following values:

Value Description
ZERO

Displays blank values as zeros.

SPAN

Connects data points on both sides of a blank value with a line.

GAP

Displays blank values as gaps.

setPlotVisibleOnly(boolean value) Method

Sets whether the chart plots data from visible cells only.

Declaration

public void setPlotVisibleOnly(boolean value)

Parameters

Name Type Description
value boolean

true to plot data from visible cells only; otherwise, false.

Remarks

A new chart plots data from all cells.

setRoundedCorners(boolean value) Method

Sets whether the chart area has rounded corners.

Declaration

public void setRoundedCorners(boolean value)

Parameters

Name Type Description
value boolean

true to apply rounded corners to the chart area; otherwise, false.

Remarks

A new chart has square corners.

setShowDataLabelsOverMax(boolean value) Method

Sets whether the chart displays data labels for values that exceed the value axis maximum.

Declaration

public void setShowDataLabelsOverMax(boolean value)

Parameters

Name Type Description
value boolean

true to display data labels for values that exceed the value axis maximum; otherwise, false.

Remarks

A new chart does not display data labels for values that exceed the value axis maximum.