Real-time candle chart for WinForms bound to a generic List

Can I have a sample of Real-time candle-stick or stock chart for WinForms bound to a generic List?

In my code, I am getting an exception on this line: ChartDataBindModel model = new ChartDataBindModel(candles, "StockTrack.Candle");

candles is a List<Candle> having items of type StockTrack.Candle.

Here is the exception: System.ArgumentException: Child list for field StockTrack cannot be created.     at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)     at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)     at Syncfusion.Windows.Forms.Chart.ChartBaseDataBindList.Reset()     at Syncfusion.Windows.Forms.Chart.ChartDataBindModel.Reset()     at Syncfusion.Windows.Forms.Chart.ChartDataBindModel..ctor(Object dataSource, String dataMember)

I think the dot(.) between StockTrack and Candle is causing problem. StockTrack is the namespace and Candle is the class.

This also gives me a similar exception (Child list for field Candle cannot be created): ChartDataBindModel model = new ChartDataBindModel(candles, "Candle");


7 Replies 1 reply marked as answer

SM Saravanan Madheswaran Syncfusion Team March 3, 2021 12:54 PM UTC

Hi Ashok,  
 
Greetings from Syncfusion support.  
 
Query: getting an exception on this line: ChartDataBindModel model = new ChartDataBindModel (candles, "StockTrack.Candle"); 
 
We would like to let you know that the datamember parameter of ChartDataBindModel is used to represent the member present within the datasource. As you used List<object> we no need to set datamember like below.  
 
Candle = new List<Candle>(); 
. . . 
. . . 
var model = new ChartDataBindModel(Candle); 
 
For example, if we used DataTable with dataset, we need represent table name in datamember path.  
 
string tableName = "Products"; 
prodDs1 = new DataSet(); 
prodDs1.Tables.Add(tableName); 
. . . 
var model = new ChartDataBindModel(prodDs1, tableName); 
 
Query: Can I have a sample of Real-time candle-stick? 
 
We always suggested to use DataSet or ChartSeries.Points for real time data update. So, we have prepared below sample for real -time update with DataSet. Please check the sample and let us know your concern. Meantime, we will check feasibility to achieve the same with enumerable collection and update you the status in 2 business days (5th March 2021). 
 
 
Regards, 
Saravanan. 



SM Saravanan Madheswaran Syncfusion Team March 5, 2021 12:11 PM UTC

Hi Ashok,   
 
Thanks for your patience,  
 
After further validation, we would like to suggest using Dataset or ChartSeries.Points instead of List<object> for real time data update. Hence, we do not have direct support to achieve this.  
 
Please check the sample attached earlier and let us know your concern.  
 
 
Regards, 
Saravanan.  


Marked as answer

AS Ashok March 6, 2021 03:59 PM UTC

Hi Saravanon,

Thanks for your response. I ran the sample that you have provided. It does not show as Candles. I have attached a screenshot.

Please let me know how to fix it.

Attachment: RealTime_Candle_Chart_77398cd8.zip


AS Ashok March 7, 2021 05:45 PM UTC

Please close this issue. I have worked out the solution using ChartSeries.Points.


YP Yuvaraj Palanisamy Syncfusion Team March 8, 2021 07:26 AM UTC

Hi Ashok, 
 
Thanks for your update. 
 
Please let us know if you have any concern. 
 
Regards, 
Yuvaraj. 



AS Ashok March 14, 2021 03:57 PM UTC

This is how you can bind a List<T> as datasource:

            ChartDataBindModel candleModel = new ChartDataBindModel(candles);    //candles is List<Candle>. Candle is a class with Time, High, Low, Close properties

            candleModel.XName = "Time";
            candleModel.YNames = new string[] { "High", "Low", "Open", "Close" };
            candleSeries.SeriesModel = candleModel;

I hope this will help someone.


SM Saravanan Madheswaran Syncfusion Team March 15, 2021 10:49 AM UTC

Hi Ashok, 
 
Thank you for your comments. We hope we discussed this in a previous follow-up, but the problem was that real-time updates were not enabled by list<object>, which is why we suggested using Series.Points. 
 
Also, we are currently revamping our UG documents, and we will take your feedback under consideration.  
 
Thanks, 
Saravanan.  


Loader.
Up arrow icon