Charts - Funnel 🧪
Funnel charts allow to express quantity evolution along a process, such as audience engagement, population education levels or yields of multiple processes.
Basics
Funnel charts series should contain a data property containing an array of objects.
Each object corresponds to a section of the funnel.
It must contain a property value and can have other optional properties, like label and id.
Display legends
The funnel chart displays a legend by default.
The only requirement is to provide a label value in the data objects.
To disable the legend, set the hideLegend property to true.
- A
- B
- C
- D
Labels
The funnel chart displays labels by default.
It shows the value of the data item in each section.
To format the labels, a valueFormatter function can be provided.
Positioning labels
The labels can be positioned relative to the section they represent.
The sectionLabel property accepts an object with the following properties:
position.vertical: The vertical position of the label. It can betop,centerorbottom.position.horizontal: The horizontal position of the label. It can bestart,middleorend.margin: The margin between the label and the section.dominantBaseline: The vertical alignment of the text. It can beauto,baseline,text-before-edge,text-after-edge,central,hanging, ormiddle.textAnchor: The horizontal alignment of the text. It can bestart,middleorend.
The sectionLabel property can be set to false to hide the labels.
It also accepts a function that receives the data object and should return the label configuration.
- A
- B
- C
- D
import { FunnelChart } from '@mui/x-charts-pro/FunnelChart';
<FunnelChart
// Space to display the labels
series={[
{
sectionLabel: {
position: {
horizontal: 'start',
vertical: 'bottom'
},
textAnchor: 'start',
dominantBaseline: 'middle',
offset: {
x: -10,
y: 10
}
}
}
]}
/>Playground
Curve interpolation
The interpolation between data points can be customized by the curve property.
This property expects one of the following string values, corresponding to the interpolation method: 'linear', 'bump' and 'step'.
This series property adds the option to control the interpolation of a series.
import { FunnelChart } from '@mui/x-charts-pro/FunnelChart';
<FunnelChart
series={[{ curve: 'bump' }]}
/>Playground
Colors
The funnel colors can be customized in two ways.
- You can provide a color palette. Each section of the funnel will be colored according to this palette.
- You can provide a
colorproperty indataobjects, which overrides the palette.
Multiple funnels
By default, multiple series are displayed on top of each other.
Simply provide multiple series to the funnel chart and make sure that they have different colors or styles to differentiate them.
The order of the series determines the display order. The first series is at the bottom and the last is at the top.
- A1
- B1
- C1
- D1
- A2
- B2
- C2
- D2
Highlight
The hovered element can be highlighted by setting highlightScope.highlight property to one of the possible values.
To fade elements which are not hovered, set the highlightScope.fade property.
Category axis
The funnel chart uses a category axis as the default axis. This axis always follows the orientation of the chart.
The funnel chart does not display an axis by default.
To display a category axis, pass a position and a list of categories to the categoryAxis props.
Scaled sections
By default, the sections have the same size because they use the band scale type.
A linear scale, is also available, and will scale the the sections based on their value.
To do so, set the scaleType property to linear in the categoryAxis.
API
See the documentation below for a complete reference to all of the props and classes available to the components mentioned here.