Page 1 of 1
TAxisScrollTool event to correct scroll
Posted: Fri Dec 09, 2016 9:54 am
by 16578912
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
Re: TAxisScrollTool event to correct scroll
Posted: Mon Dec 12, 2016 9:57 am
by yeray
Hello,
The TChart OnScroll event is fired when you drag the mouse over an axis (having a TAxisScrollTool).
Re: TAxisScrollTool event to correct scroll
Posted: Mon Dec 12, 2016 1:16 pm
by 16578912
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
Re: TAxisScrollTool event to correct scroll
Posted: Tue Dec 13, 2016 1:26 pm
by yeray
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.
Re: TAxisScrollTool event to correct scroll
Posted: Tue Dec 13, 2016 2:43 pm
by 16578912
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
Re: TAxisScrollTool event to correct scroll
Posted: Tue Dec 13, 2016 3:57 pm
by yeray
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).
Re: TAxisScrollTool event to correct scroll
Posted: Wed Dec 14, 2016 5:44 am
by 16578912
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
Re: TAxisScrollTool event to correct scroll
Posted: Wed Dec 14, 2016 8:27 am
by yeray
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;
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