Page 1 of 1

Retain custom mark positions on chart resize or tscrollbar

Posted: Thu Jan 18, 2018 12:41 am
by 16582125
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?

Re: Retain custom mark positions on chart resize or tscrollbar

Posted: Thu Jan 18, 2018 9:03 am
by yeray
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.

Re: Retain custom mark positions on chart resize or tscrollbar

Posted: Thu Jan 18, 2018 4:11 pm
by 16582125
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?

Re: Retain custom mark positions on chart resize or tscrollbar

Posted: Tue Jan 23, 2018 8:58 am
by yeray
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 12838 times

Re: Retain custom mark positions on chart resize or tscrollbar

Posted: Wed Jan 24, 2018 12:12 am
by 16582125
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?

Re: Retain custom mark positions on chart resize or tscrollbar

Posted: Thu Jan 25, 2018 8:04 am
by yeray
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?

Re: Retain custom mark positions on chart resize or tscrollbar

Posted: Tue Mar 06, 2018 1:11 am
by 16582125
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.

Re: Retain custom mark positions on chart resize or tscrollbar

Posted: Wed Mar 07, 2018 10:45 am
by yeray
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 734 times