Cursor XValue sometime different from current cursor position

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Luca
Newbie
Newbie
Posts: 3
Joined: Wed Jun 22, 2022 12:00 am

Cursor XValue sometime different from current cursor position

Post by Luca » Mon Jun 27, 2022 4:11 pm

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.
Attachments
SampleProjForSteema.rar
(6.96 KiB) Downloaded 578 times
cursor.png
cursor.png (21.85 KiB) Viewed 6820 times

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Cursor XValue sometime different from current cursor position

Post by Yeray » Wed Jun 29, 2022 2:21 pm

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 6773 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Luca
Newbie
Newbie
Posts: 3
Joined: Wed Jun 22, 2022 12:00 am

Re: Cursor XValue sometime different from current cursor position

Post by Luca » Wed Jun 29, 2022 2:57 pm

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.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Cursor XValue sometime different from current cursor position

Post by Yeray » Mon Jul 04, 2022 12:35 pm

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;
}
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Luca
Newbie
Newbie
Posts: 3
Joined: Wed Jun 22, 2022 12:00 am

Re: Cursor XValue sometime different from current cursor position

Post by Luca » Tue Jul 05, 2022 6:59 am

Hello, thank you very much for your support, now all works well.

Post Reply