Arys Posted September 1, 2008 Report Share Posted September 1, 2008 Hello all, this is a very newbie question but with the help document i cannot bind a datatable to the chart. Basicallyi am not getting the datatable from a database, im creating a datablewith dynamic data that the user types in the application. The thing is when i bind the datable to the chart, doesnt display the value. DataTable t = new DataTable();t.Columns.Add("Name");t.Columns.Add("Age");DataRow dr = t.NewRow();dr[0] = "Duncan";dr[1] = 25;t.Rows.Add(dr);mFarmLoadChart.DataSource = t; Doi need to set some basic stuff to the chart like series and such? Sorryto bother you with such a trivial thing but reading the documentation icouldnt find out what are the most basic settings i must set for thechart to load a datatable. Quote Link to comment Share on other sites More sharing options...
raydenxxx Posted September 2, 2008 Report Share Posted September 2, 2008 try this (replace your datasource): mFarmLoadChart.DataSourceSettings.Fields.Add(new FieldMap("Age", FieldUsage.Value)); // Set the Y axis valuesmFarmLoadChart.DataSourceSettings.Fields.Add(new FieldMap("Name", FieldUsage.Label)); // Set the X axis valuesmFarmLoadChart.DataSourceSettings.DataSource = t; All written in the documentation/examples ++ Raydenxxx (France) Quote Link to comment Share on other sites More sharing options...
Frank Posted September 2, 2008 Report Share Posted September 2, 2008 Make sure your Columns are typed, by default a column's type is string which is not ideal for charting: t.Columns.Add("Age",typeof(double)); Quote Link to comment Share on other sites More sharing options...
Arys Posted September 3, 2008 Author Report Share Posted September 3, 2008 GREAT!!!!! With the first comment i made the chart to load all the data perfectly, but i had some problems with the types, then its when the types came in. Thanks a lot guys, the chart is looking amazing right now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.