Click here to Skip to main content
15,881,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
private void Bindchart()

		{			
			DataTable ChartData = objJobPerReport.GetJobPerformanceGraph(new Guid(Session["ClientKey"].ToString()));

			Chart Chart1 = new Chart();
			int num_WeeklyPaidSubmits = 0;
			int num_WeeklyOrganicSubmits = 0;
			string[] XPointMember = new string[ChartData.Rows.Count];
			int[] YPointMemberOrganic = new int[ChartData.Rows.Count];
			int[] YPointMemberPaid = new int[ChartData.Rows.Count];

			for (int count = 0; count < ChartData.Rows.Count; count++)
			{
				XPointMember[count] = ChartData.Rows[count]["SubmitDate"].ToString();
				YPointMemberOrganic[count] = Convert.ToInt32(ChartData.Rows[count]["OrganicCount"]);
				YPointMemberPaid[count] = Convert.ToInt32(ChartData.Rows[count]["PaidCount"]);
				num_WeeklyOrganicSubmits += Convert.ToInt32(ChartData.Rows[count]["OrganicCount"]);
				num_WeeklyPaidSubmits += Convert.ToInt32(ChartData.Rows[count]["PaidCount"]);
			}
			lblTotalClicks.Text = num_WeeklyPaidSubmits.ToString();
			Chart1.Series.Add("Default").Points.AddY(1);
			Chart1.Series.Add("Default1").Points.AddY(1);
			Chart1.ChartAreas.Add("ChartArea1");
			Chart1.Series[0].ChartArea = "ChartArea1";	
			//Chart1.Series[0].ChartType = SeriesChartType.Bar;
			foreach (Series series in Chart1.Series)
			{
				series.ChartType = SeriesChartType.Bar;
			}
			Chart1.Series[0].MarkerStyle = MarkerStyle.Circle;
			Chart1.ChartAreas["ChartArea1"].AxisX.Minimum = 1;
			Chart1.ChartAreas["ChartArea1"].AxisX.LineWidth = 2;
			Chart1.ChartAreas["ChartArea1"].AxisX.LineColor = Color.Maroon;

			Chart1.Series[0].YAxisType = AxisType.Primary;
			Chart1.Series[1].YAxisType = AxisType.Secondary;
			Chart1.Series[0].Points.DataBindXY(XPointMember, YPointMemberPaid);
			Chart1.Series[1].Points.DataBindXY(XPointMember, YPointMemberOrganic);
			Chart1.Series[0].IsValueShownAsLabel = true;
			Chart1.Series[1].IsValueShownAsLabel = true;
			Chart1.Series[0].Color = Color.CadetBlue;
			Chart1.Series[0].BorderWidth = 2;
			Chart1.Series[0].LabelForeColor = Color.BlueViolet;
			Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
			Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Interval = 0;
			Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
			Chart1.ChartAreas[0].AxisY.Enabled = AxisEnabled.False;			
			Chart1.Width = 500;
			Chart1.Height = 200;
			//Chart1.ChartAreas[0].AxisX.IsMarginVisible = false;
			chartcontainer.Controls.Add(Chart1);
		}


Above code i am getting the x y line for the chart in c sharp, please let me know how to remove those for chart in c#

What I have tried:

private void Bindchart()

		{			
			DataTable ChartData = objJobPerReport.GetJobPerformanceGraph(new Guid(Session["ClientKey"].ToString()));

			Chart Chart1 = new Chart();
			int num_WeeklyPaidSubmits = 0;
			int num_WeeklyOrganicSubmits = 0;
			string[] XPointMember = new string[ChartData.Rows.Count];
			int[] YPointMemberOrganic = new int[ChartData.Rows.Count];
			int[] YPointMemberPaid = new int[ChartData.Rows.Count];

			for (int count = 0; count < ChartData.Rows.Count; count++)
			{
				XPointMember[count] = ChartData.Rows[count]["SubmitDate"].ToString();
				YPointMemberOrganic[count] = Convert.ToInt32(ChartData.Rows[count]["OrganicCount"]);
				YPointMemberPaid[count] = Convert.ToInt32(ChartData.Rows[count]["PaidCount"]);
				num_WeeklyOrganicSubmits += Convert.ToInt32(ChartData.Rows[count]["OrganicCount"]);
				num_WeeklyPaidSubmits += Convert.ToInt32(ChartData.Rows[count]["PaidCount"]);
			}
			lblTotalClicks.Text = num_WeeklyPaidSubmits.ToString();
			Chart1.Series.Add("Default").Points.AddY(1);
			Chart1.Series.Add("Default1").Points.AddY(1);
			Chart1.ChartAreas.Add("ChartArea1");
			Chart1.Series[0].ChartArea = "ChartArea1";	
			//Chart1.Series[0].ChartType = SeriesChartType.Bar;
			foreach (Series series in Chart1.Series)
			{
				series.ChartType = SeriesChartType.Bar;
			}
			Chart1.Series[0].MarkerStyle = MarkerStyle.Circle;
			Chart1.ChartAreas["ChartArea1"].AxisX.Minimum = 1;
			Chart1.ChartAreas["ChartArea1"].AxisX.LineWidth = 2;
			Chart1.ChartAreas["ChartArea1"].AxisX.LineColor = Color.Maroon;

			Chart1.Series[0].YAxisType = AxisType.Primary;
			Chart1.Series[1].YAxisType = AxisType.Secondary;
			Chart1.Series[0].Points.DataBindXY(XPointMember, YPointMemberPaid);
			Chart1.Series[1].Points.DataBindXY(XPointMember, YPointMemberOrganic);
			Chart1.Series[0].IsValueShownAsLabel = true;
			Chart1.Series[1].IsValueShownAsLabel = true;
			Chart1.Series[0].Color = Color.CadetBlue;
			Chart1.Series[0].BorderWidth = 2;
			Chart1.Series[0].LabelForeColor = Color.BlueViolet;
			Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
			Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Interval = 0;
			Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
			Chart1.ChartAreas[0].AxisY.Enabled = AxisEnabled.False;			
			Chart1.Width = 500;
			Chart1.Height = 200;
			//Chart1.ChartAreas[0].AxisX.IsMarginVisible = false;
			chartcontainer.Controls.Add(Chart1);
		}
Posted
Comments
Richard MacCutchan 9-May-20 4:25am    
Check the documentation for your Chart class.
phil.o 9-May-20 4:41am    
What is the x y line? Are you talking about axis?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900