Chart updated every second keeps running into errors

Hi there, under .NET 8.0, to a form already having 3 charts updated per minute and running for weeks w/o problems, I added a 4th one. This spans a minute and is updated every second. It threw messages often when a new minute started, within ChartAreaPrepare, until I changed its X axis from DateTime to decimal, and use only the seconds to place candles. The code is within try-catch, just a simple series.Points.Add(candle). I don't subscribe to the chart events. The latest weekly release of SfChart. Still, it errs sometimes like this, pls advise:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

   at Syncfusion.Windows.Forms.Chart.ChartSeriesRenderer.PrepearePoints()

   at Syncfusion.Windows.Forms.Chart.ChartSeriesRenderer.CanRender()

   at Syncfusion.Windows.Forms.Chart.ChartPlace.CalculateSpace(ChartSeriesCollection series, Boolean doManyAreas, IChartAreaHost chart)

   at Syncfusion.Windows.Forms.Chart.ChartSeriesCollection.DrawSeries(Graphics g, IChartAreaHost chart)

   at Syncfusion.Windows.Forms.Chart.ChartArea.Draw2D(PaintEventArgs e, ChartPaintFlags flags)

   at Syncfusion.Windows.Forms.Chart.ChartArea.Draw(PaintEventArgs e, ChartPaintFlags flags)

   at Syncfusion.Windows.Forms.Chart.ChartControl._Paint(Graphics g, Rectangle r)

   at Syncfusion.Windows.Forms.Chart.ChartControl.OnPaint(PaintEventArgs e)

   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)

   at System.Windows.Forms.Control.WmPaint(Message& m)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at Syncfusion.Windows.Forms.Chart.ChartControl.WndProc(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

   at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, WM msg, WPARAM wparam, LPARAM lparam)





12 Replies

NT Nitheeshkumar Thangaraj Syncfusion Team July 20, 2023 07:56 AM UTC

Hi Gyorgy,

Currently, our team is investigating your query. We will provide an update on July 24, 2023


Regards,

Nitheeshkumar T.



GG Gyorgy Gorog July 20, 2023 01:56 PM UTC

Just as additional info to your investigation: this happens rather regularly every 3-4 hours. I will try to re-config the chart every hour, redefining the axes and series. We'll see if it hepls.



GG Gyorgy Gorog July 20, 2023 04:18 PM UTC

If I want to reset the chart every hour, it errs on the first attempt. Code is: 

SecondsChart.Series.Clear();

SecondsChart.ColumnDrawMode = ChartColumnDrawMode.ClusteredMode;

SecondsChart.ColumnWidthMode = ChartColumnWidthMode.FixedWidthMode;

SecondsChart.ColumnFixedWidth = 4;


SecondsChart.PrimaryXAxis.ValueType = ChartValueType.Double;

SecondsChart.PrimaryXAxis.RangeType = ChartAxisRangeType.Set;

SecondsChart.PrimaryXAxis.Range = new MinMaxInfo( -10, 60, 10 );


_minuteCandleSeries.EnableStyles = true;

_minuteCandleSeries.ConfigItems.FinancialItem.PriceDownColor =

_minuteCandleSeries.ConfigItems.FinancialItem.PriceUpColor = Color.Blue;

SecondsChart.Series.Add( _minuteCandleSeries );


_candleSeries.EnableStyles = false;

_candleSeries.Style.Border.Color = Color.Black;

_candleSeries.Style.Border.Width = 1;

SecondsChart.Series.Add( _candleSeries );


_volumeSeries.EnableStyles = false;

_volumeSeries.Style.Interior = new Syncfusion.Drawing.BrushInfo( Color.SkyBlue );

_volumeSeries.Style.Symbol.Color = _volumeSeries.Style.Symbol.Border.Color = _volumeSeries.Style.Border.Color = Color.Transparent;

SecondsChart.Series.Add( _volumeSeries );


ChartAxis volumeYAxis = new ChartAxis( ChartOrientation.Vertical );

volumeYAxis.OpposedPosition = true;

volumeYAxis.DrawGrid = false;

volumeYAxis.AutoSize = false;

volumeYAxis.Size = new Size( 1, SecondsChart.Height / 5 );

volumeYAxis.ForeColor = volumeYAxis.TickColor = volumeYAxis.LineType.ForeColor = Color.SkyBlue;

_volumeSeries.YAxis = volumeYAxis;

SecondsChart.Axes.Add( volumeYAxis );



GG Gyorgy Gorog July 21, 2023 07:22 AM UTC

May be my bad. The collection behind the series grew forever, I didn't check that it gets truncated when a new minute starts. Yet, the error message did not indicate this. We'll see.



SM Saravanan Madheswaran Syncfusion Team July 21, 2023 11:04 AM UTC

It appears that you were able to resolve the issue on your end. We are attempting to prepare the sample based on the input above, and we are validating the stack trace as well. We will update you in one business day, on July 24, 2023.



GG Gyorgy Gorog July 21, 2023 02:22 PM UTC

Saravanan, we'll see during the weekend if it's stable. Will be back to you on Monday with the news. 



NT Nitheeshkumar Thangaraj Syncfusion Team July 22, 2023 06:15 AM UTC

Hi Gyorgy,

Sure, take your time and evaluate the stability during the weekend. I'll be here, so feel free to reach out with any updates or news on Monday. 


Regards,

Nitheeshkumar T.



NT Nitheeshkumar Thangaraj Syncfusion Team July 24, 2023 12:45 PM UTC

Hi Gyorgy,


We have prepared the sample as you provided input. In this simple sample, could you please modify the reproduced issue for better understanding so that we can effectively address your needs?.

Attached the sample in below


Regards,

Nitheeshkumar T.


Attachment: WinFormsSample_4332bf32.zip



GG Gyorgy Gorog July 26, 2023 05:54 AM UTC

Nitheeshkumar, thanks for the sample. However, I fail to understand how a sample of adding a new series with 3 points relates to my original problem, which is a 24/7 running application drawing new points every second and refreshing every minute.

Anyway, my app seems stable now, with limited growth allowed for the collections behind the series. 

Thanks for your efforts, I think this thread may be closed. 



PR Preethi Rajakandham Syncfusion Team July 27, 2023 04:47 AM UTC

Hi Gyorgy Gorog,

You're welcome. Please let us know if you have any further queries on this. We are happy to help.

Regards,

Preethi R



GG Gyorgy Gorog July 27, 2023 11:32 AM UTC

Preeth, finally BeginUpdate() and EndUpDate() came to the rescue. Next time you may just look for these in the code or ask back to the user as a first line of defence. 



PR Preethi Rajakandham Syncfusion Team July 28, 2023 09:22 AM UTC

Hi Gyorgy,

Thank you for the update. Please let us know if you have any further queries on this. We are happy to help.


Loader.
Up arrow icon