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,
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.
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?
Thanks for your response. If you have any questions, feel free to write us
Sorry, I forgot to reply after you help me!
To solve my problem, I didn't use databinding ...
I Manually add and remove series from my UltraChart and it works well (I did it the same way as before I wawnted to use databinding).
Thanks for all Georgi!
Have you been able to resolve your issue ? If you still have any concerns or questions I will be glad to help. If you need any additional assistance don’t hesitate to ask.
I made small sample where I`m using NumericTimeSeries with Points collection. On a button click I add a new point to Points collection :
private void ultraButton1_Click(object sender, EventArgs e) { series1.Points.Add(new NumericTimeDataPoint(DateTime.Today.AddDays(day), RandValue(), "test", false)); day++; }
Please take a look at the attached sample for more details and let me know if you have any questions.
Georgi said: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));
NumericSeries series2 = new NumericSeries();series2.Points.Add(new NumericDataPoint(10, "item 1", false));
=>I am exactly in this case (using point collection and not datatables), the only difference is that I have NumericTimeSeries instead of NumericSeries.
So what his the next step to add it to my ultrachart using binding?
I only found descriptions of databinding with datatable (as you show in your previous point) and not with point collection.
Maybe I could build a datatable with my datas, but it would be just a trick.
SeriesCollection really seem to be the right solution.
Georgi 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.[/quote] Forget the point I told you I used stored procedure, it was just to tell you that it was heavy to load. When I am using my datas they are in collections, no more in datatables. Don't hesitate to ask me more precisions if you need it. Thanks for helping
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.[/quote]
Forget the point I told you I used stored procedure, it was just to tell you that it was heavy to load.
When I am using my datas they are in collections, no more in datatables.
Don't hesitate to ask me more precisions if you need it.
Thanks for helping