← Gallery

Funnel

Requests from receipt to completion

Explore the example, download the output or use the C# source in your own project.

Preview
Requests from receipt to completionChart with 1 data series: Requests.Requests from receipt to completionThe same data in a compact viewReceived to Qualified: 120 to 95Qualified to Reviewed: 95 to 74Reviewed to Completed: 74 to 41Received: 120, retained 100%Received: 120Qualified: 95, retained 79.2%, drop-off 20.8%Qualified: 9579.2% retained20.8% drop-offReviewed: 74, retained 61.7%, drop-off 22.1%Reviewed: 7461.7% retained22.1% drop-offCompleted: 41, retained 34.2%, drop-off 44.6%Completed: 4134.2% retained44.6% drop-off
Requests from receipt to completion
Requests from receipt to completionChart with 1 data series: Requests.Requests from receipt to completionThe same data in a compact viewReceived to Qualified: 120 to 95Qualified to Reviewed: 95 to 74Reviewed to Completed: 74 to 41Received: 120, retained 100%Received: 120Qualified: 95, retained 79.2%, drop-off 20.8%Qualified: 9579.2% retained20.8% drop-offReviewed: 74, retained 61.7%, drop-off 22.1%Reviewed: 7461.7% retained22.1% drop-offCompleted: 41, retained 34.2%, drop-off 44.6%Completed: 4134.2% retained44.6% drop-off
Requests from receipt to completion
360 × 360 pixels

Create this example

Create a console project, add the ChartForgeX package, and replace Program.cs with this source. Run it to write SVG, PNG and HTML with the default system fonts.

For the same typography as the gallery, download the gallery-font recipe and copy the gallery’s fonts directory beside your program.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;

var mode = VisualThemeMode.Light;
var theme = VisualTheme.Graphite();
var model = FunnelRecipe.Create("compact", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
    new VisualFrame("Requests from receipt to completion", "The same data in a compact view", showLegend: null, showSurface: false));
var prepared = model.Prepare(context);
File.WriteAllText("visual.svg", prepared.ToSvg());
File.WriteAllBytes("visual.png", prepared.ToPng());
File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Chart).ToHtmlPage());

/// <summary>Builds an ordered request funnel as proportional stages or a cone.</summary>
public static class FunnelRecipe {
    /// <summary>Creates the selected funnel example, preserving zero-valued completion stages.</summary>
    public static Chart Create(string variant = "wide", VisualThemeMode mode = VisualThemeMode.Light) {
        if (variant is not ("wide" or "compact" or "sparse" or "options" or "compact-options" or "cone-vertical" or "stage-bars-horizontal"))
            throw new ArgumentOutOfRangeException(nameof(variant));
        var chart = Chart.Create().WithDataLabels();
        if (variant is "options" or "compact-options" or "cone-vertical" or "stage-bars-horizontal") {
            var requests = new ChartSeries(new ChartSeriesId("requests"), "Requests", ChartSeriesKind.Funnel, new[] {
                new ChartPoint(1, 100), new ChartPoint(2, 75), new ChartPoint(3, 25), new ChartPoint(4, 0)
            });
            chart.WithXLabels("Received", "Reviewed", "Qualified", "Completed").AddSeries(requests)
                .ConfigureFunnel(options => {
                    options.Form = variant == "stage-bars-horizontal" ? ChartFunnelForm.StageBars : ChartFunnelForm.Cone;
                    options.Orientation = variant == "cone-vertical" ? ChartOrientation.Vertical : ChartOrientation.Horizontal;
                });
        }
        else {
            var requests = new ChartSeries(new ChartSeriesId("requests"), "Requests", ChartSeriesKind.Funnel, new[] {
                new ChartPoint(1, 120), new ChartPoint(2, 95), new ChartPoint(3, 74), new ChartPoint(4, 41)
            });
            chart.WithXLabels("Received", "Qualified", "Reviewed", "Completed").AddSeries(requests);
        }
        return chart.WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture));
    }
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;

var mode = VisualThemeMode.Dark;
var theme = VisualTheme.Graphite();
var model = FunnelRecipe.Create("compact", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
    new VisualFrame("Requests from receipt to completion", "The same data in a compact view", showLegend: null, showSurface: false));
var prepared = model.Prepare(context);
File.WriteAllText("visual.svg", prepared.ToSvg());
File.WriteAllBytes("visual.png", prepared.ToPng());
File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Chart).ToHtmlPage());

/// <summary>Builds an ordered request funnel as proportional stages or a cone.</summary>
public static class FunnelRecipe {
    /// <summary>Creates the selected funnel example, preserving zero-valued completion stages.</summary>
    public static Chart Create(string variant = "wide", VisualThemeMode mode = VisualThemeMode.Light) {
        if (variant is not ("wide" or "compact" or "sparse" or "options" or "compact-options" or "cone-vertical" or "stage-bars-horizontal"))
            throw new ArgumentOutOfRangeException(nameof(variant));
        var chart = Chart.Create().WithDataLabels();
        if (variant is "options" or "compact-options" or "cone-vertical" or "stage-bars-horizontal") {
            var requests = new ChartSeries(new ChartSeriesId("requests"), "Requests", ChartSeriesKind.Funnel, new[] {
                new ChartPoint(1, 100), new ChartPoint(2, 75), new ChartPoint(3, 25), new ChartPoint(4, 0)
            });
            chart.WithXLabels("Received", "Reviewed", "Qualified", "Completed").AddSeries(requests)
                .ConfigureFunnel(options => {
                    options.Form = variant == "stage-bars-horizontal" ? ChartFunnelForm.StageBars : ChartFunnelForm.Cone;
                    options.Orientation = variant == "cone-vertical" ? ChartOrientation.Vertical : ChartOrientation.Horizontal;
                });
        }
        else {
            var requests = new ChartSeries(new ChartSeriesId("requests"), "Requests", ChartSeriesKind.Funnel, new[] {
                new ChartPoint(1, 120), new ChartPoint(2, 95), new ChartPoint(3, 74), new ChartPoint(4, 41)
            });
            chart.WithXLabels("Received", "Qualified", "Reviewed", "Completed").AddSeries(requests);
        }
        return chart.WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture));
    }
}