The main aim of this article is to create a simple Pareto Chart Control .There is few Third party Pareto charts available and also pareto chart can be made using MS Chart controls.My aim is to creata a simple pareto Chart User control.As a result ,Yes i have created a Pareto Chart user control using C#.Net.First we start with what is Pareto chart. Pareto Chart
Pareto Chart is a combination of both Bar graph and Line graph. In Pareto chart X-Axis we will plot the Data Names. In Left Y-Axis we will plot the Data Frequency and in Right side Y-Axis we will plot the Data Cumulative Frequency Percentage.A pareto chart is used to graphically summarize and display the relative importance of the differences between groups of data.
The rules of Pareto chart are to start displaying highest to lowest Frequency data as bar graph. Display the Cumulative Frequency Percentage data as a Line Graph.
here we can see a Sample data.
S.No Name Freq Cum Freq Cum Per %
1 Pareto1 535319.272727272 pareto2 459835.636363643 pareto3 4314151.272727274 pareto4 3717864.727272735 pareto5 3521377.454545456 pareto6 2724087.272727277 pareto7 2326395.636363648 pareto8 12275100
The Above sample data has been used in my program to display the result of the Pareto chart. From the above data we can see. Fre(Frequency <blah>
1) First we will start with the User Control .To Create a user control .
Create a new Windows Control Library project.
Set the Name of Project and Click Ok(here my user control name is ShanuParetoChart_CTL).
Add all the controls which is needed.
In code behind declare all the public variables and Public property variables.
private System.Windows.Forms.PictureBox PicBox;
private System.Windows.Forms.Panel OuterPanel;
private System.ComponentModel.Container components = null;
privatestring m_sPicName = "";
ContextMenuStrip docmenu = new System.Windows.Forms.ContextMenuStrip();
ToolStripMenuItem saveimg = new ToolStripMenuItem();
int NoofPlots = 5;
public DataTable dt = new DataTable();
Font f12 = new Font("arial", 12, FontStyle.Bold, GraphicsUnit.Pixel);
Pen B1pen = new Pen(Color.Black, 1);
Pen B2pen = new Pen(Color.Black, 2);
int First_chartDatarectHeight = 400;
int First_chartDatarectWidth = 600;
Font f10 = new Font("arial", 10, FontStyle.Bold, GraphicsUnit.Pixel);
LinearGradientBrush a2 = new LinearGradientBrush(new RectangleF(0, 0, 100, 19), Color.DarkGreen, Color.Green, LinearGradientMode.Horizontal);
LinearGradientBrush a3 = new LinearGradientBrush(new RectangleF(0, 0, 100, 19), Color.DarkRed, Color.Red, LinearGradientMode.Horizontal);
LinearGradientBrush a1 = new LinearGradientBrush(new RectangleF(0, 0, 100, 19), Color.Blue, Color.DarkBlue, LinearGradientMode.Horizontal);
5.In Pictuerbox Paint Method I call a Method to draw the pareto chart.i have used .NET GDI+ to Draw both Bar and Line Graph in Pareto chart with the Datatable result.In paint method i check for the Datatable Data and store the Frequency ,Cumulative Frequency and Cumulative Frequency Percentage to a Array. <see main link at top>