Skip to main content

DataTableOptions Class

Contains settings for a chart data table.

Declaration

public class DataTableOptions extends ChartElement

Remarks

A data table displays chart data in a grid below the plot area. To display a data table, pass a DataTableOptions object to the Chart.setDataTable(value) method.

The DataTableOptions class inherits fill and outline settings from the ChartElement class.

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

Example: Display a Data Table Below a Chart

The following code snippet creates a line chart with three series and displays a data table with borders, an outline, and legend keys:

import java.io.*;
import java.nio.file.*;
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 chart data: quarters in column A and values in columns B to D.
            ChartData data = chart.getData();
            String[] quarters = { "Q1", "Q2", "Q3" };
            double[][] values = { { 120, 95, 140 }, { 90, 110, 125 }, { 20, 60, 50 } };
            for (int row = 0; row < quarters.length; row++) {
                data.get("A" + (row + 1)).setTextValue(quarters[row]);
                for (int column = 0; column < values.length; column++)
                    data.get((char) ('B' + column) + String.valueOf(row + 1)).setNumericValue(values[column][row]);
            }

            // Add a line series for each value column.
            for (String column : new String[] { "B", "C", "D" }) {
                LineSeries series = new LineSeries();
                series.setArguments(new ChartDataReference("A1", "A3"));
                series.setValues(new ChartDataReference(column + "1", column + "3"));
                chart.getSeries().add(series);
            }

            // Display a data table with borders, an outline, and legend keys.
            DataTableOptions dataTable = new DataTableOptions();
            dataTable.setShowHorizontalBorder(true);
            dataTable.setShowVerticalBorder(true);
            dataTable.setShowOutline(true);
            dataTable.setShowLegendKeys(true);
            chart.setDataTable(dataTable);

            // 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

DataTableOptions()

Initializes a new instance of the DataTableOptions class.

Declaration

public DataTableOptions()

Methods

deepClone() Method

Creates a copy of the data table settings.

Declaration

public DataTableOptions deepClone()

Returns

Type Description
DataTableOptions

A copy of the data table settings.

getShowHorizontalBorder() Method

Returns whether the data table displays horizontal borders.

Declaration

public boolean getShowHorizontalBorder()

Returns

Type Description
boolean

true if the data table displays horizontal borders; otherwise, false.

getShowLegendKeys() Method

Returns whether the data table displays legend keys next to series names.

Declaration

public boolean getShowLegendKeys()

Returns

Type Description
boolean

true if the data table displays legend keys next to series names; otherwise, false.

getShowOutline() Method

Returns whether the data table displays an outline.

Declaration

public boolean getShowOutline()

Returns

Type Description
boolean

true if the data table displays an outline; otherwise, false.

getShowVerticalBorder() Method

Returns whether the data table displays vertical borders.

Declaration

public boolean getShowVerticalBorder()

Returns

Type Description
boolean

true if the data table displays vertical borders; otherwise, false.

getTextProperties() Method

Returns text formatting settings for the data table.

Declaration

public TextProperties getTextProperties()

Returns

Type Description
TextProperties

Text formatting settings, or null if the data table has no text formatting settings.

setShowHorizontalBorder(boolean value) Method

Sets whether the data table displays horizontal borders.

Declaration

public void setShowHorizontalBorder(boolean value)

Parameters

Name Type Description
value boolean

true to display horizontal borders; otherwise, false.

Remarks

A new DataTableOptions object does not display horizontal borders.

setShowLegendKeys(boolean value) Method

Sets whether the data table displays legend keys next to series names.

Declaration

public void setShowLegendKeys(boolean value)

Parameters

Name Type Description
value boolean

true to display legend keys next to series names; otherwise, false.

Remarks

A new DataTableOptions object does not display legend keys next to series names.

setShowOutline(boolean value) Method

Sets whether the data table displays an outline.

Declaration

public void setShowOutline(boolean value)

Parameters

Name Type Description
value boolean

true to display an outline; otherwise, false.

Remarks

A new DataTableOptions object does not display an outline.

setShowVerticalBorder(boolean value) Method

Sets whether the data table displays vertical borders.

Declaration

public void setShowVerticalBorder(boolean value)

Parameters

Name Type Description
value boolean

true to display vertical borders; otherwise, false.

Remarks

A new DataTableOptions object does not display vertical borders.

setTextProperties(TextProperties value) Method

Sets text formatting settings for the data table.

Declaration

public void setTextProperties(TextProperties value)

Parameters

Name Type Description
value TextProperties

Text formatting settings.