Page 1 of 1

NearestTool, VC6++

Posted: Thu Jan 06, 2005 1:50 pm
by 6925557
Hello,

I'm not able to add a nearest tool to my chart. Using TeeChart 5.0.7.0, VC6++, I use the following code:

m_Chart.GetAspect().SetView3D(false);
m_Chart.AddSeries(scLine);
m_Chart.Series(0).FillSampleValues(10);

m_Chart.GetTools().Add(4); // tcNearest = 4
m_Chart.GetTools().GetItems(0).SetActive(true);
m_Chart.GetTools().GetItems(0).GetAsNearest().SetSeries(COleVariant("Series0"));
m_Chart.GetTools().GetItems(0).GetAsNearest().SetDrawLine(false);
m_Chart.GetTools().GetItems(0).GetAsNearest().SetSize(15);
m_Chart.GetTools().GetItems(0).GetAsNearest().SetStyle(hsDiamond);

However, the nearest tool does not appear. Already searched this forum but in the code examples I found I cannot see a difference.

Thanks,
mexx

Posted: Thu Jan 06, 2005 2:08 pm
by 9523803
When I search the internet I find the following sample code:

VARIANT TheSeries;
TheSeries.vt=VT_I2;
TheSeries.intVal=0;
m_chart.GetTools().GetItems(0).GetAsNearest().SetSeries(TheSeries);
TheSeries.intVal=2;
m_chart.GetTools().GetItems(0).GetAsNearest().SetSeries(TheSeries);

Have you tried this ??

Bye,
Michael Kuelshammer
Germany

Posted: Thu Jan 06, 2005 3:43 pm
by 6925557
Michael,

thanks for your help! Ok, using VARIANT works. However, another problem appears. Looks like the nearest point tool is not able to lock onto points that are positioned on one of the axes:

m_Chart.GetAspect().SetView3D(false);
m_Chart.AddSeries(scLine);
m_Chart.Series(0).Add(0, NULL, 1);
m_Chart.Series(0).Add(10, NULL, 2);
m_Chart.Series(0).Add(0, NULL, 3);
m_Chart.Series(0).Add(10, NULL, 4);
m_Chart.Series(0).Add(0, NULL, 5);
m_Chart.Series(0).Add(10, NULL, 6);

This will create a Zig-Zag sample series. The nearest tool will only lock on the first two "10"-values, not on any other (those all lie on one of the axes). When i manually move the series so that the points are not anymore on an axis, I can also lock the other points.

However, this is hardly useful as my usage for the nearest tool is to analyze/find points that are hard to spot AS they are positioned on an axis.
Anyway to fix this?

Regards,
mexx

Posted: Thu Jan 06, 2005 3:59 pm
by 9523803
In TeeChart Pro AX V7 example under the item "All features/Tools/Nearest Point" I can change the values to the values that you have posted (0,10,0,10), there I see no problem to find the nearest point that lie on the x-axis.

I think it's a problem of your old Version 5 ActiveX control.

Bye,
Michael Kuelshammer
Germany

Posted: Thu Jan 06, 2005 4:15 pm
by 6925557
Tried that using my TeeChart Pro AX v5 Features Demo. When I enter the data however, then resize the diagram using zoom-out I notice that the 0x,0y point does not reset exactly on the axes, but is slightly set off. Looks like there is some kind of margin set.

Therefore, the 0-values etc do not lie on the axis but slighty "hover above", and the nearest tool is able to find them.

I'll look whether im eligible for an version update however, maybe this is fixed in a never version.

Thanks,
mexx

Posted: Fri Jan 14, 2005 9:47 am
by Pep
Hi mexx,

yes, this is a problem that has been fixed in the latest TeeChart Pro v7.