Skip to main content

SeriesBase Class

The base class for series in a standard chart.

Declaration

public abstract class SeriesBase extends OfficeObject

Remarks

Call the Chart.getSeries() method to access series of a standard chart. To create a series, add a descendant class object (for example, BarSeries or LineSeries) to the collection.

Call the convertTo(ChartType chartType) method to create a series of another chart type with the same data and settings.

Refer to the following help topics for additional information:

Example: Convert a Bar Series to an Area Series

The following code snippet adds a bar series to a chart, converts the series to an area series, and replaces the bar series with the area series:

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

            // Add a bar series.
            BarSeries barSeries = new BarSeries();
            barSeries.setText("Revenue");
            barSeries.setArguments(new ChartStringData(List.of("Q1", "Q2", "Q3", "Q4")));
            barSeries.setValues(new ChartNumericData(List.of(10.0, 13.0, 4.0, 7.0)));
            chart.getSeries().add(barSeries);

            // Convert the bar series to an area series and replace it in the chart.
            SeriesBase areaSeries = barSeries.convertTo(ChartType.AREA);
            chart.getSeries().remove(barSeries);
            chart.getSeries().add(areaSeries);

            // 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
SeriesBase
See Also

SeriesBase()

Initializes a new instance of the SeriesBase class.

Declaration

public SeriesBase()

Methods

convertTo(ChartType chartType) Method

Converts the series to the specified chart type.

Declaration

public SeriesBase convertTo(ChartType chartType)

Parameters

Name Type Description
chartType ChartType

The target chart type.

Returns

Type Description
SeriesBase

A new series of the specified chart type.

Exceptions

Type Description
NullPointerException

Thrown if the chartType parameter is null.

Remarks

The convertTo method returns a new series with data and settings copied from the source series and does not modify the source series. To replace the source series in a chart, remove the source series from the Chart.getSeries() collection and add the converted series.

deepClone() Method

Creates a copy of the series.

Declaration

public SeriesBase deepClone()

Returns

Type Description
SeriesBase

A copy of the series.

getArguments() Method

Returns argument data of the series.

Declaration

public IChartArgumentData getArguments()

Returns

Type Description
IChartArgumentData

Argument data, or null if the series has no arguments.

getProperties() Method

Returns fill, outline, and effect settings for the series.

Declaration

public ChartElement getProperties()

Returns

Type Description
ChartElement

Series appearance settings, or null if the series has no custom appearance settings.

getText() Method

Returns the series name.

Declaration

public String getText()

Returns

Type Description
String

The series name, or null if the series has no custom name.

getTextReference() Method

Returns a chart data reference to the series name.

Declaration

public IChartDataReference getTextReference()

Returns

Type Description
IChartDataReference

A reference to the series name, or null if the series name does not use a reference.

getValues() Method

Returns value data of the series.

Declaration

public IChartValueData getValues()

Returns

Type Description
IChartValueData

Value data, or null if the series has no values.

setArguments(IChartArgumentData value) Method

Sets argument data of the series.

Declaration

public void setArguments(IChartArgumentData value)

Parameters

Name Type Description
value IChartArgumentData

Argument data.

Exceptions

Type Description
ArgumentException

Thrown if the value parameter contains hierarchical data. The exception message is “Only Treemap and Sunburst series support hierarchical category data.” Also thrown if the series is in a scatter or bubble chart and the value parameter refers to a cell range that is not a single cell, row, or column. The exception message is “The chart data reference must identify a single cell, row, or column.”

Remarks

To bind arguments to chart data cells, pass a ChartDataReference or ChartDataExpressionReference object to the setArguments(value) method. To specify arguments in code, pass a ChartStringData or ChartNumericData object.

setProperties(ChartElement value) Method

Sets fill, outline, and effect settings for the series.

Declaration

public void setProperties(ChartElement value)

Parameters

Name Type Description
value ChartElement

Series appearance settings.

setText(String value) Method

Sets the series name.

Declaration

public void setText(String value)

Parameters

Name Type Description
value String

The series name.

Remarks

If you pass a value other than null, the API clears the reference that the getTextReference() method returns.

setTextReference(IChartDataReference value) Method

Sets a chart data reference to the series name.

Declaration

public void setTextReference(IChartDataReference value)

Parameters

Name Type Description
value IChartDataReference

A reference to the series name.

Exceptions

Type Description
ArgumentException

Thrown if the series is in a chart on a slide and the value parameter refers to a cell range that is not a single cell, row, or column. The exception message is “The chart data reference must identify a single cell, row, or column.”

Remarks

If you pass a reference, the API clears the series name that the getText() method returns.

setValues(IChartValueData value) Method

Sets value data of the series.

Declaration

public void setValues(IChartValueData value)

Parameters

Name Type Description
value IChartValueData

Value data.

Exceptions

Type Description
ArgumentException

Thrown if the series is in a chart on a slide and the value parameter refers to a cell range that is not a single cell, row, or column. The exception message is “The chart data reference must identify a single cell, row, or column.”

Remarks

To bind values to chart data cells, pass a ChartDataReference or ChartDataExpressionReference object to the setValues(value) method. To specify values in code, pass a ChartNumericData object.