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)
Hi Gyorgy,
Currently, our team is investigating your query. We will provide an update on July 24, 2023
Regards,
Nitheeshkumar T.
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.
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 );
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.
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.
Saravanan, we'll see during the weekend if it's stable. Will be back to you on Monday with the news.
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.
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
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.
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
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.
Hi Gyorgy,
Thank you for the update. Please let us know if you have any further queries on this. We are happy to help.
- 12 Replies
- 4 Participants
-
GG Gyorgy Gorog
- Jul 19, 2023 08:28 AM UTC
- Jul 28, 2023 09:22 AM UTC