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
Index was outside the bounds of the array
-
- Newbie
- Posts: 4
- Joined: Mon Nov 15, 2010 12:00 am
Index was outside the bounds of the array
- Attachments
-
- TeeChartException.JPG (60.42 KiB) Viewed 3813 times
Re: Index was outside the bounds of the array
Hello Vladimir,
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.
Thanks,
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’m using TeeChart Pro v2009/2010 for Visual Studio .NET in data acquisition.
License Number : XXXXXXXX
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.
Could you please, send us a simple project that we can reproduce exactly your problem here? So we try to solve it.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?
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 4
- Joined: Mon Nov 15, 2010 12:00 am
Re: Index was outside the bounds of the array
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
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
Re: Index was outside the bounds of the array
Hello Vladimir,
Thank you for your information. I am glad that you can find a solution for your problem.
Thanks,
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 |
Instructions - How to post in this forum |