Skip to main content

ChartDataExpressionReference Class

A reference to chart data specified by a reference expression (for example, a cell range or a defined name).

Declaration

public class ChartDataExpressionReference extends JavaObject implements IChartValueData, IChartArgumentData, IChartDataReference

Remarks

Pass a ChartDataExpressionReference object to the SeriesBase.setArguments(value), SeriesBase.setValues(value), or SeriesBase.setTextReference(value) method to bind a series to chart data cells. A reference expression is a formula without the equal sign (for example, Sheet1!$B$1:$B$3).

In a loaded presentation, the SeriesBase.getValues() method and other methods that return chart data return a ChartDataReference object if the reference points to a single cell range in chart data. For other expressions (for example, a defined name or a reference to a sheet that chart data does not contain), these methods return a ChartDataExpressionReference object.

Refer to the following help topic for additional information: Load Data into Charts — Presentation API for Java.

Example: Bind Series Data to Reference Expressions

The following code snippet populates chart data cells and binds line series arguments and values to reference expressions:

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.
            ChartData data = chart.getData();
            data.get(0, "A1").setTextValue("Q1");
            data.get(0, "A2").setTextValue("Q2");
            data.get(0, "A3").setTextValue("Q3");
            data.get(0, "B1").setNumericValue(120);
            data.get(0, "B2").setNumericValue(95);
            data.get(0, "B3").setNumericValue(140);

            // Bind series arguments and values to reference expressions.
            LineSeries series = new LineSeries();
            series.setArguments(new ChartDataExpressionReference("Sheet1!$A$1:$A$3"));
            series.setValues(new ChartDataExpressionReference("Sheet1!$B$1:$B$3"));
            chart.getSeries().add(series);

            // 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
com.devexpress.system.JavaObject
ChartDataExpressionReference
See Also

ChartDataExpressionReference(String expression)

Initializes a new instance of the ChartDataExpressionReference class with the specified reference expression.

Declaration

public ChartDataExpressionReference(String expression)

Parameters

Name Type Description
expression String

A reference expression (for example, Sheet1!$A$1:$A$3 or a defined name).

Exceptions

Type Description
ArgumentNullException

Thrown if the expression parameter is null.

Remarks

The ChartDataExpressionReference(expression) constructor does not validate the expression.

Methods

cloneArgumentData() Method

Creates a copy of the expression reference.

Declaration

public IChartArgumentData cloneArgumentData()

Returns

Type Description
IChartArgumentData

A copy of the expression reference.

cloneReference() Method

Creates a copy of the expression reference.

Declaration

public IChartDataReference cloneReference()

Returns

Type Description
IChartDataReference

A copy of the expression reference.

cloneValueData() Method

Creates a copy of the expression reference.

Declaration

public IChartValueData cloneValueData()

Returns

Type Description
IChartValueData

A copy of the expression reference.

getExpression() Method

Returns the reference expression.

Declaration

public String getExpression()

Returns

Type Description
String

The reference expression.

getExpression(IChartDataContext context) Method

Returns the reference expression.

Declaration

public String getExpression(IChartDataContext context)

Parameters

Name Type Description
context IChartDataContext

An object that returns sheet names for sheet indexes.

Returns

Type Description
String

The reference expression.

Remarks

The getExpression(context) method returns the same value as the getExpression() method and does not use the context parameter.

getLevelCount() Method

Returns the number of argument levels in the data object.

Declaration

public int getLevelCount()

Returns

Type Description
int

0 for an expression reference.

getNumericValues() Method

Returns numeric values stored in the data object.

Declaration

public List<Double> getNumericValues()

Returns

Type Description
java.util.List<java.lang.Double>

null for an expression reference.

Remarks

An expression reference does not store values. Chart data cells that the expression refers to contain the values.

getType() Method

Returns the chart data type.

Declaration

public ChartDataType getType()

Returns

Type Description
ChartDataType

ChartDataType.REFERENCE.

makeCopy() Method

Creates a copy of the expression reference.

Declaration

public ChartDataExpressionReference makeCopy()

Returns

Type Description
ChartDataExpressionReference

A copy of the expression reference.