TAxisScrollTool event to correct scroll

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Technicon
Newbie
Newbie
Posts: 43
Joined: Thu Aug 11, 2016 12:00 am
Contact:

TAxisScrollTool event to correct scroll

Post by Technicon » Fri Dec 09, 2016 9:54 am

Hello

Is it possible to force TAxisScrollTool to obey axis settings like pTChartAxis->ExactDateTime = true; pTChartAxis->Increment = DateTimeStep[dtFifteenMinutes];
I would try to do this but I can't find any event in TAxisScrollTool that would be proper for such functionality.
Any help appreciated.

Best Regards,
Grzegorz

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

Re: TAxisScrollTool event to correct scroll

Post by Yeray » Mon Dec 12, 2016 9:57 am

Hello,

The TChart OnScroll event is fired when you drag the mouse over an axis (having a TAxisScrollTool).
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

Technicon
Newbie
Newbie
Posts: 43
Joined: Thu Aug 11, 2016 12:00 am
Contact:

Re: TAxisScrollTool event to correct scroll

Post by Technicon » Mon Dec 12, 2016 1:16 pm

Hello
I try to correct axis min and max from OnAllowScroll but there is probably a bug in TAxisScrollTool because it doesn't consider values than was changed inside that event.
There is also small bug that TAxisScrollTool call OnAllowScroll event with "Axis" variable instead of "AAxis".

Code: Select all

      if Assigned(TCustomChart(ParentChart).OnAllowScroll) then
      begin
        tmpMin:=AAxis.Minimum+ADelta;
        tmpMax:=AAxis.Maximum+ADelta;
        TCustomChart(ParentChart).OnAllowScroll(Axis,tmpMin,tmpMax,tmp);
      end;
Best Regards,
Grzegorz

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

Re: TAxisScrollTool event to correct scroll

Post by Yeray » Tue Dec 13, 2016 1:26 pm

Hello Grzegorz,

OnAllowScroll event was thought to give the option to cancel the scroll action "on the fly", not to change the axis scale. To change the axis scale you should use OnScroll event.
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

Technicon
Newbie
Newbie
Posts: 43
Joined: Thu Aug 11, 2016 12:00 am
Contact:

Re: TAxisScrollTool event to correct scroll

Post by Technicon » Tue Dec 13, 2016 2:43 pm

Hello,

I try to use OnScroll but I need information which axis was scrolled. Can you tell me how to do this please?

Best Regards,
Grzegorz

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

Re: TAxisScrollTool event to correct scroll

Post by Yeray » Tue Dec 13, 2016 3:57 pm

Hello Grzegorz,

The problem I see is that when OnScroll event is fired, several axes could have been scrolled. At OnAllowScroll you could add "Sender" into an array of TChartAxis and check that array at OnScroll event (and clear it).
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

Technicon
Newbie
Newbie
Posts: 43
Joined: Thu Aug 11, 2016 12:00 am
Contact:

Re: TAxisScrollTool event to correct scroll

Post by Technicon » Wed Dec 14, 2016 5:44 am

Hello

I've had similar idea but the bug mentioned above doesn't let me to do this.
TAxisScrollTool call OnAllowScroll event with "Axis" variable instead of "AAxis". That's why I get NULL if none axis is selected or pointer to axis chosen in TAxisScrollTool settings instead of axis that do the real scroll.
This problem is also linked to bug http://bugs.teechart.net/show_bug.cgi?id=1651
Is there any time frame for resolving bugs that I reported ?

Best Regards,
Grzegorz

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

Re: TAxisScrollTool event to correct scroll

Post by Yeray » Wed Dec 14, 2016 8:27 am

Hello Grzegorz,
Technicon wrote:I've had similar idea but the bug mentioned above doesn't let me to do this.
TAxisScrollTool call OnAllowScroll event with "Axis" variable instead of "AAxis". That's why I get NULL if none axis is selected or pointer to axis chosen in TAxisScrollTool settings instead of axis that do the real scroll.
I'm sorry. I applied the fix you suggested above before testing the OnAllowScroll event, and that's why it worked for me.
The next maintenance release will include this small modification.

In your case, you could play with the OnMouseDown/OnMouseUp events to determine whether the scroll started over an axis. Ie:

Code: Select all

var onAxis: TChartAxis;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var i: Integer;
begin
  onAxis:=nil;
  for i:=0 to Chart1.Axes.Count-1 do
      if Chart1.Axes.Items[i].Clicked(X,Y) then
      begin
        onAxis:=Chart1.Axes.Items[i];
        Exit;
      end;

end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  onAxis:=nil;
end;

procedure TForm1.Chart1Scroll(Sender: TObject);
begin
  if Assigned(onAxis) then
     // adjust min and max as you wish
end;
Technicon wrote:This problem is also linked to bug http://bugs.teechart.net/show_bug.cgi?id=1651
As you can see the ticket is "In progress". I have a fix in the works waiting for a second verification.
Technicon wrote:Is there any time frame for resolving bugs that I reported ?
I'm afraid we can't say when the tickets will be closed. See the Bug Fixing Policy
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