Click here to Skip to main content
15,742,357 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello all,

My goal is to display my database table values ( I have two columns as Total and Used) on a pie chart. I used the WPFToolkit for the chart control and created a pie chart structure.

but I am stuck with binding the chart to the datasource.

Any one can pls suggest me a solution. Thanks !

This is what i have tried :

public List<ram> getRamData()
          List<ram> list = new List<ram>();
          string query = "select top 1 Used,Total from UsageRam";
          cmd = new SqlCommand(query, con);
          dr = cmd.ExecuteReader();
          while (dr.Read())
              var reading = new ram
                  Used = Convert.ToInt32(dr[0]),
                  Total = dr[1].ToString()
Updated 9-Jan-13 2:52am
Sanjay Debnath 9-Jan-13 7:28am    
may be this can help
BuBa1947 9-Jan-13 7:37am    
Thank you sanjay, I have refereed these links already. But in both links, they have binded the Itemsource from list , not from a database. my question is , how to bind Pie Chart datacontext to a DataBase
Sandeep Mewara 9-Jan-13 8:26am    
Just get the data from database as List.. whats the problem?
BuBa1947 9-Jan-13 8:52am    
@Sandeep Mewara: Kindly check my code above. is that the right way ?

1 solution

Hello, please take a look over here, it could solve your problem, perhaps :[^]
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