BarSeries Class
A bar or column series in a standard chart.
Declaration
public class BarSeries extends BarSeriesBase
Remarks
Add a BarSeries object to the Chart.getSeries() collection to create a bar or column chart. The chart creates a BarChartView object for the series. To display horizontal bars, call the BarChartView.setBarDirection(BarChartDirection.BAR) method.
Refer to the following help topic for additional information: Create Standard Charts — Presentation API for Java.
Example
Create a Bar Chart with a Title
The following code snippet adds a bar chart to a slide, binds the series to chart data, and adds a chart title:
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();
data.get(0, "A1").setNumericValue(120);
data.get(0, "A2").setNumericValue(95);
data.get(0, "A3").setNumericValue(140);
data.get(0, "B1").setTextValue("Q1");
data.get(0, "B2").setTextValue("Q2");
data.get(0, "B3").setTextValue("Q3");
// Bind series values and arguments to chart data ranges.
BarSeries series = new BarSeries();
series.setValues(new ChartDataReference(0, "A1", "A3"));
series.setArguments(new ChartDataReference(0, "B1", "B3"));
chart.getSeries().add(series);
// Add a chart title.
TextProperties titleTextProperties = new TextProperties();
titleTextProperties.setFontSize(30f);
titleTextProperties.setFill(new SolidFill(Color.getDarkBlue()));
chart.setTitle(new ChartTitle(
new TextArea("Quarterly Sales", new TextParagraphProperties(titleTextProperties))));
// 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:

Inherited Members
Inheritance
BarSeries()
Initializes a new instance of the BarSeries class.
Declaration
public BarSeries()
Methods
getAxisGroup() Method
Returns the axis group that displays the series.
Declaration
public ChartAxisGroupType getAxisGroup()
Returns
| Type | Description |
|---|---|
| ChartAxisGroupType | The axis group. |
getDataLabels() Method
Returns data label settings for the series.
Declaration
public IBarDataLabels getDataLabels()
Returns
| Type | Description |
|---|---|
| IBarDataLabels | Data label settings. |
Remarks
Call the BarChartView.getDataLabels() method to access data label settings for all series in a bar 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 |
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.
getTrendLine() Method
Returns the trend line of the series.
Declaration
public TrendLine getTrendLine()
Returns
| Type | Description |
|---|---|
| TrendLine | The trend line, or |
setAxisGroup(ChartAxisGroupType value) Method
Sets the axis group that displays the series.
Declaration
public void setAxisGroup(ChartAxisGroupType value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ChartAxisGroupType | The axis group. |
Remarks
The setAxisGroup(value) method accepts the following values:
| Value | Description |
|---|---|
| PRIMARY | Indicates primary axes. |
| SECONDARY | Indicates secondary axes. |
If you do not call the setAxisGroup(value) method, the series uses primary axes. If you call the setAxisGroup(ChartAxisGroupType.SECONDARY) method, the chart moves the series to a separate chart view and creates secondary axes for this view.
Refer to the following help topics for additional information:
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 |
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.
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 |
Remarks
Refer to the following help topic for additional information: Add Error Bars and Trend Lines to Charts — Presentation API for Java.