Funnel chart

Now, let's learn how to create a Funnel chart. We will create a chart showcasing the purchase-conversion analysis ofa a website. The data will look as shown below:

Wesite Sections Website Visits
Unique Website Visits 1460000
Programme Details Section Visits 930000
Attempts to Register 540000
Successful Registrations 210000
Logged In 190000
Purchased on Introductory Offers 120000

The chart will look as shown below:

FusionCharts will load here..

Click here to edit the funnel chart.

Render the Chart

Create the FunnelChart.aspx.cs file and do the following:

  • Include the FusionCharts.DataEngine and FusionCharts.Visualization .dll files.
  • Create DataTable.
  • Retrieve data using database query.
  • Set server name.
  • Set DataBase name.
  • Connect with DataBase using a connection string.
  • Create StaticSource using the DataTable.
  • Create an instance of DataModel class.
  • Add DataSource to the DataModel.
  • Instantiate Funnel Chart.
  • Set chart width and height.
  • Set DataModel instance as the data source of the chart.
  • Set Chart Title.
  • Finally, use a container using <div> to render the chart.

The code is shown below:

using FusionCharts.Visualization;
using FusionCharts.DataEngine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace FusionChartsVisualisationWebFormsSamples.Samples {
    public partial class FunnelChart : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
            // Create data table
            DataTable primaryData = new DataTable();

            // Retrieve data using database query
            string query = "select [Website Sections], [Website Visits] from dbo.WebsiteVisits";
            string connetionstring = null;

            // Servevr name
            string serverName = "FusionChartsServer";

            // DataBase name
            string databaseName = "FusionChartsSamplesDB";

            // Connection string
            connetionstring = "Data Source=" + serverName + ";Initial Catalog=" + databaseName + ";Trusted_Connection=true;";

            using (SqlConnection con = new SqlConnection(connetionstring))
                using (SqlCommand command = new SqlCommand(query, con))
                using (SqlDataAdapter da = new SqlDataAdapter(command))
            StaticSource source = new StaticSource(ChartData);
            DataModel model = new DataModel();
            Charts.FunnelChart funnel = new Charts.FunnelChart("first_Funnel_chart");
            funnel.Data.Source = model;
            funnel.Caption.Text = "Visit to purchase analysis";
            funnel.Caption.Text = "Harry's Supermart";
            funnel.SubCaption.Text = "Visit to purchase- Conversion Anallysis for last year";
            Literal1.Text = funnel.Render();

The .aspx template for the above sample is shown below:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FunnelChart.aspx.cs" Inherits="FusionChartsVisualisationWebFormsSamples.Samples.FunnelChart" %>
<!DOCTYPE html>
<html xmlns="">
<head runat="server">
    <script type="text/javascript" src="//"></script>
    <form id="form1" runat="server">
            <asp:Literal ID ="Literal1" runat ="server"></asp:Literal>
            <input type ="button" value ="Samples" onclick="location.href = 'Index.aspx';" />