Retain custom mark positions on chart resize or tscrollbar

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
kkar
Newbie
Newbie
Posts: 4
Joined: Mon Oct 23, 2017 12:00 am

Retain custom mark positions on chart resize or tscrollbar

Post by kkar » Thu Jan 18, 2018 12:41 am

I've found several posts that explain how to display the correct custom mark positions when zooming or scrolling a chart. For example:
http://www.teechart.net/support/viewtop ... =3&t=15468

In this post and any others related to custom mark position updating, the answer seems to depend on using TChart's zoom and scroll by mouse feature. My users wanted a more standard interface, so we have attached a tscrollbar - we don't use the mouse at all. So the marks do not get repositioned correctly because XScrollPos and YScrollPos are not correct. Likewise, when a chart is resized, there is no mouse click involved, and so the marks do not update correctly.

In my case, I think I need to somehow keep track of the logical positions of all the custom marks, and update marks OnResize and OnScrollBarChange. Can you suggest some code to help me accomplish this?

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

Re: Retain custom mark positions on chart resize or tscrollbar

Post by Yeray » Thu Jan 18, 2018 9:03 am

Hello,

In the example you linked, there is a method named PlaceMarks, responsible of repositioning the marks at their correct positions. This method is called at the events being fired on the actions you noted, like zoom and scroll.
In your case, you need to call that method in the the OnResize and OnScrollBarChange events. Have you tried it?

If you find any problem with it, please try to arrange a simple example project we can run as-is to reproduce the situation here.
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

kkar
Newbie
Newbie
Posts: 4
Joined: Mon Oct 23, 2017 12:00 am

Re: Retain custom mark positions on chart resize or tscrollbar

Post by kkar » Thu Jan 18, 2018 4:11 pm

I have tried it, and when you resize the form, the marks don't move, while the rest of the chart resizes. This is because all values in the XOffset and YOffset arrays are still zero; there have been no mouse clicks.

We are currently using TeeChart Pro v8.08. I tried the attached example in version 2014, and it does work there. We are moving towards a more current version, but aren't able to use it until some other upgrade issues are resolved. Is there a simple fix to make version 8 work?
Attachments
TChart_drag_marks8.zip
(2.45 KiB) Downloaded 748 times

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

Re: Retain custom mark positions on chart resize or tscrollbar

Post by Yeray » Tue Jan 23, 2018 8:58 am

Hello,

Your project seems to work fine for me with Delphi 7 and TeeChart 8.08.
I only added this code to make sure I'm using the correct TeeChart version:

Code: Select all

uses TeeConst;

  Caption:=TeeMsg_Version;
2018-01-23_09-55-31.gif
2018-01-23_09-55-31.gif (613.96 KiB) Viewed 13478 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

kkar
Newbie
Newbie
Posts: 4
Joined: Mon Oct 23, 2017 12:00 am

Re: Retain custom mark positions on chart resize or tscrollbar

Post by kkar » Wed Jan 24, 2018 12:12 am

Hmm. Turns out I was using 8.06, but even after I installed 8.08, the resize doesn't work. After the install, my paths all appear to point to 8.08. I am using D2010, not D7. It seems unlikely that is the source of the problem, but I don't know what else?
Attachments
Resize problem on 8.08e.PNG
Resize problem on 8.08e.PNG (31.18 KiB) Viewed 13459 times

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

Re: Retain custom mark positions on chart resize or tscrollbar

Post by Yeray » Thu Jan 25, 2018 8:04 am

Hello,
kkar wrote:I am using D2010, not D7. It seems unlikely that is the source of the problem, but I don't know what else?
I've tried it with RAD XE and TeeChart Pro v8.08 (source code version) and it also works fine for me.

Have you added a breakpoint into the PlaceMarks method to check if it's executed when you resize the window?
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

kkar
Newbie
Newbie
Posts: 4
Joined: Mon Oct 23, 2017 12:00 am

Re: Retain custom mark positions on chart resize or tscrollbar

Post by kkar » Tue Mar 06, 2018 1:11 am

I stepped away from the problem until we were able to upgrade to TChart v2017.22.170619, where the Resize retains the correct "stock" mark positions. But it still doesn't retain custom mark positions correctly. The TScrollbar also does not handle custom mark positions correctly. The mark still attaches to the correct point, but the mark label does not retain the correct relative position. Each scroll makes the position worse.

I understand I need to update the mark position, but I don't understand how to do it using the scrollbar. Attached is my updated sample project.
Attachments
TChart_drag_marks_scrollbar.zip
(2.63 KiB) Downloaded 755 times

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

Re: Retain custom mark positions on chart resize or tscrollbar

Post by Yeray » Wed Mar 07, 2018 10:45 am

Hello,

I've modified the project to make the marks to work fine both with the ScrollBar, and with the builtin zoom and scroll features:
TChart_drag_marks_scrollbar.zip
(82.77 KiB) Downloaded 856 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

Post Reply