C1FlexChart绑定匿名数组
本帖最后由 Richard.Ma 于 2019-7-1 09:29 编辑有些时候,我们的flexchart需要绑定的数据源不是数据表,想要直接绑定一个数组,来显示多个series,这个时候可以通过绑定匿名数组来实现
下面是关键代码
private void Form1_Load(object sender, EventArgs e)
{
List<object> pointslist = new List<object>();
pointslist.Add(new { X = 1, Y1 = 100, Y2 = 80 });
pointslist.Add(new { X = 2, Y1 = 400, Y2 = 100});
pointslist.Add(new { X = 3, Y1 = 28000, Y2 = 150});
pointslist.Add(new { X = 4, Y1 = 240, Y2 = 34000000});
pointslist.Add(new { X = 5, Y1 = 180, Y2 = 280});
pointslist.Add(new { X = 6, Y1 = 380, Y2 = 180});
pointslist.Add(new { X = 7, Y1 = 380, Y2 = 180 });
pointslist.Add(new { X = 8, Y1 = 380, Y2 = 180 });
pointslist.Add(new { X = 9, Y1 = 380, Y2 = 180 });
pointslist.Add(new { X = 10, Y1 = 380, Y2 = 180 });
pointslist.Add(new { X = 11, Y1 = 380, Y2 = 180 });
pointslist.Add(new { X = 12, Y1 = 380, Y2 = 180 });
flexChart1.Series.Clear();
flexChart1.DataSource = pointslist;
flexChart1.BindingX = "X";
// create data series
C1.Win.Chart.Series series1 = new C1.Win.Chart.Series();
C1.Win.Chart.Series series2 = new C1.Win.Chart.Series();
flexChart1.Series.Add(series1);
flexChart1.Series.Add(series2);
series1.Binding = "Y1";
series1.Name = "Offshore";
series2.Binding = "Y2";
series2.Name = "Onsite";
flexChart1.ChartType = C1.Chart.ChartType.LineSymbols;
}
最终运行效果
代码呢:( putaoleix 发表于 2019-6-27 18:30
代码呢
不好意思,代码可能是编辑时发生错误没有被添加到帖子里,已经添加,请参考
谢谢提醒
页:
[1]