ZoomIn ZoomOut with MouseWheel ?
ZoomIn ZoomOut with MouseWheel ?
Hi !
Is it possible to Zoom in and Zoom out with the mousewheel ?
How can I realize this?
Is it possible to Zoom in and Zoom out with the mousewheel ?
How can I realize this?
Greetz Dominik
http://www.logview.info
http://www.logview.info
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dominik,
Yes, this is possible using this code:
Yes, this is possible using this code:
Code: Select all
Chart1.TabStop:=true;
TeeUseMouseWheel:=true;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi !
Well I added
in FormCreate
but nothing happend. Are ther some other properties which have to be set (or not)?
Something is interesting:
This procedure is never fired up when use the wheel from my mouse.
Any suggestions ?
Well I added
Code: Select all
TeeUseMouseWheel := true;
Chart1.TabStop := true;
but nothing happend. Are ther some other properties which have to be set (or not)?
Something is interesting:
Code: Select all
procedure TForm1.Chart1MouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
beep;
end;
Any suggestions ?
Greetz Dominik
http://www.logview.info
http://www.logview.info
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dominik,
Code below works fine for me here using latest v8 release available. Which TeeChart version are you using? Can you please test if this works fine at your end?
Thanks in advance.
Code below works fine for me here using latest v8 release available. Which TeeChart version are you using? Can you please test if this works fine at your end?
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
TeeUseMouseWheel:=true;
Chart1.TabStop:=true;
end;
procedure TForm1.Chart1MouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
Chart1.Title.Text.Add('Hi');
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
I did a test with a really small sample application. The mousewheel works.
But it only scrolls the y-axis.
Is it possible to scroll the x-Axis, too?
And how can I use the mouse wheel to zoom in / out (what is the interesting part for me)?
But it only scrolls the y-axis.
Is it possible to scroll the x-Axis, too?
And how can I use the mouse wheel to zoom in / out (what is the interesting part for me)?
Greetz Dominik
http://www.logview.info
http://www.logview.info
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dominik,
This may work provided you have a mouse that supports horizontal wheel scrolling.Is it possible to scroll the x-Axis, too?
Sorry for overlooking the original message. In that case you can do something like in this C++ Builder example:And how can I use the mouse wheel to zoom in / out (what is the interesting part for me)?
Code: Select all
void __fastcall TForm1::FormMouseWheel(TObject *Sender, TShiftState Shift,
int WheelDelta, TPoint &MousePos, bool &Handled) {
Chart1->Zoom->Animated = false;
if(WheelDelta > 0)
Chart1->ZoomPercent(110);
if(WheelDelta < 0)
Chart1->ZoomPercent(90);
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Ok thx !
But what the hell can cause Chart1MouseWheel to be never fired up?
In my simple demo it works. My bigger demo don´t bring this event.
This is the start from FormCreate. So in general it should work ?!
But what the hell can cause Chart1MouseWheel to be never fired up?
In my simple demo it works. My bigger demo don´t bring this event.
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
TeeUseMouseWheel := true;
Chart1.TabStop := true;
Greetz Dominik
http://www.logview.info
http://www.logview.info
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dominik,
Is there any other mouse event on your project that may be overriding the OnMouseWheel event? If so you could try commenting in those events and check if it makes a difference.
Is there any other mouse event on your project that may be overriding the OnMouseWheel event? If so you could try commenting in those events and check if it makes a difference.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi !
No there is only a ChartListBox2MouseDown. But this shouldn´t be a problem.
I tried to put another Chart to the mainform. Set
and added some sample data to the series 1. In my simple demo this works fine. In my bigger dimo this won´t work, too.
So could it be possible that there is something worng in the mainform? There are no other mousewheel events.
Strange thing ....
No there is only a ChartListBox2MouseDown. But this shouldn´t be a problem.
I tried to put another Chart to the mainform. Set
Code: Select all
TeeUseMouseWheel := true;
Chart1.TabStop := true;
Chart2.TabStop := true;
So could it be possible that there is something worng in the mainform? There are no other mousewheel events.
Strange thing ....
Greetz Dominik
http://www.logview.info
http://www.logview.info
This works:
Code: Select all
procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
Chart1.Title.Text.Add('Hi');
end;
Greetz Dominik
http://www.logview.info
http://www.logview.info
From my point of view:
1. First, make sure you Chart in your big demo is the active control, otherwise it won’t fire OnMouseWheel event.
2. It’s useful to add in OnChartClick event handler something like
or
to allow user to set focus to chart without tabbing, just clicking it.
3. And finally in OnMouseWheel event handler write something like that
this enables user to use Ctrl+Shift together with mouse wheel for zooming in and out,
Ctrl+Alt together with mouse wheel for horizontal scrolling and still allow him to use plain MouseWheel for vertical scrolling.
4. Last bun not least, thank you for a good tip how to organize more clever Unzoom under control of user, I just work on this issue, because standard TeeChart Unzoom to the original 100% is not always what user expects.
Regards,
Alexander
1. First, make sure you Chart in your big demo is the active control, otherwise it won’t fire OnMouseWheel event.
2. It’s useful to add in OnChartClick event handler something like
Code: Select all
procedure TForm1.Chart1Click(Sender: TObject);
begin
ActiveControl:=Chart1;
…
end;
Code: Select all
procedure TForm1.Chart1Click(Sender: TObject);
begin
Chart1.SetFocus;
…
end;
3. And finally in OnMouseWheel event handler write something like that
Code: Select all
procedure TForm1.Chart1MouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
Percentage : double;
begin
if ([ssShift,ssCtrl] <= Shift) then
with Chart1 do begin
if WheelDelta>0 then
Percentage:=100+0.045*WheelDelta
else
Percentage:=100+0.05*WheelDelta;
ZoomPercent(Percentage);
Handled:=True;
end
else
if ([ssAlt,ssCtrl] <= Shift) then
with Chart1.BottomAxis do begin
Scroll(WheelDelta*(Maximum-Minimum)/1000,False);
Handled:=True;
end;
end;
Ctrl+Alt together with mouse wheel for horizontal scrolling and still allow him to use plain MouseWheel for vertical scrolling.
4. Last bun not least, thank you for a good tip how to organize more clever Unzoom under control of user, I just work on this issue, because standard TeeChart Unzoom to the original 100% is not always what user expects.
Regards,
Alexander
I only have to say once:
THANK YOU VERY MUCH !!!
That´s absolutely great ... fantastic
THANK YOU VERY MUCH !!!
That´s absolutely great ... fantastic
Greetz Dominik
http://www.logview.info
http://www.logview.info
Hi !
There are still 2 small problems:
1) custom Y axis
I use only custom Y axis and I zoom these axis with this code:
And this is my code for the MouseWheel:
If you try this and use the scrolling wheel for zooming (with pressed Shift, CTRL) the Y axis are zoomed dramatically. The axis are approximated zoomed with the factor 1000-2000. You can´t see any series any more.
If I don´t use the Chart1Zoom Event, then the Y axis won´t be zoomed. Only the x axis - what is ok.
2) Scrolling chart with the mouse wheel
I use this code:
Works great in both directions. You can scroll vertical by pressing the Alt key and it works. If you want to scroll horizontal by releasing the Alt key you have to click into the chart first. If you don´t click you won´t be able to scroll the chart in horizontal direction.
How can I change this so that no additional click is necessary?
There are still 2 small problems:
1) custom Y axis
I use only custom Y axis and I zoom these axis with this code:
Code: Select all
procedure TForm1.Chart1Zoom(Sender: TObject);
var Achse : TChartAxis;
i : Byte;
begin
if Chart1.Zoom.Direction in [tzdBoth, tzdVertical] then
for i := 0 to Chart1.SeriesCount - 1 do begin
Achse := Chart1.Series[i].GetVertAxis;
if Achse.Visible then
Achse.SetMinMax(Achse.CalcPosPoint(Chart1.Zoom.Y1),Achse.CalcPosPoint(Chart1.Zoom.Y0));
end;
end;
Code: Select all
procedure TForm1.Chart1MouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
if ([ssShift,ssCtrl] <= Shift) then
with Chart1 do begin
if (WheelDelta > 0) then Chart1.ZoomPercent(110)
else Chart1.ZoomPercent(90);
Handled:=True;
end;
end;
If I don´t use the Chart1Zoom Event, then the Y axis won´t be zoomed. Only the x axis - what is ok.
2) Scrolling chart with the mouse wheel
I use this code:
Code: Select all
procedure TForm1.Chart1MouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
if ([ssAlt] <= Shift) then
with Chart1.BottomAxis do begin
Scroll(WheelDelta*(Maximum-Minimum)/1000,False);
Handled:=True;
end;
Chart1.SetFocus;
end;
How can I change this so that no additional click is necessary?
Greetz Dominik
http://www.logview.info
http://www.logview.info
Hi,
have you tried changing the :
Chart1.SetFocus;
by
Chart1.TabStop := true;
?
have you tried changing the :
Chart1.SetFocus;
by
Chart1.TabStop := true;
?
Pep Jorge
http://support.steema.com
http://support.steema.com
Event fires each time you turn a wheel - 10% for each Wheel movement is too much!9349911 wrote:If you try this and use the scrolling wheel for zooming (with pressed Shift, CTRL) the Y axis are zoomed dramatically.
It seems we work in parallel direction. My work is on progress, I can only mention I turned from ZoomPercent to ZoomRect and now it works with custom axis as well.9349911 wrote: If I don´t use the Chart1Zoom Event, then the Y axis won´t be zoomed.
I didn't catch the point. Your code and comment regarding Alt-key operation seems controversial. Anyhow, firing Wheel event is beyond TeeChart and it seems you have enable TChart to catch it yourself, i.g. providing handler for OnExit events of all other contols, or may be catch corresponding Window message.9349911 wrote: You can scroll vertical by pressing the Alt key and it works. If you want to scroll horizontal by releasing the Alt key you have to click into the chart first. If you don´t click you won´t be able to scroll the chart in horizontal direction.