Click here to Skip to main content
15,883,975 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone!

I have trouble putting together a chart with the contents of a data table that is basically as sex, marital status, age, and DATE . Im working with a bar chart or column chart, but I can't make it work like I want. What im looking for is that each column of the chart has his name on the bottom (column name of the database) and on the header (think are called labels) display the results of a sql query but if in that query exist different data like for example in the SEX column there are two possibilites, MAN or WOMAN and I need that if there 2 results with MAN and 3 results with WOMAN on the column chart SEX header this values have to appear there in the header of that column. I get data from a SQL Server Express DB.

This is the query that I have to get the data in the chart:

C#
SqlCommand cmd2 = new SqlCommand(string.Format("SELECT SEX, MARITAL,AGE,DATE FROM TEST WHERE (SEX IN (" + sex + ")) AND (MARITAL IN (" + marital + ")) AND (AGE (" + age + ")) AND (DATE IN (" + date + "))"), con1);
            SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
            DataSet ds2 = new DataSet();
            da2.Fill(ds2);
            chart1.DataSource = da2;
            chart1.Visible = true;

In case that you don't understand me, this is what i'm looking for (made with photoshop :p):

http://img38.imageshack.us/img38/4586/graficoingles.jpg[^]

I really search all the webs related with chart in c# winforms but i can't find any solution like this.

Can anyone please help me to make the code like the chart example using the binding from my bbdd.

Thanks for the answers!.

Kind regards.
Posted
Updated 20-Dec-12 10:39am
v2
Comments

Have you checked this link mschart[^] and sample-using-mschart-in-c-sharp[^]

there you can find more samples different types of charts as well.
 
Share this answer
 
Comments
Abhishek Pant 22-Dec-12 10:41am    
+5
Jibesh 22-Dec-12 19:30pm    
Thanks.
this might help you-
Write Your Own Bar Chart Winforms User Control[^]
Windows Charting Application[^]

or you can follow this link
jibesh
mschart[^]

hope it helps!
 
Share this answer
 

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