Chart Types / Statistical Charts / WinForms Pareto Chart
WinForms Pareto Chart

Pareto charts graphically summarize the process problems in ranking order from the most frequent to the least one. These charts comprise of both a bar and a line chart where bar chart values are plotted in decreasing order of relative frequency while the line chart plots the cumulative total percentage of frequencies. Pareto chart is essentially used in scenarios where the data is broken into different categories, and when the developer needs to highlight the most important factors from a given set of factors. For example, quality control, inventory control, and customer grievance handling are some areas where Pareto chart analysis can be frequently used.

WinForms Pareto Chart

With FlexChart, Pareto chart can be easily created by combining ranged histogram chart with any of line, spline, line symbol, or spline symbol chart. First, plot the relative frequency on a ranged histogram in descending order. Then, calculate the cumulative relative frequency in percentage using original data to create another series which is plotted using any of the line, spline, line symbol, or spline symbol chart. This forms Pareto line of the chart which helps in identifying the added contribution of each category.

private void Form1_Load(object sender, EventArgs e)
{
    this.flexChart1.ChartType = ChartType.RangedHistogram;
    var histogram = new C1.Win.Chart.RangedHistogram()
    {
        Binding = "Value",
        BindingX = "Name",
        Name = "Count",
        SortDescending = true,
        DataSource = GetPurchaseFactorsData(),
        DataLabel = new DataLabel { Content = "{y:N0}", Position = LabelPosition.Top },
    };
    this.flexChart1.Series.Add((Series)histogram);
    //calculate data for Pareto line
    var histoYs = histogram.GetValues(0);
    var sum = histoYs.Sum();
    var paretoData = new List<PointF>();
    double cumulativeSum = 0;
    for (int i = 0; i < histoYs.Length; i++)
    {
        cumulativeSum += histoYs[i];
        paretoData.Add(new PointF
        {
            X = i,
            Y = (float)(cumulativeSum / sum),
        });
    }
    var paretoLine = new Series
    {
        Name = "Cumulative %",
        ChartType = ChartType.LineSymbols,
        DataSource = paretoData,
        Binding = "Y",
        BindingX = "X",
        AxisY = new Axis
        {
            Position = Position.Right,
            Min = 0,
            Max = 1,
            Format = "P0",
            Title = "Cumulative Percentage",
        },
    };
    this.flexChart1.Series.Add(paretoLine);
}

Note that the above sample code uses a custom method named GetPurchaseFactorsData to supply data to the chart. You can set up the data source as per your requirements.

Random rnd = new Random();
public List<CategoricalPoint> GetPurchaseFactorsData()
{
    var data = new List<CategoricalPoint>();
    for (int i = 1; i <= 7; i++)
    {
        int fact = 1;
        foreach (string factor in PurchaseFactors)
        {
            data.Add(new CategoricalPoint
            {
                Name = factor,
                Value = (22 - (fact * 3)) * rnd.Next(9, 15),
            });
            fact++;
        }
    }
    return data;
}