Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m working on visual studio C# project. In this i have one table with column(date,name,income). i want to show income on y axis and both date and name on x axis.

i want chart like shown in below url:-

http://www.royalcollege.ca/portalHelp2/faces/helppages/config.OHW+Servlet+1/locale.en/topics/common_images/h_wchart.gif
Posted
Updated 20-Nov-14 18:33pm
v5
Comments
BillWoodruff 20-Nov-14 9:43am    
What have you done so far ? What tech are you using: WinForms ? Win Charting Control ?
ravish naik 20-Nov-14 22:46pm    
I am using WinForms .
This is my code :-
//////////////////////////////
conn.open();
string query = "select date,name,income from table user_pay;
SqlDataAdapter mycommand = new SqlDataAdapter(query, conn);
DataSet ds = new DataSet();
mycommand.Fill(ds);
DataView source = new DataView(ds.Tables[0]);
chart1.DataSource = source;
chart1.Series[0].XValueMember = "date";
chart1.Series[0].YValueMembers = "income";
chart1.DataBind();
conn.Close();

/////////////////////////////////////////

this gives me output as on particular date this was the income , but i want name of the user
with date. so the output should be on particular date user have this income.

1 solution

To me this doesn't sound like you need 2 series on X, rather you need to concatenate the name and date into a single column in your query and then set that as your x series:

string query = "select income, Cast(date as varchar) + ' ' + name from table user_pay";

If you wanted to do display the chart in income or date order then do the sorting first as part of the SQL query:

string query = "select income, Cast(date as varchar) + ' ' + name from table user_pay order by income";
 
Share this answer
 
v2
Comments
ravish naik 24-Nov-14 22:49pm    
Thank You Very Much Friend, This Is The Perfect Solution For My Question.

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