Skip to main content

ChartNumericData Class

Numeric chart data specified in code.

Declaration

public class ChartNumericData extends JavaObject implements IChartValueData, IChartArgumentData

Remarks

Pass a ChartNumericData object to a series method that specifies values or arguments (for example, DataSeriesExBase.setValues(value) or SeriesBase.setValues(value)) to specify numeric data in code. To bind series data to chart data cells, use a ChartDataReference object instead.

Refer to the following help topic for additional information: Load Data into 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:

 Waterfall chart with total columns and connector lines created with the DevExpress Presentation API for Java

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
ChartNumericData
See Also

ChartNumericData(Iterable<Double> values)

Initializes a new instance of the ChartNumericData class with the specified values.

Declaration

public ChartNumericData(Iterable<Double> values)

Parameters

Name Type Description
values java.lang.Iterable<java.lang.Double>

Numeric values.

Exceptions

Type Description
ArgumentNullException

Thrown if the values parameter is null.

Methods

cloneArgumentData() Method

Creates a copy of the numeric data.

Declaration

public IChartArgumentData cloneArgumentData()

Returns

Type Description
IChartArgumentData

A copy of the numeric data.

cloneValueData() Method

Creates a copy of the numeric data.

Declaration

public IChartValueData cloneValueData()

Returns

Type Description
IChartValueData

A copy of the numeric data.

getExpression(IChartDataContext context) Method

Returns the reference expression of the data.

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

null, because numeric data does not refer to cells.

getLevelCount() Method

Returns the number of hierarchy levels in the data.

Declaration

public int getLevelCount()

Returns

Type Description
int

0, because numeric data is not hierarchical.

getNumericValues() Method

Returns the numeric values.

Declaration

public List<Double> getNumericValues()

Returns

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

A read-only list of numeric values.

getType() Method

Returns the chart data type.

Declaration

public ChartDataType getType()

Returns

Type Description
ChartDataType

ChartDataType.VALUES.

getValues() Method

Returns the numeric values.

Declaration

public List<Double> getValues()

Returns

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

A read-only list of numeric values.

makeCopy() Method

Creates a copy of the numeric data.

Declaration

public ChartNumericData makeCopy()

Returns

Type Description
ChartNumericData

A copy of the numeric data.