Aps.com Posted April 7, 2008 Report Share Posted April 7, 2008 Below is sample code I am using to attempt to produce a bar graphic with the yAxis as string data. I have seen examples in these forms that suggesting using a datatable column and implementing the "typeof" method to convert to string. I have tried that with no success I continue to get the message "input string not correct format" Please help. DataTable mydt = new DataTable(); mydt.Columns.Add( "Range");mydt.Columns.Add("Month",typeof(string)); DataRow mydr1 = mydt.NewRow();mydr1["Range"] = 100;mydr1["Month"] = "March"; mydt.Rows.Add(mydr1); mydt.AcceptChanges(); DataRow mydr2 = mydt.NewRow(); mydr2[ "Range"] = 200;mydr2["Month"] = "April"; mydt.Rows.Add(mydr2); mydt.AcceptChanges(); DataRow mydr3 = mydt.NewRow(); mydr3[ "Range"] = 300;mydr3["Month"] = "May"; mydt.Rows.Add(mydr3); mydt.AcceptChanges();Chart1.DataSourceSettings.Fields.Add(new FieldMap("Month", FieldUsage.XValue)); Chart1.DataSourceSettings.Fields.Add( new FieldMap("Range", FieldUsage.Value));Chart1.DataSource = mydt; Link to comment Share on other sites More sharing options...
Frank Posted April 7, 2008 Report Share Posted April 7, 2008 A month name can not be used as a value (there is no numerical value associated with it). Instead you can use it as a label. Chart1.DataSourceSettings.Fields.Add(new FieldMap("Month", FieldUsage.Label)); For Range, you need to create it as a numeric column:mydt.Columns.Add("Range",typeof(double)); Link to comment Share on other sites More sharing options...
Aps.com Posted April 7, 2008 Author Report Share Posted April 7, 2008 wow, that was too easy. there needs to be a newbie section in the form for low-end questions like that. thanks for your quick response Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.