Funnel chart
Since 0.1.0-alpha.22Use a funnel for a fixed sequence of steps, each a subset of the one before, such as a checkout. It works best with four or more steps. When the exact numbers matter, use bars in step order. Values that just get smaller, such as sales by region, aren't a funnel.
Stages and their shares
Give FunnelChart the Items in the order of the process, each stage's name as Argument, its count as Value, and a Title.
Static
Preview
- Viewed pricing, 12,400
- Started sign-up, 7,900, 64% of the first, 64% of the stage before
- Created an account, 5,600, 45% of the first, 71% of the stage before
- Started a trial, 3,700, 30% of the first, 66% of the stage before
- Became a customer, 1,450, 12% of the first, 39% of the stage before
| Stage | People | Of the first | Of the stage before |
|---|---|---|---|
| Viewed pricing | 12,400 | 100% | |
| Started sign-up | 7,900 | 64% | 64% |
| Created an account | 5,600 | 45% | 71% |
| Started a trial | 3,700 | 30% | 66% |
| Became a customer | 1,450 | 12% | 39% |
Code
@* A month's trial sign-ups, from the pricing page to a paid plan. *@
<FunnelChart Items="_stages" Argument="s => s.Stage" Value="s => s.People" Title="Trial sign-ups, October" />
{
private record SignupStage(string Stage, int People);
private readonly SignupStage[] _stages =
[
new("Viewed pricing", 12_400),
new("Started sign-up", 7_900),
new("Created an account", 5_600),
new("Started a trial", 3_700),
new("Became a customer", 1_450),
];
}Add this example to a page with the izzy CLI:
izzy add component FunnelChart --at <file>:<line>Each stage's label gives its name, value and share of the first stage. "Show data" adds each stage's share of the one before.
Labels in the stages
To write each stage's label in it, as its share over its name, set Labels="ChartLabels.Inside". A label that doesn't fit its stage, such as a narrow last stage's, sits beside the shape with a line instead.
Static
Preview
- Leads, 1,840
- Qualified, 1,290, 70% of the first, 70% of the stage before
- Proposal sent, 760, 41% of the first, 59% of the stage before
- Negotiating, 410, 22% of the first, 54% of the stage before
- Won, 180, 10% of the first, 44% of the stage before
| Stage | Deals | Of the first | Of the stage before |
|---|---|---|---|
| Leads | 1,840 | 100% | |
| Qualified | 1,290 | 70% | 70% |
| Proposal sent | 760 | 41% | 59% |
| Negotiating | 410 | 22% | 54% |
| Won | 180 | 10% | 44% |
Code
@* A quarter's sales pipeline, each stage's share written in it; the last stage is too narrow, so its label sits beside. *@
<FunnelChart Items="_stages" Argument="s => s.Stage" Value="s => s.Deals" Title="Sales pipeline, Q3" Labels="ChartLabels.Inside" />
{
private record PipelineStage(string Stage, int Deals);
private readonly PipelineStage[] _stages =
[
new("Leads", 1_840),
new("Qualified", 1_290),
new("Proposal sent", 760),
new("Negotiating", 410),
new("Won", 180),
];
}LabelTemplate replaces the labels with your own, inside or beside, built from each stage's Name, ValueText, Share and ShareOfPrevious. ChartLabels.None leaves the labels out.
A pyramid
A pyramid shows levels of a hierarchy, such as a team by seniority. To draw one, set Pyramid: the first item is at the bottom, and each level is as tall as its share of the total, which its label shows.
Static
Preview
- Engineer, 64, 52% of the total
- Senior engineer, 41, 33% of the total
- Staff engineer, 14, 11% of the total
- Principal engineer, 5, 4.0% of the total
| Level | People | Share |
|---|---|---|
| Engineer | 64 | 52% |
| Senior engineer | 41 | 33% |
| Staff engineer | 14 | 11% |
| Principal engineer | 5 | 4.0% |
Code
@* An engineering team by level, the most junior as the base. *@
<FunnelChart Items="_levels" Argument="l => l.Level" Value="l => l.People" Title="Engineering team by level" Pyramid />
{
private record TeamLevel(string Level, int People);
private readonly TeamLevel[] _levels =
[
new("Engineer", 64),
new("Senior engineer", 41),
new("Staff engineer", 14),
new("Principal engineer", 5),
];
}The wide base gives the first level more area than its share. To compare levels exactly, use a Chart with bars across.
Details
Stages keep the items' order, unsorted: the order is the process. A missing, zero or negative value gets no stage in the shape but keeps its label and its row in the table, and the stage after it has no share of the one before. Each stage has the palette's next color, as a PieChart's slices do.
Mode support
| Feature | Static | Interactive |
|---|---|---|
| A funnel, each stage as wide as its value and sloping to the next | Yes | Yes |
| A pyramid, each level as tall as its share of the total | Yes | Yes |
| Each stage named beside the shape with its value and share, joined by a line, or in its stage where it fits | Yes | Yes |
| Labels you write with a template | Yes | Yes |
| A table of the values, with each stage's share of the one before, in a "Show data" disclosure | Yes | Yes |
Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.
Accessibility
- The chart is a figure captioned by
Title, or named by a heading on the page withTitledBy. - The labels are a list, named by the title: each reads its name, value, and share of the first and of the stage before (a pyramid's: of the total). The shape is hidden from screen readers.
- "Show data" under the chart opens the same numbers as a table (
DataTable).
Parameters
| Prop | Type | Default |
|---|---|---|
RefreshHow often the chart reads its data again, at least a second, such as Refresh="TimeSpan.FromSeconds(30)". | TimeSpan? | |
RefreshFromOn a static page with Refresh: a lighter page to fetch than this one, which renders the same chart with the same id. | string? | |
ChildContentChartDrillLevel<T>s, from the top, for stages that drill down: each level's groups are the stages (the level's argument in place of Argument), their values added up by Aggregate, and selecting one shows the next level. | RenderFragment? | |
DrillWith drill-down levels: the page address's query value that holds the level ("drill" by default; give each chart that drills on a page its own). | string? | |
HideBreadcrumbWith drill-down levels: leaves out the breadcrumb above the chart. | bool | false |
AggregateWith drill-down levels, how each stage adds up its items' values: Sum by default, or Avg, Min, Max or Count. | DataAggregate | DataAggregate.Sum |
ItemsThe items, one stage each, in the order of the process. | IEnumerable<TItem>? | Required |
ArgumentEach stage's name, such as s => s.Stage. | Expression<Func<TItem, object?>>? | |
ValueEach stage's value, such as s => s.People: any number. | Expression<Func<TItem, object?>> | Required |
TitleThe chart's title, such as "Sign-ups, October", shown above it as its caption. | string? | |
HideTitleHides the title, which still names the chart for screen readers. | bool | false |
DownloadShows a button across from the title that saves the chart as a PNG, named after its title, in the color scheme on screen. | bool | false |
TitleAlignWhere the title sits: at the start by default (the left, in a left-to-right page); ChartAlign.Center or ChartAlign.End. | ChartAlign | ChartAlign.Start |
TitledByThe id of a heading already on the page that titles the chart, such as a card's, in place of Title: the chart takes its name from it and shows no title of its own. | string? | |
ValueFormatA .NET format string for the values, such as C0 or N0. | string? | |
PaletteThe colors in order: Colors (the theme's eight, the default), Shades of one color, or your own with Of. | ChartPalette? | |
PyramidDraws a pyramid: a triangle on its base, the first item at the bottom, each level as tall as its share of the total, for levels of a hierarchy such as a team's seniority. | bool | false |
LabelsWhere the labels go: beside the shape, joined to their stages by lines, by default (Auto or ChartLabels.Outside); ChartLabels.Inside writes each in its stage (its share over its name), where it fits, and puts the rest beside the shape. | ChartLabels | ChartLabels.Auto |
LabelTemplateWrites each label yourself, from the stage's name, value and shares: inside its stage or beside the shape (Inside says which). | RenderFragment<FunnelLabelContext<TItem>>? | |
DataTableThe values as a table: by default behind a "Show data" button that opens it over the chart; ChartDataTable.Collapsed puts it in a disclosure under the chart. | ChartDataTable | ChartDataTable.Popover |
OnRefreshOn an interactive page with Refresh: raised at each interval, to load new data. | EventCallback |
Plus 17 item props and 4 common props.
Full APISee also
- Chart: draws a chart on the server from a list of items, with axes, value labels, reference lines, trends and a table of the values, for every chart type.
- PieChart: shows how one total splits into a few shares, such as customers by plan, each labeled with its share.