There are different ways about how the data of a Infragistics Linechart can be initialized. However, I would like to use its Property 'DataSource' and format the data before, since I already use this for other charts too.
So I would prefer this way:
UltraChart1.DataSource = myDataSource
Against this (Whole example with NumericTimeSeries is 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)
However, my question is of how to format the DataSource, that it actually shows up more than one series.
No matter what I try, I'm only getting one Series in the Linechart.
The result should look something like this
We are using an abstract of a datatable, which works fine for the other ChartTypes (PieChart, BarChart, etc.). A good example of how to achieve this, would really be appreciated.
Hello Fabian,
There are different approaches to solve this task. Here are few possible options:
Option 1: You could create a one or more series and bind each of them using the code:
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);
Option 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);
For more details, please take a look at the first attached sample where I`m using different series in a composite chart.
Option 3:
If you want to use direct DataSource property , you should specify the data type of your columns. Please take a look at the second sample for more details.
Let me know if you have any questions.
Regards
Hello GeorgiThank you very much for your answer. It helped me a lot!Is there also a way to have more than one point per month in LineCharts? E.g. to show the trend in January?Regards
This is the first sample