HistogramBinType Enum
Lists bin types of histogram charts.
Declaration
public enum HistogramBinType extends Enum<HistogramBinType> implements IIntEnum
Members
| Name | Description |
|---|---|
AUTOMATIC
|
Indicates that the chart calculates the bin width from series data. |
BIN_COUNT
|
Indicates a specified number of bins. |
BIN_SIZE
|
Indicates bins of a specified width. |
BY_CATEGORY
|
Indicates a bin for each category. The bin value is the sum of values in the category. |
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
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 Histogram Chart with an Overflow Bin
The following code snippet creates a histogram chart that groups values into bins of a specified width, combines values above a boundary into an overflow bin, and displays 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.
ChartEx chart = new ChartEx();
chart.setWidth(presentation.getSlideSize().getWidth());
chart.setHeight(presentation.getSlideSize().getHeight());
slide.getShapes().add(chart);
// Create a histogram series and specify data.
HistogramSeries series = new HistogramSeries();
series.setText("Delivery Time");
series.setValues(new ChartNumericData(List.of(
2.0, 3.0, 4.0, 4.0, 5.0, 6.0, 6.0, 7.0, 8.0, 9.0,
11.0, 12.0, 14.0, 15.0, 18.0, 22.0, 27.0, 35.0)));
// Group values into bins of 5 days and combine values above 20 days.
series.setBinType(HistogramBinType.BIN_SIZE);
series.setBinSize(5);
series.setOverflowType(HistogramOverflowType.FIXED);
series.setOverflow(20);
// Display the number of values in each bin.
series.getDataLabels().setShowValue(true);
series.getDataLabels().setLabelPosition(HistogramDataLabelPosition.OUTSIDE_END);
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:
