Funnel
The
Funnel
component allows visualizing of data in a funnel structure, for example, a conversion funnel on a website. The funnel can be configured to display horizontally (see below) or vertically.
Funnel example
The
Funnel
component can be used to display a single group of data, or multiple data series that flow through the same funnel steps. Both the data, as well as colors are configured via the "Data" configuration property.It expects a specific JSON structure, which is defined as follows:
interface FunnelData {
colors: Array<string | string[]>;
labels: string[];
subLabels?: string[] | null;
values: number[] | number[][];
}
This data structure covers multiple scenarios on how the
Funnel
can be used.Let us firstly explore the different properties of the JSON structure, using the conversion funnel example above. The JSON data for such a funnel looks as follows:
{
"labels": ["Impressions", "Add To Cart", "Buy"],
"subLabels": ["Direct", "Social Media", "Ads"],
"colors": ["#6389E9", "#8DA7EE", "#B5C6F1"],
"values": [
[12000, 15000, 24000],
[5700, 6400, 7800],
[620, 750, 960]
]
}
In the example above, there are multiple "data series", that are differentiated by color. Furthermore, the user can explore the values of each series by hovering over the particular funnel step.

Exploring series values by hover
There are three funnel steps ("Impressions", "Add to Cart", "Buy") and there are three distinct data series for this funnel ("Direct", "Social Media", "Ads"). Each data series has a dedicated set of values and a color.
- labels: This array defines the title of each funnel step. It is displayed at the top (horizontal direction) or on the left (vertical direction), where the data values and percentages are also visualized.
- subLabels: This array contains the titles of the data series, which are displayed on hover. This property is optional, i.e. nothing is rendered on hover in case it is omitted.
- colors: This array contains a color for each data series. The number of colors must always exactly match the number of data series, i.e. the length of the
subLabels
array (if provided), and the length of each array invalues
. The values in this array can be any valid CSS color, like for example'red'
,'#6389E9'
or'rgba(0, 0, 127, 0.8)'
. - values: Holds all values to be displayed in the funnel. In case there are multiple data series, this will be an array of arrays, while displaying a single set of values can be achieved with a flat array of numbers.
When not using multiple data series, the structure can look much simpler:
{
"labels": ["Impressions", "Add To Cart", "Buy"],
"colors": ["#6389E9"],
"values": [12000, 5700, 620],
}
This renders a simple funnel with only a single set of values:

Basic funnel with a single set of values
You may have noticed that the
colors
property of the funnel data structure can be an "array of arrays of strings". The purpose of this is to provide the ability for color gradients within a data series. Change the example from the previous section as follows:{
"labels": ["Impressions", "Add To Cart", "Buy"],
"subLabels": ["Direct", "Social Media", "Ads"],
"colors": [
["#FFB178", "#FF78B1", "#FF3C8E"],
["#A0BBFF", "#EC77FF"],
"#A0F9FF"
],
"values": [
[12000, 15000, 24000],
[5700, 6400, 7800],
[620, 750, 960]
]
}
This renders the following funnel with color gradients:

Funnel with gradients
When working with gradients in the
colors
property, consider the following:- A gradient can consist of more than two colors. You can provide as many colors as you like, and the gradient will linearly transition through the provided colors in the provided order.
- You can freely mix gradients and fixed colors. In the example above, the first two data series are visualized with a gradient, while the third series uses the fixed color
"#A0F9FF"
In case of a single data series, there is no need to provide an array of arrays to the
colors
property, but it must be a flat array of strings. This means, that you don't provide something like [["#A0BBFF", "#EC77FF"]]
, but instead: ["#A0BBFF", "#EC77FF"]
The
Funnel
component offers the following configuration properties.Property | Type | Default value | Behavior |
---|---|---|---|
Data | object | Conversion funnel example, as shown above | |
Direction | 'horizontal' | 'vertical' | 'horizontal' | Determines whether to render the funnel horizontally or vertically. |
Display percent | boolean | true | Whether the percentages of each step should be displayed in the header or not. These percentages are always calculated against the value of the first step, i.e. against the "funnel entry". There is currently no way to change this logic. |
The
Funnel
component does not offer any UI events. The
Funnel
exposes the following API in the JavaScript runtime environment.Property / Function | Type | Behavior |
---|---|---|
data | object | |
displayPercent | boolean | Provides the current value of the "Display percent" property |
direction | 'horizontal' | 'vertical' | Provides the current value of the "Direction" property |
setData(data) | (data: FunnelData) => void | |
setDisplayPercent(value) | (value: boolean) => void | Sets the value of the "Display percent" property to the provided boolean value. |
setDirection(value) | (value: 'horizontal' | 'vertical') => void | Sets the value of the "Direction" property to the provided value. Throws an error in case the value is not either 'horizontal' or 'vertical' . |
Last modified 4mo ago