Funnel
Last updated
Last updated
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.
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:
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:
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.
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 in values
. 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:
This renders a simple funnel with only 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:
This renders the following funnel with color 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.
The Funnel
component does not offer any UI events.
The Funnel
exposes the following API in the JavaScript runtime environment.
Property | Type | Default value | Behavior |
---|---|---|---|
Property / Function | Type | Behavior |
---|---|---|
Data
object
Conversion funnel example, as shown above
Determines the values, labels and colors of the funnel displayed. Learn more
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.
data
object
Provides the currently displayed funnel data. Learn more
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
Updates the funnel data. The provided object must match the FunnelData
interface. Learn more
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'
.