Skip to main content

GroupedChartView Class

The base class for chart views that can stack series.

Declaration

public abstract class GroupedChartView extends ColorfulChartView

Remarks

AreaChartView, Area3DChartView, LineChartView, and Line3DChartView classes derive from the GroupedChartView class.

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

Example: Stack Area Series and Display Drop Lines

The following code snippet creates an area chart with two series, stacks the series, and displays dark gray drop lines:

import java.io.*;
import java.nio.file.*;
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.
            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[] quarters = { "Q1", "Q2", "Q3", "Q4" };
            double[] online = { 40, 55, 50, 70 };
            double[] retail = { 60, 50, 65, 60 };
            data.get(0, "B1").setTextValue("Online");
            data.get(0, "C1").setTextValue("Retail");
            for (int i = 0; i < quarters.length; i++) {
                data.get(0, "A" + (i + 2)).setTextValue(quarters[i]);
                data.get(0, "B" + (i + 2)).setNumericValue(online[i]);
                data.get(0, "C" + (i + 2)).setNumericValue(retail[i]);
            }

            // Add two area series.
            for (String column : new String[] { "B", "C" }) {
                AreaSeries series = new AreaSeries();
                series.setArguments(new ChartDataReference(0, "A2", "A5"));
                series.setValues(new ChartDataReference(0, column + "2", column + "5"));
                series.setTextReference(new ChartDataReference(0, column + "1"));
                chart.getSeries().add(series);
            }

            // Stack the series.
            AreaChartView view = (AreaChartView) chart.getViews().get(0);
            view.setGrouping(ChartGrouping.STACKED);

            // Display dark gray drop lines.
            view.setShowDropLines(true);
            ChartElement dropLines = new ChartElement();
            OutlineStyle dropLineStyle = new OutlineStyle();
            dropLineStyle.setFill(new SolidFill(Color.getDarkSlateGray()));
            dropLines.setOutlineStyle(dropLineStyle);
            view.setDropLineProperties(dropLines);

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

See Also

GroupedChartView()

Initializes a new instance of the GroupedChartView class.

Declaration

public GroupedChartView()

Methods

getDropLineProperties() Method

Returns appearance settings for drop lines.

Declaration

public ChartElement getDropLineProperties()

Returns

Type Description
ChartElement

Drop line appearance settings.

getGrouping() Method

Returns the series grouping type.

Declaration

public ChartGrouping getGrouping()

Returns

Type Description
ChartGrouping

The series grouping type.

getShowDropLines() Method

Returns whether the view displays drop lines.

Declaration

public boolean getShowDropLines()

Returns

Type Description
boolean

true if the view displays drop lines; otherwise, false.

setDropLineProperties(ChartElement value) Method

Sets appearance settings for drop lines.

Declaration

public void setDropLineProperties(ChartElement value)

Parameters

Name Type Description
value ChartElement

Drop line appearance settings.

Remarks

Note

Drop line settings take effect when you call the setShowDropLines(true) method.

setGrouping(ChartGrouping value) Method

Sets the series grouping type.

Declaration

public void setGrouping(ChartGrouping value)

Parameters

Name Type Description
value ChartGrouping

The series grouping type.

Remarks

The setGrouping(value) method accepts the following values:

Value Description
STANDARD Indicates series values displayed without stacking.
STACKED Indicates series values stacked on top of each other in each category.
PERCENT_STACKED Indicates series values stacked and scaled to 100% in each category.

If you do not call the setGrouping(value) method, the API uses ChartGrouping.STANDARD.

To stack bar series, call the BarChartViewBase.setBarGrouping(value) method.

setShowDropLines(boolean value) Method

Sets whether to display drop lines.

Declaration

public void setShowDropLines(boolean value)

Parameters

Name Type Description
value boolean

true to display drop lines; otherwise, false.

Remarks

Drop lines extend from data points to the category axis. Call the setDropLineProperties(ChartElement value) method to specify drop line appearance.