DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty

DwsChartFunnel

Shows how a quantity shrinks from stage to stage (visitors, sign-ups, buyers) as centered bars, each as wide as its value. The funnel fills its container on any screen, its colors are theme colors, and hovering, focusing or tapping a stage shows its value, its share of the top stage and its conversion from the stage above.

API Reference

Basic

Only ChartData is needed: one stage per step, top to bottom. Each stage shows its label, its value and its share of the top stage; the legend below names the colors.

Sales pipeline
  1. Visitors: 12,480
  2. Product views: 7,350, 58.9% of the first stage, 58.9% of the previous stage
  3. Added to cart: 2,910, 23.3% of the first stage, 39.6% of the previous stage
  4. Checkout: 1,640, 13.1% of the first stage, 56.4% of the previous stage
  5. Purchase: 1,185, 9.5% of the first stage, 72.3% of the previous stage
Show Code
FunnelChart.razor
<DwsChartFunnel Name='FunnelChartDemo_Basic' ChartData='@_sales' Title='Sales pipeline' />
FunnelChart.razor.cs
private readonly DwsChartFunnelData _sales = new DwsChartFunnelData()
    .Add("Visitors", 12480)
    .Add("Product views", 7350)
    .Add("Added to cart", 2910)
    .Add("Checkout", 1640)
    .Add("Purchase", 1185);

Loading, caption and empty

IsLoading shows a spinner in place of the drawing while the data is on its way. Caption puts a sentence under the chart - what it shows, the source - and screen readers describe the drawing with it. EmptyContent replaces the empty text when there is nothing to draw; without it NoDataText or the localized default is shown, as in the last example.

  1. Visitors: 12,480
  2. Product views: 7,350, 58.9% of the first stage, 58.9% of the previous stage
  3. Added to cart: 2,910, 23.3% of the first stage, 39.6% of the previous stage
  4. Checkout: 1,640, 13.1% of the first stage, 56.4% of the previous stage
  5. Purchase: 1,185, 9.5% of the first stage, 72.3% of the previous stage

Online shop, last 30 days.

No orders in this period yet.
No data to display
Show Code
FunnelChart.razor
<DwsSwitch Name='FunnelChartDemo_States_Loading' @bind-Value='_statesLoading' Label='IsLoading' Class='mb-2' />
<DwsChartFunnel Name='FunnelChartDemo_States_Chart' ChartData='@_sales' IsLoading='@_statesLoading' Caption='Online shop, last 30 days.' />

<!-- Nothing to draw: your own content -->
<DwsChartFunnel Name='FunnelChartDemo_States_EmptyContent' ChartData='null' Class='mt-3'>
    <EmptyContent>
        <span>No orders in this period yet.</span>
    </EmptyContent>
</DwsChartFunnel>

<!-- Nothing to draw, no EmptyContent: NoDataText or the localized default -->
<DwsChartFunnel Name='FunnelChartDemo_Empty' ChartData='null' />
FunnelChart.razor.cs
private readonly DwsChartFunnelData _sales = new DwsChartFunnelData()
    .Add("Visitors", 12480)
    .Add("Product views", 7350)
    .Add("Added to cart", 2910)
    .Add("Checkout", 1640)
    .Add("Purchase", 1185);

private bool _statesLoading;

Width and height

Width, Height, MinWidth, MaxWidth, MinHeight and MaxHeight size the funnel in pixels, caption and legend included; with a height the stages share what is left. StageMinHeight and StageGap size the stages. Drag the corner of the box: this one is 360px high and keeps between 240px and 640px wide.

  1. Visitors: 12,480
  2. Product views: 7,350, 58.9% of the first stage, 58.9% of the previous stage
  3. Added to cart: 2,910, 23.3% of the first stage, 39.6% of the previous stage
  4. Checkout: 1,640, 13.1% of the first stage, 56.4% of the previous stage
  5. Purchase: 1,185, 9.5% of the first stage, 72.3% of the previous stage
Show Code
FunnelChart.razor
<div class='funnel-demo-resizable'>
    <DwsChartFunnel Name='FunnelChartDemo_Size' ChartData='@_sales' Height='360' MinWidth='240' MaxWidth='640' StageGap='2' />
</div>

<style>
    .funnel-demo-resizable {
        resize: horizontal;
        overflow: auto;
        width: 100%;
        min-width: 240px;
        max-width: 100%;
        padding: 0.5rem;
        border: 1px dashed var(--secondary);
    }
</style>
FunnelChart.razor.cs
private readonly DwsChartFunnelData _sales = new DwsChartFunnelData()
    .Add("Visitors", 12480)
    .Add("Product views", 7350)
    .Add("Added to cart", 2910)
    .Add("Checkout", 1640)
    .Add("Purchase", 1185);

Interface-Description

Name Typ Parameters Description
GetDataAsCsv string CultureInfo? culture The data the chart was given as CSV text (RFC 4180, CRLF, a header line): one row per mark in data order, the values as passed in. Null writes numbers the invariant way with commas between the cells; a culture writes them its way with its list separator. Text a spreadsheet would run as a formula gets an apostrophe in front.
ExportDataAsync Task string? fileName, CultureInfo? culture Downloads GetDataAsCsv() as a .csv file (UTF-8 with a byte order mark). Null names the file after the chart's title, else its Name.
Name Typ Default Description
ChartData DwsChartFunnelData? null The stages, top to bottom: Stages (each with a Label, a Value, an optional Color and Tag). Add(label, value, color, tag) chains stages. A negative value, NaN or infinity is drawn as 0 with a warning. Null, or no stage, shows NoDataText.
Title string? null Caption above the funnel, also its accessible name.
NoDataText string? null Text shown when there is nothing to draw. Null uses the localized "No data to display".
EmptyContent RenderFragment? null Shown instead of the funnel when there is nothing to draw; null shows the localized empty text.
IsLoading bool false The data is still loading: a spinner instead of the funnel.
Caption string? null A sentence under the funnel (what it shows, the source); the funnel is described by it (aria-describedby).
Width int? null Width in px. Never wider than the container unless MinWidth asks for more. Null fills the container.
Height int? null Height in px, caption and legend included; the stages share what is left. Null gives every stage StageMinHeight.
MinWidth int? null Smallest width in px; the only size that may make the funnel wider than its container.
MaxWidth int? null Largest width in px, and never more than the container.
MinHeight int? null Smallest height in px; the stages grow to fill it.
MaxHeight int? null Largest height in px; the stages shrink to fit it, down to StageMinHeight.
StageMinHeight int? null Smallest height of a stage in px. Null uses 2.25rem.
StageGap int 4 Space between the stages in px.
Shape DwsChartFunnelShape DwsChartFunnelShape.Funnel Funnel narrows each stage towards the width of the next, so the stages join into one funnel; Bars draws each as a centered bar of its own width.
Colors IReadOnlyList<DwsColor>? null Theme colors of the stages, top to bottom, repeated when there are more stages; a stage's own Color wins. Null or empty uses Primary, Info, Success, Warning, Accent and Error. Undefined entries are skipped.
ShowLabels bool true Shows each stage's label before its bar. Long labels are cut off with an ellipsis at 35% of the width; the tooltip and the accessible name keep the full label.
ShowValues bool true Shows each stage's value after its bar.
ShowPercentages bool true Adds each stage's share of the top stage to its value (with ShowValues).
ShowConversionRates bool true Prints, on the line between two stages, how much the lower one lost or gained against the one above ("-41%"), in the current culture. Nothing is printed after a stage of 0. The stage's accessible text already says its share of the previous stage.
WrapLabels bool true Lets a stage label that is too long for its column (35% of the width at most) wrap onto a second line; only what still does not fit is cut off with an ellipsis. False keeps every label on one line.
ValueFormat string "#,0.##" .NET number format for the values, in the current UI culture. An invalid format falls back to the default with a warning.
WithLegend bool true Shows a legend with each stage's color and label. Hovering an entry fades the other stages (with HighlightOnHover).
LegendPosition DwsChartLegendPosition DwsChartLegendPosition.Bottom Bottom, Top, Right or Left of the funnel. Right and Left move below it on screens narrower than 576px.
ShowTooltip bool true Shows the label, value, share of the top stage and conversion from the stage above of the hovered or focused stage. Escape hides it until the next stage.
TooltipTemplate RenderFragment<DwsChartFunnelStage>? null Content of the tooltip. Null shows the default detail.
HighlightOnHover bool true Fades the other stages while one is hovered or focused, or while the pointer is on its legend entry.
Name Typ Description
OnStageClick EventCallback<DwsChartFunnelStage> Raised when a stage is clicked, tapped or activated with Enter/Space. With a handler the stages become buttons in the tab order. Not raised while disabled or in permission select mode (a click then selects the funnel).
OnStageHover EventCallback<DwsChartFunnelStage?> Raised when the pointer or focus enters a stage, and with null when neither is on one any more: also when the funnel stops reacting (disabled, permission select mode) or new data no longer has the stage.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The HTML ID attribute for the component.
AdditionalAttributes Dictionary<string, object> Additional HTML attributes for the component's root element.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.