Skip to main content

FunnelDataLabel Class

Contains settings for a data label in a funnel chart.

Declaration

public class FunnelDataLabel extends DataLabelEx

Remarks

The FunnelDataLabel class inherits label content and formatting settings from the DataLabelExBase class (for example, FunnelDataLabel.setShowValue(value) and FunnelDataLabel.setTextProperties(value) methods).

Pass a FunnelDataLabel object to the IFunnelDataLabels.setLabel(key, value) method to format the data label of an individual data point.

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

Example

Create a Funnel Chart with Data Labels

The following code snippet creates a funnel chart, displays values in data labels, and applies bold text formatting to the last data label:

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 funnel series and specify sales pipeline stages.
            FunnelSeries series = new FunnelSeries();
            series.setText("Sales Pipeline");
            series.setArguments(new ChartStringData(List.of("Leads", "Qualified", "Proposals", "Negotiations", "Deals")));
            series.setValues(new ChartNumericData(List.of(1200.0, 640.0, 310.0, 150.0, 85.0)));
            chart.getSeries().add(series);

            // Display values in data labels.
            TextProperties labelText = new TextProperties();
            labelText.setFontSize(20f);
            series.getDataLabels().setShowValue(true);
            series.getDataLabels().setTextProperties(labelText);

            // Apply bold text formatting to the data label of the last stage.
            TextProperties boldText = new TextProperties();
            boldText.setFontSize(20f);
            boldText.setBold(true);
            FunnelDataLabel lastLabel = new FunnelDataLabel();
            lastLabel.setShowValue(true);
            lastLabel.setTextProperties(boldText);
            series.getDataLabels().setLabel(4, lastLabel);

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

 Funnel chart with a bold data label for the last stage 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
See Also

FunnelDataLabel()

Initializes a new instance of the FunnelDataLabel class.

Declaration

public FunnelDataLabel()

Methods

deepClone() Method

Returns a deep copy of this FunnelDataLabel instance.

Declaration

public FunnelDataLabel deepClone()

Returns

Type Description
FunnelDataLabel

A deep copy of this FunnelDataLabel.