Charts 如何分配x和y值?
我在datasource中有值,datasource没有问题。我必须给图表指定X和Y值。图表抛出错误,并表示没有名为“TotalInboundArrivals”的列 我的问题在哪里?有什么建议吗?你看过了吗。将数据集指定为系列的数据源是一个错误。想想看,它怎么能在数据源中搜索列呢。尝试将Charts 如何分配x和y值?,charts,devexpress,Charts,Devexpress,我在datasource中有值,datasource没有问题。我必须给图表指定X和Y值。图表抛出错误,并表示没有名为“TotalInboundArrivals”的列 我的问题在哪里?有什么建议吗?你看过了吗。将数据集指定为系列的数据源是一个错误。想想看,它怎么能在数据源中搜索列呢。尝试将Ds.Tables[“TableName”]指定为数据源 创建数据源表 private DataTable CreateChartData(int rowCount) { // Creat
Ds.Tables[“TableName”]
指定为数据源
创建数据源表
private DataTable CreateChartData(int rowCount) {
// Create an empty table.
DataTable table = new DataTable("Table1");
// Add two columns to the table.
table.Columns.Add("Argument", typeof(Int32));
table.Columns.Add("Value", typeof(Int32));
// Add data rows to the table.
Random rnd = new Random();
DataRow row = null;
for (int i = 0; i < rowCount; i++) {
row = table.NewRow();
row["Argument"] = i;
row["Value"] = rnd.Next(100);
table.Rows.Add(row);
}
检查并浏览创建图表->提供数据
部分以更好地理解它
希望这有帮助
private DataTable CreateChartData(int rowCount) {
// Create an empty table.
DataTable table = new DataTable("Table1");
// Add two columns to the table.
table.Columns.Add("Argument", typeof(Int32));
table.Columns.Add("Value", typeof(Int32));
// Add data rows to the table.
Random rnd = new Random();
DataRow row = null;
for (int i = 0; i < rowCount; i++) {
row = table.NewRow();
row["Argument"] = i;
row["Value"] = rnd.Next(100);
table.Rows.Add(row);
}
Series series = new Series("Series1", ViewType.Bar);
chart.Series.Add(series);
// Generate a data table and bind the series to it.
series.DataSource = CreateChartData(50);
// Specify data members to bind the series.
series.ArgumentScaleType = ScaleType.Numerical;
series.ArgumentDataMember = "Argument";
series.ValueScaleType = ScaleType.Numerical;
series.ValueDataMembers.AddRange(new string[] { "Value" });