TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
-
CKBN
- Newbie
- Posts: 21
- Joined: Mon Apr 11, 2011 12:00 am
Post
by CKBN » Thu May 12, 2011 2:17 pm
Hi,
What will make NearestPoint.Point equals -1?
In my
Steema.TeeChart.Tools.NearestPoint Change
event handler most of my series works perfect, but for some series NearestPoint.Point always = -1
Also NearestPoint.GetNearestPoint(cursorPosition); returns -1.
My event handler look like this:
Code: Select all
private Steema.TeeChart.Tools.NearestPoint tNearestPoint;
private EventHandler _steemaTeeChartToolsNearestPointEventHandler = null;
_steemaTeeChartToolsNearestPointEventHandler = new EventHandler(tNearestPoint_Change);
tNearestPoint.Change += _steemaTeeChartToolsNearestPointEventHandler;
private void tNearestPoint_Change(object sender, EventArgs e)
{
try
{
if (NearestPointChangeDelegate != null)
{
if (tNearestPoint.Point != -1)
{
NearestPointChangeEventArgs nearestPointChangeEventArgs = new NearestPointChangeEventArgs(
tNearestPoint.Series.XValues[tNearestPoint.Point],
tNearestPoint.Series.YValues[tNearestPoint.Point]);
NearestPointChangeDelegate(this, nearestPointChangeEventArgs);
}
else
{
Point cursorPosition = ((System.Windows.Forms.Control)Chart).PointToClient(System.Windows.Forms.Cursor.Position);
int point = tNearestPoint.GetNearestPoint(cursorPosition); //Also always = -1;
}
}
}
catch (Exception ex)
{
Ellab.Debug.GlobalDebug.debugForm.WriteText(ex);
}
}
Thanks a lot in advance
Christian
-
Sandra
- Site Admin
- Posts: 3132
- Joined: Fri Nov 07, 2008 12:00 am
Post
by Sandra » Fri May 13, 2011 10:10 am
Hello Christian,
I couldn't reproduce your problem using next code:
Code: Select all
Steema.TeeChart.Styles.Points point,point1;
Steema.TeeChart.Tools.NearestPoint nearest1;
private void InitializeChart()
{
point = new Steema.TeeChart.Styles.Points(tChart1.Chart);
point1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);
nearest1 = new Steema.TeeChart.Tools.NearestPoint(tChart1.Chart);
point.FillSampleValues();
nearest1.Series = this.point;
point1.FillSampleValues();
nearest1.Change += new EventHandler(nearest1_Change);
}
void nearest1_Change(object sender, EventArgs e)
{
if (nearest1.Point != -1)
{
this.Text = nearest1.Point.ToString();
}
}
Please, could you tell us if you can reproduce your problem using previous code? And if your problem doesn't appears in using previous code please send us a simple project that we can reproduce exactly your problem.
Thanks,
-
CKBN
- Newbie
- Posts: 21
- Joined: Mon Apr 11, 2011 12:00 am
Post
by CKBN » Mon May 16, 2011 10:25 am
Hi Sandra,
Sorry for the confusion, but my question is simply:
In what conditions will NearestPoint.GetNearestPoint(...) return -1?
Thanks a lot in advance.
Christian
-
Yeray
- Site Admin
- Posts: 9612
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Tue May 17, 2011 11:03 am
Hello Christian,
CKBN wrote:In what conditions will NearestPoint.GetNearestPoint(...) return -1?
When the series linked to the tool has no points or when the points in the series are out of the axes range.
I don't see any other situation where it could return -1. However, feel free to study the function yourself (you can use RedGate's Reflector to read the TeeChart.dll via reflection if you are not a source code customer).
-
CKBN
- Newbie
- Posts: 21
- Joined: Mon Apr 11, 2011 12:00 am
Post
by CKBN » Tue May 17, 2011 11:15 am
Hi Yeray,
Thanks a lot. That gives me some better debug capabilities. I’m sure that the error is in my code.
Also, thanks for the tip about the RedGate's Reflector tool. I’ll definitely give it a try.
BR,
Christian
-
Yeray
- Site Admin
- Posts: 9612
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Tue May 17, 2011 3:37 pm
Hi Christian,
I'm happy to hear that
If you think you find a bug in TeeChart's code, don't hesitate to let us know.