A Funnel Series illustrates how a value changes during a process, with bar widths representing the value at each stage and drop-offs denoting the change between them.
Simple Funnel Copy Link
import {
AgChartOptions,
AgCharts,
AnimationModule,
CategoryAxisModule,
ContextMenuModule,
CrosshairModule,
FunnelSeriesModule,
LegendModule,
ModuleRegistry,
NumberAxisModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
ModuleRegistry.registerModules([
AnimationModule,
CategoryAxisModule,
CrosshairModule,
FunnelSeriesModule,
LegendModule,
NumberAxisModule,
ContextMenuModule,
]);
const options: AgChartOptions = {
data: getData(),
title: {
text: "Conversion Drop Off",
},
series: [
{
type: "funnel",
stageKey: "group",
valueKey: "value",
},
],
};
options.container = document.getElementById("myChart");
const chart = AgCharts.create(options);
export function getData() {
return [
{ group: "Page Visit", value: 490 },
{ group: "Enquiry", value: 340 },
{ group: "Quote", value: 300 },
{ group: "Sale", value: 290 },
];
}
To create a Funnel Series, use the funnel series type.
{
series: [
{
type: 'funnel',
stageKey: 'group',
valueKey: 'value',
},
],
}In this configuration:
stageKeydefines the stages which are used for the bars of the funnel.valueKeyprovides the numerical values which determine the width of each bar.
Horizontal Funnel Copy Link
import {
AgChartOptions,
AgCharts,
AnimationModule,
CategoryAxisModule,
ContextMenuModule,
CrosshairModule,
FunnelSeriesModule,
LegendModule,
ModuleRegistry,
NumberAxisModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
ModuleRegistry.registerModules([
AnimationModule,
CategoryAxisModule,
CrosshairModule,
FunnelSeriesModule,
LegendModule,
NumberAxisModule,
ContextMenuModule,
]);
const options: AgChartOptions = {
data: getData(),
title: {
text: "Conversion Drop Off",
},
series: [
{
type: "funnel",
stageKey: "group",
valueKey: "value",
direction: "horizontal",
},
],
};
options.container = document.getElementById("myChart");
const chart = AgCharts.create(options);
export function getData() {
return [
{ group: "Page Visit", value: 490 },
{ group: "Enquiry", value: 340 },
{ group: "Quote", value: 300 },
{ group: "Sale", value: 290 },
];
}
To create a horizontal Funnel Series, set the direction to horizontal.
{
direction: 'horizontal',
} Segmented Funnel Copy Link
A segmented funnel does not draw the drop offs between the stages.
import {
AgChartOptions,
AgCharts,
AnimationModule,
CategoryAxisModule,
ContextMenuModule,
CrosshairModule,
FunnelSeriesModule,
LegendModule,
ModuleRegistry,
NumberAxisModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
ModuleRegistry.registerModules([
AnimationModule,
CategoryAxisModule,
CrosshairModule,
FunnelSeriesModule,
LegendModule,
NumberAxisModule,
ContextMenuModule,
]);
const options: AgChartOptions = {
data: getData(),
title: {
text: "Revenue Open by Sales Stage",
},
series: [
{
type: "funnel",
stageKey: "group",
valueKey: "value",
dropOff: {
enabled: false,
},
},
],
};
options.container = document.getElementById("myChart");
const chart = AgCharts.create(options);
export function getData() {
return [
{ group: "Qualify", value: 7910 },
{ group: "Develop", value: 8170 },
{ group: "Propose", value: 7260 },
{ group: "Close", value: 4460 },
];
}
To disable the drop offs, set enabled to false in the dropOff configuration.
{
dropOff: {
enabled: false,
},
} Customisation Copy Link
import {
AgChartOptions,
AgCharts,
AnimationModule,
CategoryAxisModule,
ContextMenuModule,
CrosshairModule,
FunnelSeriesModule,
LegendModule,
ModuleRegistry,
NumberAxisModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
ModuleRegistry.registerModules([
AnimationModule,
CategoryAxisModule,
CrosshairModule,
FunnelSeriesModule,
LegendModule,
NumberAxisModule,
ContextMenuModule,
]);
const options: AgChartOptions = {
data: getData(),
title: {
text: "Revenue Open by Sales Stage",
},
seriesArea: {
padding: {
left: 20,
right: 20,
},
},
series: [
{
type: "funnel",
stageKey: "group",
valueKey: "value",
fills: ["#5090DC", "#FFA03A", "#459D55", "#34BFE1"],
},
],
};
options.container = document.getElementById("myChart");
const chart = AgCharts.create(options);
export function getData() {
return [
{ group: "Close", value: 4460 },
{ group: "Propose", value: 7260 },
{ group: "Develop", value: 7910 },
{ group: "Qualify", value: 9170 },
];
}
{
fills: ['#5090DC', '#FFA03A', '#459D55', '#34BFE1'],
}In this configuration:
- The fills for each stage are defined in the
fillsarray. - The drop offs use an opacity of the same fills. This can be changed in the drop off options.
- The Funnel Series is reversed by providing the data items in the reverse order.
Labels Copy Link
The values can be displayed inside or outside each stage using the label option, and the stage name can be shown with the stageLabel option.
import {
AgCartesianChartOptions,
AgCharts,
AgFunnelSeriesLabelPlacement,
AgFunnelSeriesOptions,
AnimationModule,
CategoryAxisModule,
ContextMenuModule,
CrosshairModule,
FunnelSeriesModule,
LegendModule,
ModuleRegistry,
NumberAxisModule,
} from "ag-charts-enterprise";
import { DataType, getData } from "./data";
const initialPlacement: AgFunnelSeriesLabelPlacement = "inside-center";
ModuleRegistry.registerModules([
AnimationModule,
CategoryAxisModule,
ContextMenuModule,
CrosshairModule,
FunnelSeriesModule,
LegendModule,
NumberAxisModule,
]);
const options: AgCartesianChartOptions<DataType> = {
data: getData(),
title: {
text: "Conversion Drop Off",
},
subtitle: {
text: initialPlacement,
},
animation: {
enabled: false,
},
seriesArea: {
padding: {
top: 20,
bottom: 20,
left: 60,
right: 60,
},
},
series: [
{
type: "funnel",
stageKey: "group",
valueKey: "value",
direction: "vertical",
label: {
enabled: true,
placement: initialPlacement,
},
stageLabel: {
placement: "before",
},
},
],
};
options.container = document.getElementById("myChart");
const chart = AgCharts.create(options);
function setPlacement(value: string) {
(options.series![0] as AgFunnelSeriesOptions<DataType>).label!.placement =
value as AgFunnelSeriesLabelPlacement;
options.subtitle!.text = value;
chart.update(options);
}
function setDirection(event: Event) {
const direction = (event.target as HTMLInputElement).value as
| "vertical"
| "horizontal";
options.series = [
{ ...(options.series![0] as AgFunnelSeriesOptions<DataType>), direction },
];
chart.update(options);
}
function setStageLabelPlacement(event: Event) {
const placement = (event.target as HTMLInputElement).value as
| "before"
| "after";
options.series = [
{
...(options.series![0] as AgFunnelSeriesOptions<DataType>),
stageLabel: { placement },
},
];
chart.update(options);
}
if (typeof window !== "undefined") {
// Attach external event handlers to window so they can be called from index.html
(<any>window).setPlacement = setPlacement;
(<any>window).setDirection = setDirection;
(<any>window).setStageLabelPlacement = setStageLabelPlacement;
}
export interface DataType {
group: string;
value: number;
}
export function getData(): DataType[] {
return [
{ group: "Page Visit", value: 490 },
{ group: "Enquiry", value: 340 },
{ group: "Quote", value: 300 },
{ group: "Sale", value: 290 },
];
}
{
label: {
enabled: true,
placement: 'inside-center',
},
stageLabel: {
placement: 'before',
},
}In this configuration:
- The label is positioned as
inside-center. Use the dropdown to see all available placements.startandendare above and below the bar when vertical, left and right of it when horizontal.beforeandafterare the other two sides, matchingstageLabel.placement.
stageLabel.placementpositions the stage names on either side of the chart.- On a vertical funnel,
beforeandafterare mirrored when RTL Layout is enabled. - Providing
placementas an ordered array (e.g.['inside-center', 'outside-end']) lets a label that does not fit inside its stage fall back to an outside position.
See Series Labels for the full set of label placement and collision avoidance options, and the API Reference for additional customisation options.
Funnel Chart Examples Copy Link
See more Funnel Chart examples in the AG Charts Gallery.
API Reference Copy Link
Properties available on the AgFunnelSeriesOptions interface.
- type required
'funnel' - Configuration for the Funnel Series.
- stageKey required
DatumKey - The key to use to retrieve stage values from the data.
- valueKey required
DatumKey - The key to use to retrieve values from the data.
- id
stringdefault: auto-generated value - Primary identifier for the series. This is provided as `seriesId` in user callbacks to differentiate multiple series. Auto-generated ids are subject to future change without warning, if your callbacks need to vary behaviour by series please supply your own unique `id` value.
- context
ContextDefault - Context object to use in callbacks.
- data
DatumDefault[] - The data to use when rendering the series. If this is not supplied, data must be set on the chart instead.
- visible
boolean - Whether to display the series.
- cursor
string - The cursor to use for hovered markers. This config is identical to the CSS `cursor` property.
- highlight
AgHighlightOptions - Configuration for highlighting when a series or legend item is hovered over.
- nodeClickRange
InteractionRange - Range from a node that a click triggers the listener.
- listeners
AgSeriesListeners - A map of event names to event listeners.
- fills
AgColorType[] - The colours to cycle through for the fills of the bars. An array of colour strings, or fill objects for gradients, patterns, or images.
- strokes
CssColor[] - The colours to cycle through for the strokes of the bars.
- fillOpacity
Opacity - The opacity of the fill for the bars.
- strokeOpacity
Opacity - The opacity of the stroke for the bars.
- strokeWidth
PixelSize - The width in pixels of the stroke for the bars.
- spacingRatio
Ratio - The size of the gap between the categories as a proportion, between 0 and 1. This value is a fraction of the “step”, which is the interval between the start of a bar and the start of the next bar.
- cornerRadius
PixelSizedefault: 0 - The corner radius applied to every bar. The chart background shows through the area cut away by the rounded corners.
- dropOff
AgFunnelSeriesDropOff - Configuration for drop-offs between adjacent bars.
- direction
'horizontal' | 'vertical' - Bar rendering direction.
- crisp
boolean - Align bars to whole pixel values to remove anti-aliasing.
- label
AgFunnelSeriesLabelOptions - Configuration for the labels shown on bars.
- stageLabel
AgFunnelSeriesStageLabelOptions - Configuration for the stage labels.
- shadow
AgDropShadowOptions - Configuration for the shadow used behind the series items.
- tooltip
AgSeriesTooltip - Series-specific tooltip configuration.
- itemStyler
Styler - Function used to return formatting for individual bars, based on the given parameters.
- lineDash
PixelSize[] - An array specifying the length in pixels of alternating dashes and gaps.
- lineDashOffset
PixelSize - The initial offset of the dashed line in pixels.
Properties available on the AgFunnelSeriesOptions interface.
- type required
'funnel' - Configuration for the Funnel Series.
- stageKey required
DatumKey - The key to use to retrieve stage values from the data.
- valueKey required
DatumKey - The key to use to retrieve values from the data.
- id
stringdefault: auto-generated value - Primary identifier for the series. This is provided as `seriesId` in user callbacks to differentiate multiple series. Auto-generated ids are subject to future change without warning, if your callbacks need to vary behaviour by series please supply your own unique `id` value.
- context
ContextDefault - Context object to use in callbacks.
- data
DatumDefault[] - The data to use when rendering the series. If this is not supplied, data must be set on the chart instead.
- visible
boolean - Whether to display the series.
- cursor
string - The cursor to use for hovered markers. This config is identical to the CSS `cursor` property.
- highlight
AgHighlightOptions - Configuration for highlighting when a series or legend item is hovered over.
- nodeClickRange
InteractionRange - Range from a node that a click triggers the listener.
- listeners
AgSeriesListeners - A map of event names to event listeners.
- fills
AgColorType[] - The colours to cycle through for the fills of the bars. An array of colour strings, or fill objects for gradients, patterns, or images.
- strokes
CssColor[] - The colours to cycle through for the strokes of the bars.
- fillOpacity
Opacity - The opacity of the fill for the bars.
- strokeOpacity
Opacity - The opacity of the stroke for the bars.
- strokeWidth
PixelSize - The width in pixels of the stroke for the bars.
- spacingRatio
Ratio - The size of the gap between the categories as a proportion, between 0 and 1. This value is a fraction of the “step”, which is the interval between the start of a bar and the start of the next bar.
- cornerRadius
PixelSizedefault: 0 - The corner radius applied to every bar. The chart background shows through the area cut away by the rounded corners.
- dropOff
AgFunnelSeriesDropOff - Configuration for drop-offs between adjacent bars.
- direction
'horizontal' | 'vertical' - Bar rendering direction.
- crisp
boolean - Align bars to whole pixel values to remove anti-aliasing.
- label
AgFunnelSeriesLabelOptions - Configuration for the labels shown on bars.
- stageLabel
AgFunnelSeriesStageLabelOptions - Configuration for the stage labels.
- shadow
AgDropShadowOptions - Configuration for the shadow used behind the series items.
- tooltip
AgSeriesTooltip - Series-specific tooltip configuration.
- itemStyler
Styler - Function used to return formatting for individual bars, based on the given parameters.
- lineDash
PixelSize[] - An array specifying the length in pixels of alternating dashes and gaps.
- lineDashOffset
PixelSize - The initial offset of the dashed line in pixels.