Click here to Skip to main content
15,867,308 members
Articles / Multimedia / GDI+

Internal Supply Chain, Visibility via 200 plus 3D Chart Reports - Part II

Rate me:
Please Sign up or sign in to vote.
5.00/5 (15 votes)
8 Oct 2009CPOL4 min read 53.5K   5.3K   46   4
This article focuses on internal supply chain management systems visibility via chart reports, and provides assessment apparatus to manage and monitor activities spawned during business processes, hence paves the way for timely and precise business decisions.

Introduction

This article focuses on the visibility of internal supply chain management process. It is a sequel to internal supply chain visibility. In this article, the objective is materialized using MSChart and hence provides assessment apparatus. Solution comprises Bar, Line, Area, Pie, Pareto and Kagi charts. These are further compartmentalized with respect to their respective attributes.

Reports are categories into segregated, cumulative and change in rates reports. Segregated reports provides a context of particular item or goods with this context other sub context resides to analyze that item or material. Cumulative reports provides a context of all items or it slides item context to the side.  

Segregated and cumulative reports are further classified to segregated cost, segregated quantity, cumulative cost, cumulative quantity. 

Segregated Cost Reports

Segregated cost reports contour cost perspective In Transit, current, In-Process, reserved, consumed and wasted raw material for procurement, and up-coming, current, In-Process, Sales Return, reserved, sold, and wasted finished goods for warehouse.  

Material Segregate Cost Reports

p_s_c_bar.jpg

Finished Goods Segregate Cost Reports

w_s_c_line.jpg

Segregated Quantity Reports

Segregated quantity reports contours quantity perspective  In Transit , current, In-Process, reserved, Consumed and wasted raw material for procurement, and up-coming, current, In-Process, Sales Return, reserved,  sold, and wasted finished goods for warehouse.  

Material Segregate Quantity Reports

p_s_q_bar.jpg

p_s_q_line.jpg

Finished Goods Segregate Quantity Reports

w_s_q_bar.jpg

w_s_q_line.jpg

Cumulative Cost Reports 

Cumulative cost reports contour cost perspective  In Transit , current, In-Process, reserved, consumed and wasted raw material for procurement, and up-coming, current, In-Process, Sales Return, reserved, sold, and wasted finished goods for warehouse.

Material Cumulative Cost Reports

p_c_c_bar.jpg

p_c_c_line.jpg

Finished Goods Cumulative Cost Reports  

w_c_c_bar.jpg

w_c_c_line.jpg

w_c_c_net_profit_bar.jpg

w_c_c_net_profit_line.jpg

w_c_c_net_profit_pie.jpg

Chart Working

Microsoft Chart constitutes Chart, ChartArea and Series classes. Collaboration of this object makes a chart report. A brief description of it is as under.

Chart Class

Chart control provides a canvas for a chart report. It acts as a container for chartArea. Hence, it can be seen as a framework upon which chart will be masked. SetChart() method is used in solution set attributes of the chart. It assigns title and set legends attributes for the report.

C#
System.Windows.Forms.DataVisualization.Charting.Chart SetChart()
        {
            System.Windows.Forms.DataVisualization.Charting.Chart chartTemp = 
		new System.Windows.Forms.DataVisualization.Charting.Chart();
            chartTemp.BackColor = System.Drawing.Color.Gainsboro;
            chartTemp.BackGradientStyle = 
	     System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom;
            chartTemp.BackSecondaryColor = System.Drawing.Color.Silver;
            chartTemp.BorderlineColor = System.Drawing.Color.FromArgb
		(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105)))));
            chartTemp.BorderlineDashStyle = 
		System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
            chartTemp.BorderlineWidth = 3;
            chartTemp.BorderSkin.SkinStyle = 
		System.Windows.Forms.DataVisualization.Charting.BorderSkinStyle.Sunken;

            if (_charts == Charts.Pie)
            {
                chartTemp.ChartAreas.Add(SetPieChartArea());
            }
            else
            {
                chartTemp.ChartAreas.Add(SetChartArea());
            }
            
            chartTemp.Legends.Add(SetLegend());
            chartTemp.Location = new System.Drawing.Point(10, 10);
            chartTemp.Name = "chart";
            chartTemp.Size = new System.Drawing.Size(1000, 450);
            chartTemp.TabIndex = 0;
            
            return chartTemp;
        }

ChartArea Class

ChartArea is a content of a chart class. It is added to chart class as collections. It provides intrinsic visualization of chart report other than data visualization, data visualization is done by Series which will be discuss later. SetChartArea() method sets attributes of chart area which define the style of report needed to be generated what will be attributes of x-axis and y-axis.

C#
ChartArea SetChartArea()
        {
            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = 
		new System.Windows.Forms.DataVisualization.Charting.ChartArea();


            chartArea1.Area3DStyle.Inclination = 15;
            chartArea1.Area3DStyle.IsClustered = true;
            chartArea1.Area3DStyle.IsRightAngleAxes = false;
            chartArea1.Area3DStyle.LightStyle = 
	      System.Windows.Forms.DataVisualization.Charting.LightStyle.Realistic;
            chartArea1.Area3DStyle.Perspective = 7;
            chartArea1.Area3DStyle.Rotation = 20;
            chartArea1.Area3DStyle.WallWidth = 10;
            chartArea1.AxisX.LabelStyle.Font = new System.Drawing.Font
			("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold);
            chartArea1.AxisX.LineColor = System.Drawing.Color.Teal;
            chartArea1.AxisX.MajorGrid.LineColor = System.Drawing.Color.Teal;
            chartArea1.AxisY.LabelStyle.Font = new System.Drawing.Font
			("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Bold);
            chartArea1.AxisY.LineColor = System.Drawing.Color.FromArgb
		(((int)(((byte)(64)))), ((int)(((byte)(64)))), 
		((int)(((byte)(64)))), ((int)(((byte)(64)))));
            chartArea1.AxisY.MajorGrid.LineColor = System.Drawing.Color.Teal;
            chartArea1.BackColor = System.Drawing.Color.Gainsboro;
            chartArea1.BackGradientStyle = 
	      System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom;
            chartArea1.BackSecondaryColor = System.Drawing.Color.Silver;
            chartArea1.BorderColor = System.Drawing.Color.Teal;
            chartArea1.BorderDashStyle = 
	      System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
            chartArea1.Name = "Default";
            chartArea1.ShadowColor = System.Drawing.Color.Transparent;

            return chartArea1;
        }

Series Class

Series class resides in System.Windows.Forms.DataVisualization.Charting namespace. Series class object are contents of ChartArea class. They are added to ChartArea object as collection. Hence we can have multiple type of charts within the same chartArea for comparative reports. Series class object is collection DataPoints objects. DataPoints can be collected by series.Points.AddXY(ts.Days, amount) method. The first parameter of addXY( , ) method defines x-coordinate of a point and y-coordinate is collected from the second parameter. When series type is set as SeriesChartType.Line, then DataPoints will act as point which generated line by joining all datapoints in collections. If it is set as SeriesChartType.Column, then y-coordinate will be the height of vertical bar and its position on the base is decided by x-coordinate. Same is the case with Kage chart as well.

Pareto Chart 

Pareto is an combinational chart. It’s a combination of bar and line chart. Bar chart shows product or material along x –axis and amount or quantity along y-axis. In the same chart conformed a line chart shows cumulative sum of preceding material. InitializeParetoChart() and ParetoChartTypeLoad() are fundamental methods for generation of  this chart.  

C#
#region Pareto Chart
        private void InitializeParetoChart()
        {
            // Initialize chart control
            this.chart = SetChart();

            // Suspend Chart Layout
            ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
            this.SuspendLayout();
        
            // setting attributes associated with pareto chart
            this.chart.ChartAreas[0].AxisX.Interval = 1;
            this.chart.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Days;
            this.chart.ChartAreas[0].AxisX.IntervalOffset = 1;
            this.chart.ChartAreas[0].AxisX.IntervalOffsetType = DateTimeIntervalType.Days;
            this.chart.ChartAreas[0].AxisX.LabelAutoFitStyle |= 
				LabelAutoFitStyles.LabelsAngleStep90;
            this.chart.ChartAreas[0].AxisY2.IsLabelAutoFit = false;
            
            // Add Chart control to Panel
            this.ReportPanel.Controls.Add(this.chart);
            
            // populating the chart
            ParetoChartTypeLoad();

            // Resume Chart Layout
            ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
            this.ResumeLayout(false);
        }
        void MakeParetoChart(System.Windows.Forms.DataVisualization.Charting.Chart chart, 
		string srcSeriesName, string destSeriesName)
        {
            // get name of the ChartAre of the source series
            string strChartArea = chart.Series[srcSeriesName].ChartArea;

            // ensure the source series is a column chart type
            chart.Series[srcSeriesName].ChartType = SeriesChartType.Column;

            // sort the data in the series to be by values in descending order
            chart.DataManipulator.Sort(PointSortOrder.Descending, srcSeriesName);

            // find the total of all points in the source series
            double total = 0.0;
            foreach (DataPoint pt in chart.Series[srcSeriesName].Points)
                total += pt.YValues[0];
            
            // set the max value on the primary axis to total
            chart.ChartAreas[strChartArea].AxisY.Maximum = total;
            
            // create the destination series and add it to the chart
            Series destSeries = new Series(destSeriesName);
            chart.Series.Add(destSeries);

            // ensure the destination series is a Line or Spline chart type
            destSeries.ChartType = SeriesChartType.Line;
            destSeries.BorderWidth = 3;

            // assign the series to the same chart area as the column chart
            destSeries.ChartArea = chart.Series[srcSeriesName].ChartArea;

            // assign this series to use the secondary axis and set it maximum to be 100%
            destSeries.YAxisType = AxisType.Secondary;
            chart.ChartAreas[strChartArea].AxisY2.Maximum = 100;

            // locale specific percentage format with no decimals
            chart.ChartAreas[strChartArea].AxisY2.LabelStyle.Format = "P00";

            // turn off the end point values of the primary X axis
            chart.ChartAreas[strChartArea].AxisX.LabelStyle.IsEndLabelVisible = false;

            // for each point in the source series find % of total and assign to series
            double percentage = 0.0;

            foreach (DataPoint pt in chart.Series[srcSeriesName].Points)
            {
                percentage += (pt.YValues[0] / total * 100.0);
                destSeries.Points.Add( ( Math.Round(percentage, 2) ) );
            }
        }
        private void ParetoChartTypeLoad()
        {
            // Accessing datasource
            Main.ChartDialog.PlantSegregation pseg =
               new ISCMS.Main.ChartDialog.PlantSegregation
               (_plantSegment, _charts, _chartBy, _is_Segregation, this);

            rows = pseg.Process();
            
            // Validating data for the report
            if (rows.Length == 0)
            {
                ReportPanel.Controls.Clear();
                Hasan.CMessageBoxSmall.ShowBox("No record has been found, 
		to generate Reports", (int)Hasan.CMessageBox.Type.Exclamation, 
			Location.X, Location.Y);
                return;
            }

            // Set report title
            this.chart.Titles.Add(SetTitle());

            // Initialize Series
            System.Windows.Forms.DataVisualization.Charting.Series series = 
		new System.Windows.Forms.DataVisualization.Charting.Series();
            series.BorderColor = System.Drawing.Color.FromArgb
		(((int)(((byte)(180)))), ((int)(((byte)(26)))), 
		((int)(((byte)(59)))), ((int)(((byte)(105)))));
            series.ChartArea = "Default";
            series.Legend = "Default";
            series.Name = "Default";
            
            // Add Series to a chart
            this.chart.Series.Add(series);
            
            chart.Series["Default"].Points.Clear();
            int amount = 0;
            
            // provide series with datapoints 
            for (int i = 0; i < rows.Length; i++)//
            {
                amount = pseg.ProcessItem(i);
                if (amount == 0)
                    continue;
                chart.Series["Default"].Points.AddXY(rows[i]["Name"].ToString(), amount);
            }

            // Make Pareto Chart
            if (chart.Series.Count > 1)
                chart.Series.RemoveAt(1);
            MakeParetoChart(chart, "Default", "Pareto");

            // Set chart types for output data
            chart.Series["Pareto"].ChartType = SeriesChartType.Line;

            // Set Color of line Pareto chart
            chart.Series["Pareto"].Color = Color.FromArgb(252, 180, 65);

            // set the markers for each point of the Pareto Line
            chart.Series["Pareto"].IsValueShownAsLabel = false;
            chart.Series["Pareto"].MarkerColor = Color.Red;
            chart.Series["Pareto"].MarkerStyle = MarkerStyle.None;
            chart.Series["Pareto"].MarkerBorderColor = Color.MidnightBlue;
            chart.Series["Pareto"].MarkerSize = 8;
            chart.Series["Pareto"].LabelFormat = "0.#";          }
        #endregion 

w_c_c_pareto.jpg

Line Chart

This chart is used to represent  perpetual inventory with respect to cost and quantity. The main constituents to generate this chart are InitializeLineCurvesChart() and LineCurvesChartTypeLoad().

C#
#region Line Chart
       private void InitializeLineCurvesChart()
       {
           // Initialize chart control
           this.chart = SetChart();

           // Suspend Chart Layout
           ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
           this.SuspendLayout();

           // Add Chart control to Panel
           this.ReportPanel.Controls.Add(this.chart);

           // populating the chart
           LineCurvesChartTypeLoad();

           // Resume Chart Layout
           ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
           this.ResumeLayout(false);
       }
       private void LineCurvesChartTypeLoad()
       {
           // Accessing datasource
           Main.ChartDialog.PlantSegregation pseg =
               new ISCMS.Main.ChartDialog.PlantSegregation
               (_plantSegment, _charts, _chartBy, _is_Segregation, this);

           rows = pseg.Process();

           // Validating data for the report
           if (rows.Length == 0)
           {
               ReportPanel.Controls.Clear();
               Hasan.CMessageBoxSmall.ShowBox("No record has been found,
       to generate Reports", (int)Hasan.CMessageBox.Type.Exclamation,
       Location.X, Location.Y);
               return;
           }

           // Set title for Report
           this.chart.Titles.Add( SetTitle());

           // Initialize Series
           System.Windows.Forms.DataVisualization.Charting.Series series =
       new System.Windows.Forms.DataVisualization.Charting.Series();
           series.BorderColor = System.Drawing.Color.Transparent;
           series.BorderWidth = 3;
           series.ChartArea = "Default";
           series.ChartType =
       System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Area;
           series.Color = _serial_Color;
           series.Legend = "Default";
           series.MarkerSize = 4;
           series.MarkerStyle =
       System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
           series.Name = "series";
           series.ShadowColor = System.Drawing.Color.Gainsboro;
           series.ShadowOffset = 2;
           series.XValueType =
       System.Windows.Forms.DataVisualization.Charting.ChartValueType.Date;
           series.YValueType =
       System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
           series.BorderColor = System.Drawing.Color.Transparent;

           TimeSpan ts = DateTime.Now - new DateTime(1900, 1, 1);
           double days = ts.Days;
           double days2 = days;
           int amount = 0;
           int perviousAmount = 0;

           // providing series datapoints
           for (int pointIndex = 0; pointIndex < rows.Length; pointIndex++)
           {
               amount = pseg.ProcessItem(pointIndex);
               ts = DateTime.Parse(rows[pointIndex]["Date"].ToString()) -
                       new DateTime(1900, 1, 1);
               if (perviousAmount == 0 && pointIndex == 0)
               {
                   series.Points.AddXY(ts.Days, amount);
                   perviousAmount = amount;
                   continue;
               }

               if (pointIndex == (rows.Length - 1))
               {
                   series.Points.AddXY(ts.Days, amount);
                   continue;
               }

               if( perviousAmount != amount )
               {
                   series.Points.AddXY(ts.Days, amount);
                   perviousAmount = amount;
                   continue;
               }
           }

           // Select chart type
           switch (combChartType.Text)
           {
               case "Line":
                   if (!chkAreaChart.Checked)
                   {
                       series.ChartType = SeriesChartType.Line;
                   }
                   else
                   {
                       series.ChartType = SeriesChartType.Area;
                   }
                   break;
               case "Spline":
                   if (!chkAreaChart.Checked)
                   {
                       series.ChartType = SeriesChartType.Spline;
                   }
                   else
                   {
                       series.ChartType = SeriesChartType.SplineArea;
                   }
                   break;
               case "StepLine":
                   if (!chkAreaChart.Checked)
                   {
                       series.ChartType = SeriesChartType.StepLine;
                   }
                   else
                   {
                       series.ChartType = SeriesChartType.SplineArea;
                   }
                   break;
           }

           // Display label on the chart
           if (chkPointLabel.Checked)
           {
               series.IsValueShownAsLabel = true;
           }
           else
           {
               series.IsValueShownAsLabel = false;
           }

           // Display margin on sides of a chart
           if (chkMargin.Checked)
               chart.ChartAreas["Default"].AxisX.IsMarginVisible = true;
           else
               chart.ChartAreas["Default"].AxisX.IsMarginVisible = false;

           // Display 3D Chart
           if (chkDisplay3D.Checked)
               chart.ChartAreas["Default"].Area3DStyle.Enable3D = true;
           else
               chart.ChartAreas["Default"].Area3DStyle.Enable3D = false;

           // Add Series to a chart
           this.chart.Series.Add(series);
       }
       #endregion

p_s_c_line.jpg

Pie Chart

It is a cumulative chart which can be generated by calling the InitializePieCollection() method. Its code is as given below:  

C#
#region Pie Chart
        private void InitializePieCollection()
        {
            // Initialize chart control
            this.chart = SetChart();

            // Suspend Chart Layout
            ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
            this.SuspendLayout();

            // setting attributes associated with Pie chart
            this.chart.Legends[0].Enabled = true;
            this.chart.Legends[0].IsEquallySpacedItems = true;
            
            // Add Chart control to Panel
            this.ReportPanel.Controls.Add(this.chart);

            // populating the chart
            PieChartTypeLoad();

            // Resume Chart Layout
            ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
            this.ResumeLayout(false);
        }
        private void PieChartTypeLoad()
        {
            // Accessing datasource
            Main.ChartDialog.PlantSegregation pseg =
                new ISCMS.Main.ChartDialog.PlantSegregation
                (_plantSegment, _charts, _chartBy, _is_Segregation, this);

            rows = pseg.Process();

            // Validating data for the report
            if (rows.Length == 0)
            {
                ReportPanel.Controls.Clear();
                Hasan.CMessageBoxSmall.ShowBox("No record has been found, 
		to generate Reports", (int)Hasan.CMessageBox.Type.Exclamation, 
		Location.X, Location.Y);
                return;
            }

            // Set report title
            this.chart.Titles.Add(SetTitle());

            // Initialize Series
            System.Windows.Forms.DataVisualization.Charting.Series series = 
		new System.Windows.Forms.DataVisualization.Charting.Series();
            series.BorderColor = System.Drawing.Color.FromArgb
		(((int)(((byte)(64)))), ((int)(((byte)(64)))), 
		((int)(((byte)(64)))), ((int)(((byte)(64)))));
            series.ChartArea = "Area1";
            series.ChartType = 
		System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie;
            series.Color = System.Drawing.Color.FromArgb
		(((int)(((byte)(180)))), ((int)(((byte)(65)))), 
		((int)(((byte)(140)))), ((int)(((byte)(240)))));
            series.CustomProperties = "DoughnutRadius=15, 
		PieDrawingStyle=Concave, CollectedLabel=Other, MinimumRelative" +
                "PieSize=10";
            series.Font = new System.Drawing.Font("Trebuchet MS", 8.25F, 
		System.Drawing.FontStyle.Bold);
            series.Label = "#PERCENT{P1}";
            series.Legend = "Default";
            series.MarkerStyle = 
		System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
            series.Name = "Default";
            series.XValueType = 
		System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
            series.YValueType = 
		System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
            
            System.Windows.Forms.DataVisualization.Charting.DataPoint dataPoint1 = 
		new System.Windows.Forms.DataVisualization.Charting.DataPoint(0, 0);
            int amount = 0;

            // providing series with datapoints 
            for (int i = 0; i < rows.Length; i++)
            {
                amount = pseg.ProcessItem(i);
                dataPoint1 = 
	       new System.Windows.Forms.DataVisualization.Charting.DataPoint(0, amount);
                dataPoint1.CustomProperties = "OriginalPointIndex=" + i.ToString();
                dataPoint1.IsValueShownAsLabel = false;
                dataPoint1.LegendText = rows[i]["Name"].ToString();
                
                if( !chkPercentage.Checked )
                    dataPoint1.Label = rows[i]["Name"].ToString();
                series.Points.Add(dataPoint1);
            }

            // Add Series to a chart
            this.chart.Series.Add(series);

            // Set series font
            chart.Series[0].Font = new Font("Trebuchet MS", 8, FontStyle.Bold);
            chart.Series[0]["CollectedToolTip"] = "Other";
            chart.Series["Default"]["PieLabelStyle"] = "Outside";

            // Merge smaller slice into one
            if (ChkCollectSlices.Checked)
            {
                chart.Series["Default"]["CollectedThreshold"] = combThershold.Text;
                combThershold.Enabled = true;
            }
            else
            {
                combThershold.Enabled = false;
            }

            // Remove supplemental series and chart area if they already exist
            if (chart.Series.Count > 1)
            {
                chart.Series.RemoveAt(1);
                chart.ChartAreas.RemoveAt(1);
                // Reset automatic position for the default chart area
                chart.ChartAreas["Default"].Position.Auto = true;
            }

            pieHelper = new PieCollectedDataHelper(chart);
            pieHelper.CollectedLabel = String.Empty;

            if (chkSupplementChart.Checked)
            {
                chart.Series["Default"]["PieLabelStyle"] = "Outside";

                // Set the percentage of the total series values. This value determines
                // if the data point value is a "small" value and 
	       // should be shown as collected.
                pieHelper.CollectedPercentage =  double.Parse(combThershold.Text);

                // Indicates if small segments should be shown as one 
                // "collected" segment in the original series.
                pieHelper.ShowCollectedDataAsOneSlice = chkCollectSmallSegment.Checked;

                // Size ratio between the original and supplemental chart areas.
                // Value of 1.0f indicates that same area size will be used.
                if (combSupplementSize.SelectedIndex == 0)
                {
                    pieHelper.SupplementedAreaSizeRatio = 0.9f;
                }
                else if (combSupplementSize.SelectedIndex == 1)
                {
                    pieHelper.SupplementedAreaSizeRatio = 1.0f;
                }
                else if (combSupplementSize.SelectedIndex == 2)
                {
                    pieHelper.SupplementedAreaSizeRatio = 1.1f;
                }

                // Set position in relative coordinates 
                // ( 0,0 - top left corner; 100,100 - bottom right corner)
                // where original and supplemental pie charts should be placed.
                pieHelper.ChartAreaPosition = new RectangleF(3f, 3f, 93f, 96f);

                // Show supplemental pie for the "Default" series
                pieHelper.ShowSmallSegmentsAsSupplementalPie("Default");
            }
            else
            {
                chart.Series["Default"]["PieLabelStyle"] = "Outside";
                chart.Series["Default"].LabelBackColor = Color.Empty;
            }

            // setting time interval for animated Pie chart
            timer1.Interval = 10;
            timer1.Enabled = true;
        }
        #endregion

p_c_c_pie.jpg

Bar Chart

The code for bar chart is as under:

C#
#region Bar Chart
       private void InitializeBarColumn()
       {
           // Initialize chart control
           this.chart = SetChart();

           // Suspend Chart Layout
           ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
           this.SuspendLayout();

           // Add Chart control to Panel
           this.ReportPanel.Controls.Add(this.chart);

           // populating the chart
           BarColumnChartTypeLoad();

           // Resume Chart Layout
           ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
           this.ResumeLayout(false);
       }
       private void BarColumnChartTypeLoad()
       {
           // Accessing datasource
           Main.ChartDialog.PlantSegregation pseg =
               new ISCMS.Main.ChartDialog.PlantSegregation
               (_plantSegment, _charts, _chartBy, _is_Segregation, this);

           rows = pseg.Process();

           // Validating data for the report
           if (rows.Length == 0)
           {
               ReportPanel.Controls.Clear();
               Hasan.CMessageBoxSmall.ShowBox("No record has been found,
       to generate Reports", (int)Hasan.CMessageBox.Type.Exclamation,
       Location.X, Location.Y);
               return;
           }

           // Set report's title
           this.chart.Titles.Add(SetTitle());

           // Initialize Series
           System.Windows.Forms.DataVisualization.Charting.Series series =
       new System.Windows.Forms.DataVisualization.Charting.Series();
           series.ChartArea = "Default";
           series.Legend = "Default";
           series.Name = "series";
           series.XValueType =
        System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
           this.chart.Series.Clear();

           // Set title for Report
           this.chart.Series.Add(series);

           TimeSpan ts = DateTime.Now - new DateTime(1900, 1, 1);
           double days = ts.Days;
           double days2 = days;
           int amount = 0;

           // providing series with datapoints
           for (int pointIndex = 0; pointIndex < rows.Length; pointIndex++)
           {
               amount = pseg.ProcessItem(pointIndex);
               ts = DateTime.Parse(rows[pointIndex]["Date"].ToString()) -
                       new DateTime(1900, 1, 1);
               series.Points.AddXY(ts.Days, amount);
           }
           series.Color = _serial_Color;

           // Display margin on chart
           if (chkMargin.Checked)
               chart.ChartAreas["Default"].AxisX.IsMarginVisible = true;
           else
               chart.ChartAreas["Default"].AxisX.IsMarginVisible = false;

           // Display 3D chart
           if (this.chkDisplayBar3D.Checked)
           {
               series.BorderColor = System.Drawing.Color.Transparent;
               chart.ChartAreas["Default"].Area3DStyle.Enable3D = true;
           }
           else
           {
               series.BorderColor = System.Drawing.Color.Teal;
               chart.ChartAreas["Default"].Area3DStyle.Enable3D = false;
           }

           // Setting attribute associated with chart area
           chart.ChartAreas[0].AxisX.LabelStyle.IntervalOffset = 1;
           chart.ChartAreas[0].AxisX.LabelStyle.IntervalOffsetType =
       System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Days;
           chart.ChartAreas[0].AxisX.LabelStyle.Interval = 2;
           chart.ChartAreas[0].AxisX.LabelStyle.IntervalType =
        System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Days;
       }
       #endregion

w_s_c_bar.jpg

Kagi Chart

Kagi chart is used to monitor material or finished goods rate over a period of time. This chart can be established by the following code:

C#
#region Kagi Chart
        private void InitializeKagiChart()
        {
            // Initialize chart control
            this.chart = SetChart();

            // Suspend Chart Layout
            ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
            this.SuspendLayout();
            
            // Add Chart control to Panel
            this.ReportPanel.Controls.Add(this.chart);

            // populating the chart
            KagiChartTypeLoad();

            // Resume Chart Layout
            ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
            this.ResumeLayout(false);
        }
        private void KagiChartTypeLoad()
        {
            Main.ChartDialog.PlantSegregation pseg =
               new ISCMS.Main.ChartDialog.PlantSegregation
               (_plantSegment, _charts, _chartBy, _is_Segregation, this);

            rows = pseg.Process();

            if (rows.Length == 0)
            {
                ReportPanel.Controls.Clear();
                Hasan.CMessageBoxSmall.ShowBox("No record has been found, 
		to generate Reports", (int)Hasan.CMessageBox.Type.Exclamation, 
		Location.X, Location.Y);
                return;
            }  
            
            DataSet ds = new DataSet();
            ds.Merge(rows);
            System.Windows.Forms.DataVisualization.Charting.Series series = 
		new System.Windows.Forms.DataVisualization.Charting.Series();
            series.BorderColor = System.Drawing.Color.Teal;
            series.BorderWidth = 3;
            series.ChartArea = "Default";
            series.ChartType = 
	     System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Kagi;
            series.Color = System.Drawing.Color.Tomato;
            series.CustomProperties = "PriceUpColor=SkyBlue";
            series.IsXValueIndexed = true;
            series.Legend = "Default";
            series.Name = "Default";
            series.ShadowColor = System.Drawing.Color.Gainsboro;
            series.ShadowOffset = 2;
            series.XValueType = 
		System.Windows.Forms.DataVisualization.Charting.ChartValueType.Date;
            series.YValueType = 
		System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
            this.chart.Titles.Add(SetTitle());

            series.Points.Clear();
            double bufRate = 0;
            TimeSpan ts;

            for (int pointIndex = 0; pointIndex < rows.Length; pointIndex++)
            {
                ts = DateTime.Parse(rows[pointIndex]["Date"].ToString()) - 
						new DateTime(1900, 1, 1);
                if (ds.Tables[0].Select(" Date = #" + 
	       DateTime.Parse(rows[pointIndex]["Date"].ToString()).ToShortDateString() 
		+ "#").Length > 0)// ts.Days == 0 )
                {
                    series.Points.AddXY(ts.Days, Convert.ToDouble(rows[pointIndex]
						["Unit_Cost"]));
                    bufRate = Convert.ToDouble(rows[pointIndex]["Unit_Cost"]);
                }
                else
                    series.Points.AddXY(ts.Days, bufRate);
            }
            series["ReversalAmount"] = combReversalAmount.Text;
            this.chart.Series.Add(series);
        }
        #endregion 

History

  • 8th October, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
This is a Organisation

33 members

Comments and Discussions

 
GeneralInformatin ... musta got yer texting mixed in. Pin
MacSpudster13-Oct-09 9:07
professionalMacSpudster13-Oct-09 9:07 
GeneralRe: Informatin ... musta got yer texting mixed in. Pin
Syed Hasan Hyder13-Oct-09 18:49
Syed Hasan Hyder13-Oct-09 18:49 
GeneralGreat Pin
Dr.Luiji8-Oct-09 20:46
professionalDr.Luiji8-Oct-09 20:46 
GeneralRe: Great Pin
Syed Hasan Hyder9-Oct-09 18:10
Syed Hasan Hyder9-Oct-09 18:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.