Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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:
 
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 20-Dec-12 10:42am
Edited 20-Dec-12 11:39am
v2
Comments
Abhishek Pant at 22-Dec-12 10:33am
   
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Abhishek Pant at 22-Dec-12 10:41am
   
+5
jibesh at 22-Dec-12 19:30pm
   
Thanks.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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!
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.150302.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100