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.
This is the sample
Yes, it is possible. One possible approach could be if you are using Tickmark properties. For example:
axisX.TickmarkStyle =AxisTickStyle.DataInterval;
axisX.TickmarkInterval = 4;
Take a look at the modifications that I made in the sample for more details.
Another possible approach could be if you are using FillSceneGraph event to hide some of labels
Regads
Hello GeorgiThank you for your answer.I was thinking about having multiple points for the same label, though.So instead of having one point per month I would like to see the trend within the month.Is that possible?Regards
Hello Fabian,
Yes, it is possible. You should add data for these points into your DataSource. For example:
DataTable dt = new DataTable();
dt.Columns.Add("Month");
dt.Columns.Add("2007");
dt.Columns.Add("2008");
dt.Columns.Add("2009");
dt.Columns.Add("2010");
dt.Columns.Add("2011");
dt.Rows.Add("Jan 1", 35, 10, 40, 30, 45);
dt.Rows.Add("Jan 10", 45, 20, 30, 30, 55);
dt.Rows.Add("Jan 20", 15, 30, 20, 40, 35);
dt.Rows.Add("Jan 30", 25, 10, 10, 50, 45);
dt.Rows.Add("Feb", 2, 15, 55, 35, 80);
dt.Rows.Add("Mar", 5, 35, 25, 50, 90);
dt.Rows.Add("Apr", 2, 60, 35, 70, 80);
dt.Rows.Add("May", 7, 55, 45, 80, 35);
dt.Rows.Add("Jun", 85, 45, 40, 75, 30);
In attached screenshot you could see the result.
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