Skip to main content

BandFormat Class

Contains formatting settings for a band in a surface chart.

Declaration

public class BandFormat extends ChartElement

Remarks

A surface chart displays value ranges as bands. To format a band, add a BandFormat object to the dictionary returned by the SurfaceChartViewBase.getBandFormats() method. The dictionary key is the band index.

Call the BandFormat.setFill(value), BandFormat.setOutlineStyle(value), and BandFormat.setEffects(value) methods to specify band formatting settings.

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

Example: Specify Band Fills in a Surface Chart

The following code snippet creates a surface chart and specifies fills for the first three value bands:

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()) {
            presentation.getSlides().clear();
            Slide slide = new Slide(SlideLayoutType.BLANK);
            presentation.getSlides().add(slide);

            Chart chart = new Chart();
            chart.setWidth(presentation.getSlideSize().getWidth());
            chart.setHeight(presentation.getSlideSize().getHeight());
            slide.getShapes().add(chart);

            // Populate chart data: arguments in column A, values of two series in columns B and C.
            ChartData data = chart.getData();
            String[] months = { "Jan", "Feb", "Mar", "Apr" };
            double[][] values = { { 10, 30 }, { 25, 45 }, { 40, 20 }, { 15, 35 } };
            for (int i = 0; i < months.length; i++) {
                data.get(0, "A" + (i + 1)).setTextValue(months[i]);
                data.get(0, "B" + (i + 1)).setNumericValue(values[i][0]);
                data.get(0, "C" + (i + 1)).setNumericValue(values[i][1]);
            }

            // Add two surface series.
            for (String column : new String[] { "B", "C" }) {
                SurfaceSeries series = new SurfaceSeries();
                series.setArguments(new ChartDataReference(0, "A1", "A4"));
                series.setValues(new ChartDataReference(0, column + "1", column + "4"));
                chart.getSeries().add(series);
            }

            // Specify fills for the first three value bands.
            SurfaceChartView view = (SurfaceChartView) chart.getViews().get(0);
            Color[] bandColors = { Color.getLightSkyBlue(), Color.getSteelBlue(), Color.getNavy() };
            for (int i = 0; i < bandColors.length; i++) {
                BandFormat bandFormat = new BandFormat();
                bandFormat.setFill(new SolidFill(bandColors[i]));
                view.getBandFormats().put(i, bandFormat);
            }

            Files.createDirectories(Path.of("output"));
            try (OutputStream output = Files.newOutputStream(Path.of("output", "Chart.pptx"))) {
                presentation.save(output);
            }
        }
    }
}

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
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

See Also

BandFormat()

Initializes a new instance of the BandFormat class.

Declaration

public BandFormat()

Methods

deepClone() Method

Creates a copy of the band format.

Declaration

public BandFormat deepClone()

Returns

Type Description
BandFormat

A copy of the band format.