Articles in this section
Category / Section

How to create PowerPoint funnel chart in C#, VB.NET?

6 mins read

This article explains how to create a funnel chart in PowerPoint using Presentation.

 

What is a funnel chart?

 

Funnel chart shows a process that starts at the initial state and ends with a final state, where it is noticeable in what stages the fall out happens and by what magnitude.

 

Create Funnel Chart in Excel

             Funnel chart created using Presentation

To create a funnel chart in PowerPoint using Presentation, you need to do the following steps.

 

Steps to create funnel chart

 

  1. Initialize chart

 

Create a chart object by calling the slide.Charts.Add method and specify the chart type to OfficeChartType.Funnel enum value.

 

            //Create the chart
            IPresentationChart chart = slide.Charts.AddChart(50, 50, 500, 400);
 
            //Set chart type to Funnel
            chart.ChartType = OfficeChartType.Funnel;

 

  1. Assign data

 

Set a range of data from the chartData value to chart’s DataRange property. To plot the series values in column and categories in row, set chart’s IsSeriesInRows property to false.

 

            //Set region of Chart data
            chart.DataRange = chart.ChartData[1, 1, 8, 2];
 
            //Set chart series in column for assigned data region
            chart.IsSeriesInRows = false;

 

  1. Apply basic chart elements

 

Add the basic elements like chart title, data labels and legend with the below list of properties.

 

  • ChartTitle of chart object.
  • Set DataLabels via DefaultDataPoint.
  • Set TRUE to chart’s HasLegend property, to show the legend.

 

              //Apply chart elements
              //Set Chart Title
              chart.ChartTitle = "Funnel Chart";
 
              //Set Legend
              chart.HasLegend = false;
              
              //Set Datalabels
              IOfficeChartSerie serie = chart.Series[0];
              serie.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;                                                                                                   

 

Applicable properties of funnel chart

 

Below is the list of other properties that is applicable for a funnel chart.

 

1.  GapWidth

 

NOTES:

1)Applying other properties unrelated to this chart might throw exception or the changes will not be reflected in the output document because those properties are not related to funnel chart.

2)As funnel chart is introduced in MS PowerPoint 2016, it can’t be viewed in MS PowerPoint 2013 and its earlier versions.

 

Download Complete Sample

 

To know more about creating charts with various settings using Presentation, please refer the documentation.

 

The following C#/ VB.NET complete code snippet shows the creation of funnel chart using Presentation.

 

C#

 

using Syncfusion.Presentation;
using Syncfusion.OfficeChart;
using System.IO;
 
namespace ChartSample
{
    class Program
    {
        static void Main(string[] args)
        {
            using (IPresentation pptxDoc = Presentation.Create())
            {
                // Adds a blank slide to the Presentation
                ISlide slide1 = pptxDoc.Slides.Add(SlideLayoutType.Blank);
 
                // Adds chart to the slide with position and size                
                IPresentationChart chart = slide1.Charts.AddChart(50, 50, 500, 400);
                chart.ChartType = OfficeChartType.Funnel;
 
                //Assign data
                chart.DataRange = chart.ChartData[1, 1, 6, 2];
                chart.IsSeriesInRows = false;
 
                //Set data
                chart.ChartData.SetValue(1, 1, "Web sales");
                chart.ChartData.SetValue(1, 2, "Users count");
                chart.ChartData.SetValue(2, 1, "Website Visits");
                chart.ChartData.SetValue(2, 2, "15600");
                chart.ChartData.SetValue(3, 1, "Downloads");
                chart.ChartData.SetValue(3, 2, "8000");
                chart.ChartData.SetValue(4, 1, "Requested price list");
                chart.ChartData.SetValue(4, 2, "6000");
                chart.ChartData.SetValue(5, 1, "Invoice sent");
                chart.ChartData.SetValue(5, 2, "2000");
                chart.ChartData.SetValue(6, 1, "Finalized");
                chart.ChartData.SetValue(6, 2, "1000");
 
                //Apply chart elements
                //Set Chart Title
                chart.ChartTitle = "Funnel Chart";
 
                //Set Datalabels
                IOfficeChartSerie serie1 = chart.Series[0];
                serie1.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
                serie1.DataPoints.DefaultDataPoint.DataLabels.Size = 8;
 
                //Set Legend
                chart.HasLegend = false;
                
                //Saving and closing the presentation
                pptxDoc.Save("FunnelChart.pptx");
                pptxDoc.Close();
            }
        }
    }
}
 

 

VB

Imports Syncfusion.Presentation
Imports Syncfusion.OfficeChart
Imports System.IO
 
Namespace ChartSample
 
    Class Program
 
        Public Shared Sub Main(ByVal args As String())
            'Creates a PowerPoint instance
            Dim pptxDoc As IPresentation = Presentation.Create()            
            Dim slide1 As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
 
            'Initialize chart
            Dim chart As IPresentationChart = slide1.Charts.AddChart(50, 50, 500, 400)
            chart.ChartType = OfficeChartType.Funnel            
 
            'Assign data
            chart.DataRange = chart.ChartData[1, 1, 6, 2]
            chart.IsSeriesInRows = False
 
            'Set data
            chart.ChartData.SetValue(1, 1, "Web sales")
            chart.ChartData.SetValue(1, 2, "Users count")
            chart.ChartData.SetValue(2, 1, "Website Visits")
            chart.ChartData.SetValue(2, 2, "15600")
            chart.ChartData.SetValue(3, 1, "Downloads")
            chart.ChartData.SetValue(3, 2, "8000")
            chart.ChartData.SetValue(4, 1, "Requested price list")
            chart.ChartData.SetValue(4, 2, "6000")
            chart.ChartData.SetValue(5, 1, "Invoice sent")
            chart.ChartData.SetValue(5, 2, "2000")
            chart.ChartData.SetValue(6, 1, "Finalized")
            chart.ChartData.SetValue(6, 2, "1000")
 
            'Apply chart elements
            'Set Chart Title
            chart.ChartTitle = "Funnel Chart"
 
            'Set Datalabels
            Dim serie1 As IOfficeChartSerie = chart.Series(0)
            serie1.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
 
            'Set Legend
            chart.HasLegend = False            
 
            'Saving and closing the presentation
            pptxDoc.Save("FunnelChart.pptx")
            pptxDoc.Close()
        End Sub
    End Class
End Namespace
 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied