UltraChart DataSource多个系列

时间:2013-05-24 09:38:53

标签: .net winforms infragistics linechart

有关如何初始化Infragistics Linechart数据的不同方法。 但是,我之前想使用它的Property'DataSource'并格式化数据,因为我已经将它用于其他图表。

所以我更喜欢这种方式:

UltraChart1.DataSource = myDataSource

对此(NumericTimeSeries的整个示例为here

Dim series1 As New NumericTimeSeries
series1.Label = "Series1"
series1.Points.Add(New NumericTimeDataPoint(DateTime.Now.AddMonths(-4), 12346, "Januar", True))
series1.Points.Add(New NumericTimeDataPoint(DateTime.Now.AddMonths(-3), 10000, "Februar", True))
series1.Points.Add(New NumericTimeDataPoint(DateTime.Now.AddMonths(-2), 14000, "März", True))
series1.Points.Add(New NumericTimeDataPoint(DateTime.Now.AddMonths(-1), 18000, "April", True))
series1.Points.Add(New NumericTimeDataPoint(DateTime.Now.AddMonths(10), 800, "Mai", True))

Dim series2 As New NumericTimeSeries
series2.Label = "Series2"
series2.Points.Add(New NumericTimeDataPoint(DateTime.Now.AddMonths(-8), 500, "Januar", True))
series2.Points.Add(New NumericTimeDataPoint(DateTime.Now.AddMonths(-6), 350, "Februar", True))
series2.Points.Add(New NumericTimeDataPoint(DateTime.Now.AddMonths(-4), 600, "März", True))
series2.Points.Add(New NumericTimeDataPoint(DateTime.Now.AddMonths(-2), 800, "April", True))
series2.Points.Add(New NumericTimeDataPoint(DateTime.Now.AddMonths(10), 800, "Mai", True))


UltraChart1.Series.Add(series1)
UltraChart1.Series.Add(series2)

但是,我的问题是如何格式化DataSource,它实际上显示了多个系列。

无论我尝试什么,我只在Linechart中获得一个系列。

结果应该类似于this

我们正在使用数据表的摘要,它适用于其他ChartTypes(PieChart,Stackbar等)。 如何实现这一目标的一个很好的例子,真的很感激。

1 个答案:

答案 0 :(得分:2)

这个答案由infragistics团队提供并为我解决: http://www.infragistics.com/community/forums/p/80325/406159.aspx#406159

选项1:您可以创建一个或多个系列,并使用以下代码绑定每个系列:

series2 = new NumericSeries();

series2.DataBind(dt,"2008", "Month");

series2.Label ="Year 2008";

series2.PEs.Add(new PaintElement(Color.Blue));


myColumnLayer.Series.Add(series2);


ultraChart1.CompositeChart.Series.Add(series2);

选项2:

series3 =new NumericSeries();

series3.Data.DataSource = dt;

series3.Data.ValueColumn ="2009";


series3.Data.LabelColumn ="Month";


series3.Label ="Year 2009";


series3.PEs.Add(new PaintElement(Color.Yellow));

myColumnLayer.Series.Add(series3);


ultraChart1.CompositeChart.Series.Add(series3);