Index was outside the bounds of the array

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
VladimirDenisov
Newbie
Newbie
Posts: 4
Joined: Mon Nov 15, 2010 12:00 am

Index was outside the bounds of the array

Post by VladimirDenisov » Fri Feb 11, 2011 12:26 am

Hi,
I’m using TeeChart Pro v2009/2010 for Visual Studio .NET in data acquisition.
License Number : XXXXXXXX

I have quite reproducible “Index was outside the bounds of the array” exception in TeeChart:
Here is the scenario:
1. There are several FastLine Series and Points series in the TeeChart control.
2. In run time, various threads are asynchronously adding points (5 points per second per series) to the series using invocation:
if (chart.InvokeRequired)
chart.Invoke(. . .);

3. X-axis is rescaled in runtime: as soon as any data point reaches the right margin of the graph, x-max is increased
Axes.Bottom.Maximum = Axes.Bottom.Maximum * 2;
so there is always a gap between the last data point in the series and the right margin of the graph.
4. Zoom in on the gap and there is an exception in the Points series.

Could you recommend a solution for the problem?

Thank you
Vladimir
Attachments
TeeChartException.JPG
TeeChartException.JPG (60.42 KiB) Viewed 3813 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Index was outside the bounds of the array

Post by Sandra » Fri Feb 11, 2011 11:43 am

Hello Vladimir,
I’m using TeeChart Pro v2009/2010 for Visual Studio .NET in data acquisition.
License Number : XXXXXXXX
First, I apologize to edit your message and change License Number for X. But, I had to change this number, because protect your data.
I recommend you to other times that you never put your License Number of TeeChart in forums. If we need check your licenses, we can know these to other ways and it is not necessary.
I have quite reproducible “Index was outside the bounds of the array” exception in TeeChart:
Here is the scenario:
1. There are several FastLine Series and Points series in the TeeChart control.
2. In run time, various threads are asynchronously adding points (5 points per second per series) to the series using invocation:
if (chart.InvokeRequired)
chart.Invoke(. . .);
3. X-axis is rescaled in runtime: as soon as any data point reaches the right margin of the graph, x-max is increased
Axes.Bottom.Maximum = Axes.Bottom.Maximum * 2;
so there is always a gap between the last data point in the series and the right margin of the graph.
4. Zoom in on the gap and there is an exception in the Points series.
Could you recommend a solution for the problem?
Could you please, send us a simple project that we can reproduce exactly your problem here? So we try to solve it.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

VladimirDenisov
Newbie
Newbie
Posts: 4
Joined: Mon Nov 15, 2010 12:00 am

Re: Index was outside the bounds of the array

Post by VladimirDenisov » Tue Feb 15, 2011 3:23 am

Hi Sandra,

I will never reveal my license number again :-); thanks for pointing that out.

I did not have a chance to create a simple project for you to reproduce the problem. I managed to find a solution though. I hope it could help others, as I saw some mentioning in the forums about similar exceptions related to the Points series.

To overcome the problem, I derived from the Points series and overridden some functions. In my particular case one of the functions along the exception path was the IsPointInChartRect(int32 valueindex). It turned that the index could sometimes be -1, which obviously created problems within the Points series. Now I use my PointsEx series instead and it seems working all right.

internal class PointsEx : Steema.TeeChart.Styles.Points
{
public PointsEx(Steema.TeeChart.Chart c): base(c) {}

protected override bool IsPointInChartRect(int valueIndex)
{
bool bRet = false;
if (valueIndex >= 0)
bRet = base.IsPointInChartRect(valueIndex);
return bRet;
}

public override void DrawValue(int index)
{
if (!IsPointInChartRect(index))
return;

base.DrawValue(index);
}

protected override void DrawMark(int index, string s, SeriesMarks.Position position)
{

if (!IsPointInChartRect(index))
return;
base.DrawMark(index, s, position);

}
}

Regards

Vladimir

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Index was outside the bounds of the array

Post by Sandra » Tue Feb 15, 2011 2:35 pm

Hello Vladimir,

Thank you for your information. I am glad that you can find a solution for your problem.:)

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply