What am I doing wrong?
DataTable dt = new DataTable(); dt.Columns.Add("Value"); dt.Columns.Add("Date"); DataRow row = dt.NewRow(); row[0] = "2"; row[1] = DateTime.Today.AddDays(-1); dt.Rows.Add(row); row = dt.NewRow(); row[0] = "3"; row[1] = DateTime.Today.AddDays(-2); dt.Rows.Add(row); row = dt.NewRow(); row[0] = "4"; row[1] = DateTime.Today.AddDays(-3); dt.Rows.Add(row); myChart.DataSource = dt; myChart.DataBind();
This is likely to happen when you don't specify the column type. Try using dt.Columns.Add("Value", typeof(int));dt.Columns.Add("Date", typeof(DateTime));Also, in order for the line chart to display a date time axis, you need to setchart.LineChart.TreatDateTimeAsString = false;https://ko.infragistics.com/help/aspnet/chart-display-data-on-a-time-scale-axis
Also tried this with NumericSeries per an example I found and I am receiving the same error. What gives?