ErrorValueType Enum
Lists calculation modes for error bars.
Declaration
public enum ErrorValueType extends Enum<ErrorValueType> implements IIntEnum
Members
| Name | Description |
|---|---|
CUSTOM
|
Uses custom error amounts specified by the |
FIXED_VALUE
|
Uses a fixed error amount for all data points. |
PERCENTAGE
|
Uses a percentage of each data point value. |
STANDARD_DEVIATION
|
Uses a multiple of the standard deviation. |
STANDARD_ERROR
|
Uses the standard error. |
fromValue(int value)
|
Returns the |
getName()
|
Returns the name of the |
getValue()
|
Returns the integer value of the |
toString()
|
Returns the string representation of the |
valueOf(String name)
|
Returns the |
values()
|
Returns an array of all |
Remarks
Call the ErrorBar.getType() method to get the calculation mode for error amounts. Call the ErrorBar.setType(value) method to specify the calculation mode.
Refer to the following help topic for additional information: Add Error Bars and Trend Lines to Charts — Presentation API for Java.
Example
Add Percentage and Custom Error Bars to a Column Chart
The following code snippet creates a column chart with two series, adds percentage error bars with end caps to the first series, and adds custom positive error bars to the second series:
import java.io.*;
import java.nio.file.*;
import java.util.List;
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);
// Add two column series.
String[] names = { "2024", "2025" };
double[][] values = { { 42, 55, 48, 61 }, { 47, 52, 58, 66 } };
for (int i = 0; i < names.length; i++) {
BarSeries series = new BarSeries();
series.setText(names[i]);
series.setArguments(new ChartStringData(List.of("Q1", "Q2", "Q3", "Q4")));
series.setValues(new ChartNumericData(List.of(values[i][0], values[i][1], values[i][2], values[i][3])));
chart.getSeries().add(series);
}
// Display 10% error bars with end caps for the first series.
ErrorBar percentageErrorBar = new ErrorBar();
percentageErrorBar.setType(ErrorValueType.PERCENTAGE);
percentageErrorBar.setValue(10);
percentageErrorBar.setShowCap(true);
OutlineStyle errorBarLine = new OutlineStyle();
errorBarLine.setFill(new SolidFill(Color.getDarkRed()));
percentageErrorBar.setOutlineStyle(errorBarLine);
((BarSeries) chart.getSeries().get(0)).getErrorBars().add(percentageErrorBar);
// Display custom positive error values for the second series.
ErrorBar customErrorBar = new ErrorBar();
customErrorBar.setType(ErrorValueType.CUSTOM);
customErrorBar.setDirection(ErrorBarDirection.PLUS);
customErrorBar.setPlus(new ChartNumericData(List.of(3.0, 5.0, 4.0, 6.0)));
customErrorBar.setShowCap(true);
((BarSeries) chart.getSeries().get(1)).getErrorBars().add(customErrorBar);
// 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:
