Skip to main content

BubbleSeries Class

A bubble series in a standard chart.

Declaration

public class BubbleSeries extends SeriesBase

Remarks

Add a BubbleSeries object to the Chart.getSeries() collection to create a bubble chart. The chart creates a BubbleChartView object for the series.

A bubble series uses three data sets: arguments (X values), values (Y values), and bubble sizes. Call BubbleSeries.setArguments(value), BubbleSeries.setValues(value), and setBubbleSize(IChartValueData value) methods to specify the data.

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

Example

Create a Bubble Chart

The following code snippet creates a bubble chart, reduces the bubble size, and displays bubble sizes in data labels:

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);

            // Create a bubble series: X values, Y values, and bubble sizes.
            BubbleSeries series = new BubbleSeries();
            series.setText("Products");
            series.setArguments(new ChartNumericData(List.of(10.0, 25.0, 40.0, 55.0)));
            series.setValues(new ChartNumericData(List.of(30.0, 55.0, 20.0, 70.0)));
            series.setBubbleSize(new ChartNumericData(List.of(120.0, 60.0, 200.0, 90.0)));
            chart.getSeries().add(series);

            // Reduce bubble size and display bubble sizes in data labels.
            BubbleChartView view = (BubbleChartView) chart.getViews().get(0);
            view.setBubbleScale(60);
            view.getDataLabels().setShowBubbleSize(true);
            view.getDataLabels().setLabelPosition(BubbleDataLabelPosition.CENTER);

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

 Bubble chart with bubble sizes in data labels 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

BubbleSeries()

Initializes a new instance of the BubbleSeries class.

Declaration

public BubbleSeries()

Methods

getBubbleSize() Method

Returns bubble size data.

Declaration

public IChartValueData getBubbleSize()

Returns

Type Description
IChartValueData

Bubble size data, or null if the series has no bubble size data.

getCustomDataPoints() Method

Returns appearance settings for individual series data points.

Declaration

public IDataPointDictionary getCustomDataPoints()

Returns

Type Description
IDataPointDictionary

A dictionary that maps zero-based data point indexes to data point settings.

Remarks

To customize an individual data point, add a DataPoint object to the dictionary that the getCustomDataPoints() method returns. The dictionary key is the zero-based index of the data point.

getDataLabels() Method

Returns data label settings for the series.

Declaration

public IBubbleDataLabels getDataLabels()

Returns

Type Description
IBubbleDataLabels

Data label settings.

Remarks

Call the BubbleChartView.getDataLabels() method to access data label settings for all series in a bubble chart view.

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

getDataLabelsRange() Method

Returns a reference to cells that contain text for series data labels.

Declaration

public IChartDataReference getDataLabelsRange()

Returns

Type Description
IChartDataReference

A reference to the cell range, or null if the series has no data label range.

getDisplayBubblesAs3D() Method

Returns whether the series displays bubbles with a 3D effect.

Declaration

public boolean getDisplayBubblesAs3D()

Returns

Type Description
boolean

true if the series displays bubbles with a 3D effect; otherwise, false.

getErrorBars() Method

Returns the collection of error bars for the series.

Declaration

public IErrorBarCollection getErrorBars()

Returns

Type Description
IErrorBarCollection

The collection of error bars.

Remarks

Add an ErrorBar object to the collection to display error bars for series values.

Refer to the following help topic for additional information: Add Error Bars and Trend Lines to Charts — Presentation API for Java.

getInvertNegative() Method

Returns whether negative bubbles use inverted fill colors.

Declaration

public boolean getInvertNegative()

Returns

Type Description
boolean

true if negative bubbles use inverted fill colors; otherwise, false.

getTrendLine() Method

Returns the trend line of the series.

Declaration

public TrendLine getTrendLine()

Returns

Type Description
TrendLine

The trend line, or null if the series has no trend line.

setBubbleSize(IChartValueData value) Method

Sets bubble size data.

Declaration

public void setBubbleSize(IChartValueData value)

Parameters

Name Type Description
value IChartValueData

Bubble size data.

Remarks

Call the BubbleChartView.setSizeRepresentation(value) method to specify whether bubble size values determine bubble area or width. Call the BubbleChartView.setBubbleScale(value) method to scale bubbles.

setDataLabelsRange(IChartDataReference value) Method

Sets a reference to cells that contain text for series data labels.

Declaration

public void setDataLabelsRange(IChartDataReference value)

Parameters

Name Type Description
value IChartDataReference

A reference to the cell range, or null to remove the reference.

Remarks

When you assign a cell range to a series in a chart, the API calls the setShowDataLabelRange(true) method of the object that the series getDataLabels() method returns. Each data label displays the value of the cell with the same index in the range. Call the setDataLabelsRange(null) method to remove cell values from data labels.

setDisplayBubblesAs3D(boolean value) Method

Sets whether to display bubbles of the series with a 3D effect.

Declaration

public void setDisplayBubblesAs3D(boolean value)

Parameters

Name Type Description
value boolean

true to display bubbles with a 3D effect; otherwise, false.

Remarks

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

Call the BubbleChartView.setDisplayBubblesAs3D(value) method to specify this setting for the chart view.

setInvertNegative(boolean value) Method

Sets whether negative bubbles use inverted fill colors.

Declaration

public void setInvertNegative(boolean value)

Parameters

Name Type Description
value boolean

true to invert fill colors of negative bubbles; otherwise, false.

Remarks

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

Call the BubbleChartView.setShowNegativeBubbles(true) method to display bubbles with negative size values.

setTrendLine(TrendLine value) Method

Sets the trend line of the series.

Declaration

public void setTrendLine(TrendLine value)

Parameters

Name Type Description
value TrendLine

The trend line, or null to remove the trend line.

Remarks

Refer to the following help topic for additional information: Add Error Bars and Trend Lines to Charts — Presentation API for Java.