Skip to main content

ChartViewBase Class

The base class for chart views in a standard chart.

Declaration

public abstract class ChartViewBase extends OfficeObject

Remarks

A chart view displays series of the same chart type in the same axis group. Call the Chart.getViews() method to access views of a standard chart. When you add a series of another chart type or axis group, the chart creates a view for the series.

To access settings for a specific chart type, cast a view to a descendant class (for example, BarChartView or LineChartView).

Refer to the following help topics for additional information:

Example: List Chart Views in a Combo Chart

The following code snippet creates a chart with a bar series and a line series in the secondary axis group, and prints the chart type and axis group of each chart view:

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();
            String[] months = { "Jan", "Feb", "Mar" };
            double[] sales = { 120, 95, 140 };
            double[] growth = { 0.05, -0.2, 0.47 };
            for (int i = 0; i < months.length; i++) {
                data.get(0, "A" + (i + 1)).setTextValue(months[i]);
                data.get(0, "B" + (i + 1)).setNumericValue(sales[i]);
                data.get(0, "C" + (i + 1)).setNumericValue(growth[i]);
            }

            // Add a bar series and a line series in the secondary axis group.
            BarSeries salesSeries = new BarSeries();
            salesSeries.setArguments(new ChartDataReference(0, "A1", "A3"));
            salesSeries.setValues(new ChartDataReference(0, "B1", "B3"));
            chart.getSeries().add(salesSeries);

            LineSeries growthSeries = new LineSeries();
            growthSeries.setArguments(new ChartDataReference(0, "A1", "A3"));
            growthSeries.setValues(new ChartDataReference(0, "C1", "C3"));
            growthSeries.setAxisGroup(ChartAxisGroupType.SECONDARY);
            chart.getSeries().add(growthSeries);

            // List the chart views that the chart created for the series.
            for (ChartViewBase view : chart.getViews()) {
                System.out.println(view.getChartType() + " view, " + view.getAxisGroup() + " axis group");
            }

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

ChartViewBase()

Initializes a new instance of the ChartViewBase class.

Declaration

public ChartViewBase()

Methods

getAxisGroup() Method

Returns the axis group of the chart view.

Declaration

public ChartAxisGroupType getAxisGroup()

Returns

Type Description
ChartAxisGroupType

The axis group.

Remarks

The getAxisGroup() method returns one of the following values:

Value Description
PRIMARY Indicates primary axes.
SECONDARY Indicates secondary axes.

getChartType() Method

Returns the chart type of the view.

Declaration

public abstract ChartType getChartType()

Returns

Type Description
ChartType

The chart type.