private void Bindchart() { SqlConnection Conn = new SqlConnection(ConfigurationHelper.ConnectionStringDCI); com = new SqlCommand("GetSaleData", Conn); com.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(com); DataSet ds = new DataSet(); da.Fill(ds); DataTable ChartData = ds.Tables[0]; //storing total rows count to loop on each Record string[] XPointMember = new string[ChartData.Rows.Count]; int[] YPointMember = new int[ChartData.Rows.Count]; for (int count = 0; count < ChartData.Rows.Count; count++) { //storing Values for X axis XPointMember[count] = ChartData.Rows[count]["Quarter"].ToString(); //storing values for Y Axis YPointMember[count] = Convert.ToInt32(ChartData.Rows[count]["SalesValue"]); } //binding chart control Chart1.Series[0].Points.DataBindXY(XPointMember, YPointMember); //Setting width of line Chart1.Series[0].BorderWidth = 10; //setting Chart type Chart1.Series[0].ChartType = SeriesChartType.Pie; // Chart1.Series[0].Appearance.DiameterScale = 0.6; foreach (Series charts in Chart1.Series) { foreach (DataPoint point in charts.Points) { switch (point.AxisLabel) { case "Below 31": point.Color = Color.SteelBlue; break; case "Between 31 & 60": point.Color = Color.LightSkyBlue; break; case "Above 60": point.Color = Color.LightSkyBlue; break; } point.Label = string.Format("{0:0}% - {1} ", point.YValues[0], point.AxisLabel); Chart1.Series["Default"].Font = new Font("Arial", 10.0f, FontStyle.Bold); Chart1.Legends["Default"].Font = new Font("Arial", 11.0f, FontStyle.Bold); } } Conn.Close(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)