Articles in this section
Category / Section

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

7 mins read

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

 

What is a pareto chart?

Pareto is a sorted histogram where the columns are sorted in descending order and a line represents the cumulative total percentage.

Create Pareto Chart in .NET Presentation

             Pareto chart created using Presentation

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

 

Steps to create pareto chart

 

  1. Initialize chart

 

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

 

     //Create the chart
            IPresentationChart chart = slide1.Charts.Add(100, 10, 700, 500);
 
            //Set chart type to Pareto
            chart.ChartType = OfficeChartType.Pareto;

 

  1. Assign data

 

Set a range of data 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[2, 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 TRUE to chart’s HasLegend property, to show the legend.

 

          //Apply chart elements
              //Set Chart Title
              chart.ChartTitle = "Pareto Chart";
 
              //Set Legend
              chart.HasLegend = false;                                                                                       

 

Applicable properties of pareto chart

 

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

 

1.  GapWidth

2.  IsBinningByCategory

3.  HasAutomaticBins

4.  BinWidth

5.  NumberOfBins

6.  OverflowBinValue

7.  UnderflowBinValue

8.  ParetoLineFormat

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 pareto chart.

2)As pareto 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 pareto chart using Presentation.

 

using Syncfusion.Presentation;
using Syncfusion.OfficeChart;
 
namespace ChartSample
{
    class Program
    {
        static void Main(string[] args)
        {
            using (IPresentation pptxDoc = Presentation.Create())
            {
                ISlide slide1 = pptxDoc.Slides.Add(SlideLayoutType.Blank);
 
                //Initialize chart
                IPresentationChart chart = slide1.Charts.AddChart(100, 10, 700, 500);
                chart.ChartType = OfficeChartType.Pareto;
 
                //Assign data
                chart.DataRange = chart.ChartData[2,1,8,2];
                chart.IsSeriesInRows = false;
 
                //Apply chart elements
                //Set Chart Title
                chart.ChartTitle = "Expenses";
 
                //Set Chart Data
                chart.ChartData.SetValue(2, 1, "Rent");
                chart.ChartData.SetValue(2, 2, 2300);
                chart.ChartData.SetValue(3, 1, "Car payment");
                chart.ChartData.SetValue(3, 2, 1200);
                chart.ChartData.SetValue(4, 1, "Groceries");
                chart.ChartData.SetValue(4, 2, 900);
                chart.ChartData.SetValue(5, 1, "Electricity");
                chart.ChartData.SetValue(5, 2, 600);
                chart.ChartData.SetValue(6, 1, "Gas");
                chart.ChartData.SetValue(6, 2, 500);
                chart.ChartData.SetValue(7, 1, "Cable");
                chart.ChartData.SetValue(7, 2, 300);
                chart.ChartData.SetValue(8, 1, "Mobile");
                chart.ChartData.SetValue(8, 2, 200);
 
                //Set Category values as bin values
                chart.PrimaryCategoryAxis.IsBinningByCategory = true;
 
                //Formatting Pareto line
                chart.Series[0].ParetoLineFormat.LineProperties.ColorIndex = OfficeKnownColors.Bright_green;
       
                //Gap width settings
                chart.Series[0].SerieFormat.CommonSerieOptions.GapWidth = 6;
 
                //Set Legend
                chart.HasLegend = false;
 
                //Saving and closing the Presentation
                pptxDoc.Save("ParetoChart.pptx");
                pptxDoc.Close();
            }
        }
    }
}
 

 

VB

Imports Syncfusion.Presentation
Imports Syncfusion.OfficeChart
 
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.Pareto            
 
            'Assign data
            chart.DataRange = chart.ChartData[2, 1, 8, 2]
            chart.IsSeriesInRows = False
 
            'Apply chart elements
            'Set Chart Title
            chart.ChartTitle = "Expenses"
 
            'Set data
            chart.ChartData.SetValue(2, 1, "Rent")
            chart.ChartData.SetValue(2, 2, 2300)
            chart.ChartData.SetValue(3, 1, "Car payment")
            chart.ChartData.SetValue(3, 2, 1200)
            chart.ChartData.SetValue(4, 1, "Groceries")
            chart.ChartData.SetValue(4, 2, 900)
            chart.ChartData.SetValue(5, 1, "Electricity")
            chart.ChartData.SetValue(5, 2, 600)
            chart.ChartData.SetValue(6, 1, "Gas")
            chart.ChartData.SetValue(6, 2, 500)
            chart.ChartData.SetValue(7, 1, "Cable")
            chart.ChartData.SetValue(7, 2, 300)
            chart.ChartData.SetValue(8, 1, “Mobile”)
            chart.ChartData.SetValue(8, 2, 200)
 
            'Set category values as bin values
             chart.PrimaryCategoryAxis.IsBinningByCategory = true
 
            'Formatting Pareto line
             chart.Series[0].ParetoLineFormat.LineProperties.ColorIndex = OfficeKnownColors.Bright_green
            
            'Gap width settings
            Chart.Series[0].SerieFormat.CommonSerieOptions.GapWidth = 6            
 
            'Set Legend
            chart.HasLegend = False            
 
            'Saving and closing the Presentation
            pptxDoc.Save("ParetoChart.pptx")
            pptxDoc.Close()
        End Sub
    End Class
End Namespace
 

Conclusion

I hope you enjoyed learning about how to create WinForms PowerPoint pareto chart in C#, VB.NET.

You can refer to our .NET PowerPoint feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our .NET PowerPoint example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

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