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 must 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 prop to true.
- A
- B
- C
- D
Pyramid Chart
The pyramid chart is a variation of the funnel chart.
To create a pyramid chart, set the curve property to pyramid in the series.
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.
Styling labels
The labels can be styled by using the funnelSectionClasses.label helper.
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
Styling
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', 'linear-sharp', 'bump', 'pyramid', 'step' and 'step-pyramid'.
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',
variant: 'filled',
// borderRadius: 0,
}]}
gap={0}
/>Playground
Gap
The gap between the sections can be customized by the gap property.
It accepts a number that represents the gap in pixels.
Border radius
The border radius of the sections can be customized by the borderRadius property.
It accepts a number that represents the radius in pixels.
- The
bumpcurve interpolation will not respect the border radius. - The
linear,linear-sharpandpyramidcurves respect the border radius to some extent due to the angle of the sections. - The
stepandstep-pyramidcurves respect the border radius.
To understand how the border radius interacts with the curve prop, see the curve interpolation example above.
The borderRadius property will also behave differently depending on whether the gap property is greater than 0.
- If the
gapis 0, the border radius will be applied to the corners of the sections that are not connected to another section. - If the
gapis greater than 0, the border radius will be applied to all the corners of the sections.
Variant
The funnel sections can be displayed in two different styles using the variant property:
'filled'(default): Sections have a solid fill and no stroke.'outlined': Sections have a translucent fill with a colored stroke around them.
The outlined variant creates a more lightweight visual style.
- Leads
- Calls
- Meetings
- Deals
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.