Skip to main content

BoxAndWhiskerSeries Class

A series in a box and whisker chart.

Declaration

public class BoxAndWhiskerSeries extends DataSeriesExBase

Remarks

Add a BoxAndWhiskerSeries object to the ChartEx.getSeries() collection to create a box and whisker chart. A box and whisker chart displays the distribution of values (quartiles, the median, the mean, and outliers).

Series arguments group values into categories. The series displays a box for each category.

Refer to the following help topic for additional information: Create Waterfall, Funnel, Treemap, and Other Office 2016 Charts — Presentation API for Java.

Example

Create a Box and Whisker Chart

The following code snippet creates a box and whisker chart with two series and two categories, displays mean markers, mean lines, and outliers, and applies the exclusive quartile calculation method:

import java.io.*;
import java.nio.file.*;
import java.util.*;
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.
            ChartEx chart = new ChartEx();
            chart.setWidth(presentation.getSlideSize().getWidth());
            chart.setHeight(presentation.getSlideSize().getHeight());
            slide.getShapes().add(chart);

            // Each value belongs to the category with the same index (five Math scores, then five Science scores).
            List<String> subjects = new ArrayList<>(Collections.nCopies(5, "Math"));
            subjects.addAll(Collections.nCopies(5, "Science"));

            // Add a box and whisker series for each team.
            String[] teams = { "Team A", "Team B" };
            List<List<Double>> scores = List.of(
                    List.of(62.0, 70.0, 74.0, 80.0, 98.0, 58.0, 66.0, 71.0, 75.0, 82.0),
                    List.of(55.0, 64.0, 69.0, 73.0, 79.0, 61.0, 68.0, 72.0, 77.0, 85.0));
            for (int i = 0; i < teams.length; i++) {
                BoxAndWhiskerSeries series = new BoxAndWhiskerSeries();
                series.setText(teams[i]);
                series.setArguments(new ChartStringData(subjects));
                series.setValues(new ChartNumericData(scores.get(i)));

                // Display mean markers, mean lines, and outliers, and specify the quartile calculation method.
                series.setShowMeanMarkers(true);
                series.setShowMeanLine(true);
                series.setShowOutlierPoints(true);
                series.setQuartileCalculationMode(QuartileCalculationMode.EXCLUSIVE);
                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);
            }
        }
    }
}

The following screenshot illustrates the result:

 Box and whisker chart with two series, mean markers, and mean 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.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
See Also

BoxAndWhiskerSeries()

Initializes a new instance of the BoxAndWhiskerSeries class.

Declaration

public BoxAndWhiskerSeries()

Methods

deepClone() Method

Creates a copy of the box and whisker series.

Declaration

public BoxAndWhiskerSeries deepClone()

Returns

Type Description
BoxAndWhiskerSeries

A copy of the box and whisker series.

getChartType() Method

Returns the chart type of the series.

Declaration

public ChartExType getChartType()

Returns

Type Description
ChartExType

ChartExType.BOX_AND_WHISKER.

getDataLabels() Method

Returns data label settings for the series.

Declaration

public IBoxAndWhiskerDataLabels getDataLabels()

Returns

Type Description
IBoxAndWhiskerDataLabels

Data label settings.

Remarks

Refer to the following help topic for additional information: Customize Chart Data Labels — Presentation API for Java.

getQuartileCalculationMode() Method

Returns the method that the series uses to calculate quartiles.

Declaration

public QuartileCalculationMode getQuartileCalculationMode()

Returns

Type Description
QuartileCalculationMode

The quartile calculation method.

getShowInnerPoints() Method

Returns whether the series displays data points between the whiskers.

Declaration

public boolean getShowInnerPoints()

Returns

Type Description
boolean

true if the series displays inner points; otherwise, false.

getShowMeanLine() Method

Returns whether the series displays a mean line that connects mean values of categories.

Declaration

public boolean getShowMeanLine()

Returns

Type Description
boolean

true if the series displays the mean line; otherwise, false.

getShowMeanMarkers() Method

Returns whether the series displays markers at mean values of categories.

Declaration

public boolean getShowMeanMarkers()

Returns

Type Description
boolean

true if the series displays mean markers; otherwise, false.

getShowOutlierPoints() Method

Returns whether the series displays outliers (data points outside the whiskers).

Declaration

public boolean getShowOutlierPoints()

Returns

Type Description
boolean

true if the series displays outliers; otherwise, false.

setQuartileCalculationMode(QuartileCalculationMode value) Method

Sets the method that the series uses to calculate quartiles.

Declaration

public void setQuartileCalculationMode(QuartileCalculationMode value)

Parameters

Name Type Description
value QuartileCalculationMode

The quartile calculation method.

Remarks

The setQuartileCalculationMode(value) method accepts the following values:

Value Description
INCLUSIVE Indicates that the quartile calculation includes the median in both halves of the data set.
EXCLUSIVE Indicates that the quartile calculation excludes the median from both halves of the data set.

If you do not call the setQuartileCalculationMode(value) method, the API uses QuartileCalculationMode.INCLUSIVE.

setShowInnerPoints(boolean value) Method

Sets whether to display data points between the whiskers.

Declaration

public void setShowInnerPoints(boolean value)

Parameters

Name Type Description
value boolean

true to display inner points; otherwise, false.

Remarks

If you do not call the setShowInnerPoints(value) method, the API uses false.

setShowMeanLine(boolean value) Method

Sets whether to display a mean line that connects mean values of categories.

Declaration

public void setShowMeanLine(boolean value)

Parameters

Name Type Description
value boolean

true to display the mean line; otherwise, false.

Remarks

If you do not call the setShowMeanLine(value) method, the API uses false.

setShowMeanMarkers(boolean value) Method

Sets whether to display markers at mean values of categories.

Declaration

public void setShowMeanMarkers(boolean value)

Parameters

Name Type Description
value boolean

true to display mean markers; otherwise, false.

Remarks

If you do not call the setShowMeanMarkers(value) method, the API uses false.

setShowOutlierPoints(boolean value) Method

Sets whether to display outliers (data points outside the whiskers).

Declaration

public void setShowOutlierPoints(boolean value)

Parameters

Name Type Description
value boolean

true to display outliers; otherwise, false.

Remarks

If you do not call the setShowOutlierPoints(value) method, the API uses false.