Recent

Author Topic: [SOLVED] How to mousewheelzoom only horizontally?  (Read 5929 times)

CM630

  • Hero Member
  • *****
  • Posts: 1676
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
[SOLVED] How to mousewheelzoom only horizontally?
« on: August 10, 2012, 02:59:27 pm »
I am trying to mousewheel zoom only horizontally, using ChartToolset1ZoomMouseWheelTool.
http://wiki.freepascal.org/TAChart_documentation#Zoom_click_tool says
ZoomRatio allows to set non-proportional zoom by indicating ratio of X to Y scale.
If I get it right if ZoomRatio is >1 then moving the mouse should scale more horizontally, than vertically, and respectively if 0<ZoomRatio<1 it shall scale more vertically.
So I tried both with ZoomRatio= 10 and ZoomRatio=0,1 but in both cases it scrolls only vertically, instead of vertically in one of the cases and horizontally in the other.
I tried to use a negative value for ZoomRatio, and as to no surprise zoom stopped working.

I tried this on Lazarus 1,0 RC.
« Last Edit: August 13, 2012, 08:37:42 am by paskal »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to mousewheelzoom only horizontally?
« Reply #1 on: August 10, 2012, 05:44:26 pm »
If I understand you correctly I would look in to axis interval to set a smaller number count this should show less marks in the visible space (I think the visible rectangle they call it extend which is a bit weird and to generic in my opinion) or any other way to reduce the number of values in the visible area of the chart.

Please keep in mind that I have not used this component at all, I'm offering only my view on them from what I can understand from the documentation you have posted a link to. I might be way of the mark here so I would like to know if you finally manage to get the effect you are after on how you did it.

regards
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

wp

  • Hero Member
  • *****
  • Posts: 13486
Re: How to mousewheelzoom only horizontally?
« Reply #2 on: August 10, 2012, 09:20:31 pm »
When you look at the source code of TZoomMouseWheelTool, method MousewheelDown, you see a code like this:

Code: [Select]
  DoZoomStep(APoint, DoublePoint(ZoomFactor, ZoomFactor * ZoomRatio));

This performs the zooming operation centered at the point and using the DoublePoint with x and y zoom factors:
  • xfactor = ZoomFactor
  • yfactor = ZoomFactor * ZoomRatio
So, if you want to zoom only horizontally, the y zoom factor must be 1, i.e. ZoomFactor*ZoomRatio = 1, or ZoomRatio = 1/ZoomFactor. For example, when your ZoomFactor for the x axis is 1.1, then ZoomRatio must be 1/1.1 = 0.909

Similarly, if you only want to zoom vertically, the x factor must be 1, i.e. ZoomFactor = 1, and you can use ZoomRatio alone to determine the y zoom factor.

And finally, in the normal case, when x and y should zoom in the same ratio, you need to keep ZoomRatio at 1 and determine the overall zoom factor by the ZoomFactor alone.

Thank you for this question - it motivated me to figure this out...
« Last Edit: August 10, 2012, 09:30:35 pm by wp »

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: How to mousewheelzoom only horizontally?
« Reply #3 on: August 11, 2012, 06:44:53 am »
Thanks wp, this is correct.

I have added part of your explanation to the docs:
http://wiki.lazarus.freepascal.org/TAChart_documentation#Zoom_click_tool

wp

  • Hero Member
  • *****
  • Posts: 13486
Re: How to mousewheelzoom only horizontally?
« Reply #4 on: August 11, 2012, 07:27:55 pm »
Added a sentence defining the X and Y zoom factors mentioned in the text, but nowhere explained.

CM630

  • Hero Member
  • *****
  • Posts: 1676
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How to mousewheelzoom only horizontally?
« Reply #5 on: August 13, 2012, 08:37:23 am »
Thank you, case solved.
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

CM630

  • Hero Member
  • *****
  • Posts: 1676
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: [SOLVED] How to mousewheelzoom only horizontally?
« Reply #6 on: September 13, 2012, 02:18:13 pm »
Probably it shall be mentioned in the wiki, that in Lazarus 1,1 zoom factors are defined differently (RatioLimit= zrlFixedX, zrlFixedY,zrlNone, zrlProportional).
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: [SOLVED] How to mousewheelzoom only horizontally?
« Reply #7 on: September 13, 2012, 03:24:38 pm »
It is mentioned, see last sentence of this section:
http://wiki.lazarus.freepascal.org/TAChart_documentation#Zoom_drag_tool

This feature is not different between 1.0 and 1.1

 

TinyPortal © 2005-2018