Context : Ultrachart, style : line chart, winform, databinding
Hi,
I am programming a window containing a Graph (LineChart) that can change depending of the user interaction.
I first code something using the series approach shown below :http://ko.infragistics.com/help/topic/EEB8F42A-9BEF-430E-8BAD-B99BB11B26E8
The result was Ok, but I was reinstantiating my ultrachart after each user interaction, that was not nice at all because of the flash due to reinstantiation.
So I plan to use databinding to modify my Series using SeriesCollection.This time it was a big fail with the result (no error is thrown when executing) in the ultrachart I got the message :
Line Chart Error: You must have at least one row and one numeric column
I am doing my databinding this way :
private UltraChart _myUltraChart;
private UltraChartBindingClass _myBindingClass;
//constructor
public ChartBuilder()
{
//some method returning a linechart
_myUltraChart = GetDefaultStyleUltraChart();
_myBindingClass = new UltraChartBindingClass();
//databinding
//with Series : SeriesCollection Series
_myUltraChart.DataSource = _myBindingClass.Series;
_myUltraChart.Data.DataBind();
}
//I got a method that feed my ultrachart :
public void FeedMyUltraChart(IEnumerable myTimeSeries)
foreach (var timeSerie in myTimeSeries)
_myBindingClass.Series.Add(timeSerie);
//I tried here to use _myUltraChart.Data.DataBind(); or _myUltraChart.Series.DataBind(); but nothing worked
//I got a method to clean my series (can't clean anything now, because adding series doesn't work)
public void CleanMySeries()
_myBindingClass.Series.Clear();
What am I doing the wrong way to have my project working?
Regards
Hello pebg,
If you want to use SeriesCollection and series DataBind it is not enough to set _myUltraChart.Data.DataBind(); or _myUltraChart.Series.DataBind(); First of all you should use the appropriate series type and after that you should use the code below for each of your series. For example:
NumericSeries series1 = new NumericSeries();series1.DataBind(dt, "2007", "Month");
where dt is DataTable
or
NumericSeries series2 = new NumericSeries();series2.Label = "Year 2008";series2.Data.LabelColumn = "2008";series2.Data.ValueColumn = "Month";series2.Data.DataSource = dt;
Another option could be if you apply your datasource direct to the chart. For example:
ultraChart1.DataSource = dt;
Another one option could be if you are using Points collection to add your points to your current series. For example:
NumericSeries series2 = new NumericSeries();series2.Points.Add(new NumericDataPoint(10, "item 1", false));
pebg said:I can't load all of my datas on the begining because if I have a lot of curve I can display (about 50 curves, with 1300 points each) and my datas are really heavy to load (they are coming from stored procedure that are not quick to execute).
There are different approaches to solve this task. Maybe you could use stored procedure with input parameters (for example Start and End period and so on). By this way the user could specify what kind of data would like to see in the chart. This result from this stored procedure could be dataTable which you could bind to your seriesr.
Let me know if you have any questions.
Hi again,
I had a look and the only help I found is this link : http://help.infragistics.com/Help/NetAdvantage/WinForms/2012.2/CLR4.0/html/Chart_Series_Collection.html
Unfortunatelly I didn't find what was wrong in my case.
If someone as something, let me know!
Hi Georgi,
First thank you for answering so quickly.
I had a look on your sample, but I can't apply such a technique on my project.
I can't load all of my datas on the begining because if I have a lot of curve I can display (about 50 curves, with 1300 points each) and my datas are really heavy to load (they are coming from stored procedure that are not quick to execute).
So, I have to load my datas on demand, that's why I tried to use binding on SeriesCollection to feed my Series on demand.
Do you have a sample matching it?
I made small sample for you with line chart and DataBinding. Could you please take a look at the attached sample and if you have any questions, please feel free to write me.