Page 1 of 1

Cursor XValue sometime different from current cursor position

Posted: Mon Jun 27, 2022 4:11 pm
by 16593929
I have a TFastLine Series with big data and i need to show in a box the Cursor->XValue property. The cursor is following the mouse(SnapStyle=ssVertical). The problem is: when the mouse stands in the midddle between 2 X-Values of the Bottom Axis, the cursor moves to next point, while the XValue property of the cursor shows the previous value.

In my application i have big data to show and the chart is zoomed out and i need to be accurate on the value i show.

In the image you can see the error.

I have also made a sample application.

Re: Cursor XValue sometime different from current cursor position

Posted: Wed Jun 29, 2022 2:21 pm
by yeray
Hello,

What TeeChart version are you using?
It seems to work fine here with v2022.35:
Steema32bitApp_2022-06-29_16-15-41.png
Steema32bitApp_2022-06-29_16-15-41.png (19.95 KiB) Viewed 6772 times

Re: Cursor XValue sometime different from current cursor position

Posted: Wed Jun 29, 2022 2:57 pm
by 16593929
Hello,
i'm using Embarcadero 10.4.2 and i've downloaded the last version of TeeChart v2022.35
In installed packages in C++ Builder i see the right paths (...Source Code 2022.35...). The only strange thing i see is the component TChart that shows the version v2022.34.220329 in the Object Inspector.

I need to point that the Cursor error shows when the cursor is EXACTLY in the middle betwwen the two points when slowly moving the mouse from one point to another and stopping in the middle. In the screenshot i've posted above i was moving the mouse slowly from point "1" to point "2" of the bottom axis. When the cursor snap to point "2" i stopped moving the mouse and see the error. In the other cases works well.

Re: Cursor XValue sometime different from current cursor position

Posted: Mon Jul 04, 2022 12:35 pm
by yeray
Hello,

The issue here is the OnMouseMove event is triggered before processing the SnapToPoint code so the XValue at that moment still holds the old value.
Instead, you could use the TCursorTool's OnSnapChange event. Ie:

Code: Select all

//...
#include <VCLTee.TeeTools.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
	//...
private:	// User declarations
	void __fastcall CursorSnapChange(TCursorTool* Sender, int x, int y, const double XValue, const double YValue, Vcltee::Teengine::TChartSeries* Series, int ValueIndex);

Code: Select all

void __fastcall TForm1::FormCreate(TObject *Sender)
{
	//...
	cursor->OnSnapChange = CursorSnapChange;
}

void __fastcall TForm1::CursorSnapChange(TCursorTool* Sender, int x, int y, const double XValue, const double YValue, Vcltee::Teengine::TChartSeries* Series, int ValueIndex)
{
	double d;
	d = cursor->XValue;
	Edit1->Text = d;
}

Re: Cursor XValue sometime different from current cursor position

Posted: Tue Jul 05, 2022 6:59 am
by 16593929
Hello, thank you very much for your support, now all works well.